Skip to content

Commit 286ee88

Browse files
committed
chore: add lots for ci failure
1 parent f1ab5f2 commit 286ee88

1 file changed

Lines changed: 35 additions & 34 deletions

File tree

apps/cli/src/__tests__/conformance/scenarios.ts

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,49 @@ async function prepareSeparatedSecondListTarget(
162162
label: string,
163163
): Promise<ListTargetPreparation> {
164164
const sourceDoc = await harness.copyListFixtureDoc(`${label}-source`);
165-
const secondItem = await nthListAddress(harness, stateDir, sourceDoc, 1);
165+
166+
// Discover source items for diagnostics.
167+
const sourceItems = await listDiscoveryItems(harness, stateDir, sourceDoc, 10);
168+
if (sourceItems.length < 2) {
169+
throw new Error(
170+
`[${label}] Source fixture has fewer than 2 list items (found ${sourceItems.length}). ` +
171+
`Items: ${JSON.stringify(sourceItems)}`,
172+
);
173+
}
174+
175+
const secondItem = sourceItems[1]?.address;
176+
if (!secondItem || typeof secondItem !== 'object') {
177+
throw new Error(`[${label}] Second list item has no address. Items: ${JSON.stringify(sourceItems)}`);
178+
}
179+
166180
const separatedDoc = harness.createOutputPath(`${label}-separated`);
167181
const separated = await harness.runCli(
168182
['lists', 'separate', sourceDoc, '--target-json', JSON.stringify(secondItem), '--out', separatedDoc],
169183
stateDir,
170184
);
171-
172185
if (separated.result.code !== 0 || separated.envelope.ok !== true) {
173-
throw new Error(`Failed to prepare separated list fixture for ${label}.`);
186+
throw new Error(
187+
`[${label}] lists separate failed. code=${separated.result.code} ` +
188+
`envelope=${JSON.stringify(separated.envelope)} ` +
189+
`target=${JSON.stringify(secondItem)} ` +
190+
`stderr=${separated.result.stderr.trim() || '<empty>'}`,
191+
);
192+
}
193+
194+
// Re-resolve from the output document (node IDs may change across write/reload).
195+
const postItems = await listDiscoveryItems(harness, stateDir, separatedDoc, 10);
196+
if (postItems.length < 2) {
197+
throw new Error(
198+
`[${label}] Post-separation doc has fewer than 2 list items (found ${postItems.length}). ` +
199+
`Items: ${JSON.stringify(postItems)}`,
200+
);
201+
}
202+
203+
const separatedSecondItem = postItems[1]?.address;
204+
if (!separatedSecondItem || typeof separatedSecondItem !== 'object') {
205+
throw new Error(`[${label}] Post-separation second item has no address. Items: ${JSON.stringify(postItems)}`);
174206
}
175207

176-
const separatedSecondItem = await nthListAddress(harness, stateDir, separatedDoc, 1);
177208
return { docPath: separatedDoc, target: separatedSecondItem };
178209
}
179210

@@ -1264,18 +1295,6 @@ export const SUCCESS_SCENARIOS = {
12641295
'doc.lists.continuePrevious': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
12651296
const stateDir = await harness.createStateDir('doc-lists-continue-previous-success');
12661297
const prepared = await prepareSeparatedSecondListTarget(harness, stateDir, 'doc-lists-continue-previous');
1267-
const probe = await harness.runCli(
1268-
['lists', 'can-continue-previous', prepared.docPath, '--target-json', JSON.stringify(prepared.target)],
1269-
stateDir,
1270-
);
1271-
const canContinue =
1272-
(probe.envelope.ok
1273-
? ((probe.envelope.data as { result?: { canContinue?: boolean }; canContinue?: boolean })?.result
1274-
?.canContinue ?? (probe.envelope.data as { canContinue?: boolean })?.canContinue)
1275-
: undefined) === true;
1276-
if (probe.result.code !== 0 || !probe.envelope.ok || !canContinue) {
1277-
throw new Error('Failed to prepare a continuable target for continue-previous success conformance scenario.');
1278-
}
12791298

12801299
return {
12811300
stateDir,
@@ -1355,24 +1374,6 @@ export const SUCCESS_SCENARIOS = {
13551374
'doc.lists.join': async (harness: ConformanceHarness): Promise<ScenarioInvocation> => {
13561375
const stateDir = await harness.createStateDir('doc-lists-join-success');
13571376
const prepared = await prepareSeparatedSecondListTarget(harness, stateDir, 'doc-lists-join');
1358-
const probe = await harness.runCli(
1359-
[
1360-
'lists',
1361-
'can-join',
1362-
prepared.docPath,
1363-
'--input-json',
1364-
JSON.stringify({ target: prepared.target, direction: 'withPrevious' }),
1365-
],
1366-
stateDir,
1367-
);
1368-
const canJoin =
1369-
(probe.envelope.ok
1370-
? ((probe.envelope.data as { result?: { canJoin?: boolean }; canJoin?: boolean })?.result?.canJoin ??
1371-
(probe.envelope.data as { canJoin?: boolean })?.canJoin)
1372-
: undefined) === true;
1373-
if (probe.result.code !== 0 || !probe.envelope.ok || !canJoin) {
1374-
throw new Error('Failed to prepare a joinable target for join success conformance scenario.');
1375-
}
13761377

13771378
return {
13781379
stateDir,

0 commit comments

Comments
 (0)