| 3166 | ]; |
| 3167 | |
| 3168 | function makeFailureContext(overrides: Partial<CliFailureContext> = {}): CliFailureContext { |
| 3169 | const result: CliLatestResult = { |
| 3170 | testId: 'test_failed', |
| 3171 | status: 'failed', |
| 3172 | startedAt: '2026-05-05T12:34:00.000Z', |
| 3173 | finishedAt: '2026-05-05T12:34:58.000Z', |
| 3174 | videoUrl: 'https://video.example.com/run_abc.mp4?sig', |
| 3175 | failureAnalysisUrl: null, |
| 3176 | snapshotId: 'snap_2026_05_07_b2f9a1c8', |
| 3177 | runIdIfAvailable: 'run_abc', |
| 3178 | codeVersion: 'v3', |
| 3179 | targetUrl: 'https://staging.example.com/checkout', |
| 3180 | failedStepIndex: 5, |
| 3181 | failureKind: 'assertion', |
| 3182 | summary: { passed: 4, failed: 1, skipped: 0 }, |
| 3183 | ...overrides.result, |
| 3184 | }; |
| 3185 | return { |
| 3186 | snapshotId: 'snap_2026_05_07_b2f9a1c8', |
| 3187 | testId: 'test_failed', |
| 3188 | projectId: 'project_alice', |
| 3189 | result, |
| 3190 | steps: FAILED_STEPS, |
| 3191 | code: { |
| 3192 | testId: 'test_failed', |
| 3193 | language: 'typescript', |
| 3194 | framework: 'playwright', |
| 3195 | code: "import { test } from '@playwright/test';\n", |
| 3196 | codeVersion: 'v3', |
| 3197 | etag: null, |
| 3198 | }, |
| 3199 | failure: { |
| 3200 | rootCauseHypothesis: |
| 3201 | 'Submit button is disabled. Underlying error: AssertionError: expected visible.', |
| 3202 | recommendedFixTarget: { kind: 'unknown', reference: null, rationale: 'fill card field' }, |
| 3203 | evidence: [ |
| 3204 | { |
| 3205 | kind: 'snapshot', |
| 3206 | stepIndex: 4, |
| 3207 | url: 'https://signed.example.com/ev/04.html?sig', |
| 3208 | summary: "Step 4 'Click the cart icon' passed (captured at ...).", |
| 3209 | }, |
| 3210 | { |
| 3211 | kind: 'snapshot', |
| 3212 | stepIndex: 5, |
| 3213 | url: 'https://signed.example.com/ev/05.html?sig', |
| 3214 | summary: "Step 5 'Click the submit button' failed. Error: AssertionError", |
| 3215 | }, |
| 3216 | ], |
| 3217 | }, |
| 3218 | ...overrides, |
| 3219 | }; |
| 3220 | } |
| 3221 | |
| 3222 | describe('runFailureGet', () => { |
| 3223 | it('JSON mode (no --out) prints the wire envelope verbatim to stdout', async () => { |