Skip to content

Commit 6c7a0e0

Browse files
committed
fix(dry-run): address failed run sample review
1 parent 9179281 commit 6c7a0e0

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/lib/dry-run/samples.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,13 +562,18 @@ describe('findSample', () => {
562562
expect(body.summary.total).toBeGreaterThanOrEqual(1);
563563
});
564564

565-
it('only one getRun entry exists in the registry (no duplicate)', () => {
566-
// Guards against re-introducing the duplicate by ensuring exactly one
567-
// sample is registered for GET /runs/{runId}.
568-
const matches = DRY_RUN_SAMPLE_ENTRIES.filter(
569-
e => e.method === 'GET' && e.operationId === 'getRun',
565+
it('keeps the failed run sentinel before the generic getRun sample', () => {
566+
// findSample is first-match-wins; exact run fixtures must precede
567+
// `/runs/{runId}` so `test wait --dry-run` still gets the passed sample.
568+
const failedRunIndex = DRY_RUN_SAMPLE_ENTRIES.findIndex(
569+
e => e.method === 'GET' && e.pathTemplate === '/runs/run_failed_sample',
570570
);
571-
expect(matches).toHaveLength(1);
571+
const genericRunIndex = DRY_RUN_SAMPLE_ENTRIES.findIndex(
572+
e => e.method === 'GET' && e.pathTemplate === '/runs/{runId}',
573+
);
574+
expect(failedRunIndex).toBeGreaterThanOrEqual(0);
575+
expect(genericRunIndex).toBeGreaterThanOrEqual(0);
576+
expect(failedRunIndex).toBeLessThan(genericRunIndex);
572577
});
573578

574579
// Input-derived sample tests (Fix #1 — dogfood 2026-05-15)

src/lib/dry-run/samples.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ const passedRunSample: RunResponse = {
363363
error: null,
364364
videoUrl: null,
365365
stepSummary: {
366-
total: 8,
367-
completed: 8,
368-
passedCount: 8,
366+
total: 2,
367+
completed: 2,
368+
passedCount: 2,
369369
failedCount: 0,
370370
},
371371
// Representative per-run steps so `test steps --run-id <id> --dry-run`
@@ -812,6 +812,7 @@ const ENTRIES: DryRunSampleEntry[] = [
812812
// fix(2026-05-21): a duplicate failed-shape entry that appeared before
813813
// this entry was removed; findSample first-match-wins was always
814814
// returning status: "failed" for `test wait --dry-run`.
815+
entry('getRun', 'GET', `/runs/${SAMPLE_FAILED_RUN_ID}`, failedRunSample),
815816
entry('getRun', 'GET', '/runs/{runId}', passedRunSample),
816817
];
817818

@@ -864,10 +865,7 @@ export function findSample(
864865
const pathOnly = extractPath(url);
865866
for (const e of ENTRIES) {
866867
if (e.method === upper && e.pattern.test(pathOnly)) {
867-
const body =
868-
e.operationId === 'getRun' && pathOnly === `/runs/${SAMPLE_FAILED_RUN_ID}`
869-
? failedRunSample
870-
: e.body(requestBody);
868+
const body = e.body(requestBody);
871869
// Rebind body so callers get the resolved value, not the factory.
872870
// We return a new object with `body` already applied so downstream
873871
// code can keep calling `e.body` as-before (no API break for tests

0 commit comments

Comments
 (0)