Skip to content

Commit 99b9c35

Browse files
committed
fix(dry-run): address failed run sample review
1 parent 6b6de67 commit 99b9c35

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
@@ -595,13 +595,18 @@ describe('findSample', () => {
595595
expect(body.summary.total).toBeGreaterThanOrEqual(1);
596596
});
597597

598-
it('only one getRun entry exists in the registry (no duplicate)', () => {
599-
// Guards against re-introducing the duplicate by ensuring exactly one
600-
// sample is registered for GET /runs/{runId}.
601-
const matches = DRY_RUN_SAMPLE_ENTRIES.filter(
602-
e => e.method === 'GET' && e.operationId === 'getRun',
598+
it('keeps the failed run sentinel before the generic getRun sample', () => {
599+
// findSample is first-match-wins; exact run fixtures must precede
600+
// `/runs/{runId}` so `test wait --dry-run` still gets the passed sample.
601+
const failedRunIndex = DRY_RUN_SAMPLE_ENTRIES.findIndex(
602+
e => e.method === 'GET' && e.pathTemplate === '/runs/run_failed_sample',
603603
);
604-
expect(matches).toHaveLength(1);
604+
const genericRunIndex = DRY_RUN_SAMPLE_ENTRIES.findIndex(
605+
e => e.method === 'GET' && e.pathTemplate === '/runs/{runId}',
606+
);
607+
expect(failedRunIndex).toBeGreaterThanOrEqual(0);
608+
expect(genericRunIndex).toBeGreaterThanOrEqual(0);
609+
expect(failedRunIndex).toBeLessThan(genericRunIndex);
605610
});
606611

607612
// 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
@@ -369,9 +369,9 @@ const passedRunSample: RunResponse = {
369369
error: null,
370370
videoUrl: null,
371371
stepSummary: {
372-
total: 8,
373-
completed: 8,
374-
passedCount: 8,
372+
total: 2,
373+
completed: 2,
374+
passedCount: 2,
375375
failedCount: 0,
376376
},
377377
// Representative per-run steps so `test steps --run-id <id> --dry-run`
@@ -823,6 +823,7 @@ const ENTRIES: DryRunSampleEntry[] = [
823823
// fix(2026-05-21): a duplicate failed-shape entry that appeared before
824824
// this entry was removed; findSample first-match-wins was always
825825
// returning status: "failed" for `test wait --dry-run`.
826+
entry('getRun', 'GET', `/runs/${SAMPLE_FAILED_RUN_ID}`, failedRunSample),
826827
entry('getRun', 'GET', '/runs/{runId}', passedRunSample),
827828
// DEV-331 piece 3 — POST /runs/{runId}/cancel. Method-guarded in
828829
// `findSample` (POST vs `getRun`'s GET), so this can't be shadowed by the
@@ -905,10 +906,7 @@ export function findSample(
905906
const pathOnly = extractPath(url);
906907
for (const e of ENTRIES) {
907908
if (e.method === upper && e.pattern.test(pathOnly)) {
908-
const body =
909-
e.operationId === 'getRun' && pathOnly === `/runs/${SAMPLE_FAILED_RUN_ID}`
910-
? failedRunSample
911-
: e.body(requestBody);
909+
const body = e.body(requestBody);
912910
// Rebind body so callers get the resolved value, not the factory.
913911
// We return a new object with `body` already applied so downstream
914912
// code can keep calling `e.body` as-before (no API break for tests

0 commit comments

Comments
 (0)