Skip to content

Commit 8177812

Browse files
authored
Update test.rerun.spec.ts
1 parent ad0dd10 commit 8177812

1 file changed

Lines changed: 46 additions & 12 deletions

File tree

src/commands/test.rerun.spec.ts

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4829,17 +4829,19 @@ describe('[finding-5] batch rerun --wait: RequestTimeoutError during fan-out pol
48294829
const batchResp: BatchRerunResponse = {
48304830
accepted: [
48314831
{ testId: 'test_1', runId: 'run_b1', enqueuedAt: '2026-06-03T10:00:00.000Z' },
4832-
{ testId: 'test_2', runId: 'run_b2', enqueuedAt: '2026-06-03T10:00:00.000Z' }
4832+
{ testId: 'test_2', runId: 'run_b2', enqueuedAt: '2026-06-03T10:00:00.000Z' },
48334833
],
48344834
deferred: [],
48354835
conflicts: [],
4836-
closure: { byProject: [] }
4836+
closure: { byProject: [] },
48374837
};
4838+
48384839
const fetchImpl = makeFetch((url) => {
48394840
if (url.includes('/tests/batch/rerun')) return { status: 202, body: batchResp };
4840-
if (url.includes('/runs/')) throw new RequestTimeoutError(120000, 'req_timeout_batch');
4841+
if (url.includes('/runs/')) throw new RequestTimeoutError(120000, 'req_timeout_batch_rerun');
48414842
return errorBody('NOT_FOUND');
48424843
});
4844+
48434845
const stdoutLines: string[] = [];
48444846
const err = await runTestRerun(
48454847
{
@@ -4853,27 +4855,52 @@ describe('[finding-5] batch rerun --wait: RequestTimeoutError during fan-out pol
48534855
maxConcurrency: 1,
48544856
profile: 'default',
48554857
output: 'json',
4856-
debug: false
4858+
debug: false,
48574859
},
4858-
{ ...creds, sleep: instantSleep, fetchImpl: fetchImpl as unknown as FetchImpl, stdout: (l) => stdoutLines.push(l), stderr: () => undefined }
4860+
{
4861+
...creds,
4862+
sleep: instantSleep,
4863+
fetchImpl: fetchImpl as unknown as FetchImpl,
4864+
stdout: (line) => stdoutLines.push(line),
4865+
stderr: () => undefined,
4866+
}
48594867
).catch((e) => e);
4868+
48604869
expect(err).toMatchObject({ exitCode: 7 });
4870+
const parsed = JSON.parse(stdoutLines.join('\n')) as {
4871+
accepted?: Array<{ testId?: string; runId: string; status?: string }>;
4872+
};
4873+
expect(parsed.accepted).toHaveLength(2);
4874+
expect(parsed.accepted.map((r) => r.runId).sort()).toEqual(['run_b1', 'run_b2']);
4875+
expect(parsed.accepted.every((r) => r.status === 'timeout')).toBe(true);
48614876
});
48624877
});
48634878

48644879
// ---------------------------------------------------------------------------
48654880
// TimeoutError on single FE rerun --wait: partial stdout + exit 7
48664881
// ---------------------------------------------------------------------------
48674882
describe('[finding-4] single FE rerun --wait: TimeoutError writes partial JSON to stdout', () => {
4868-
it('exit 7 AND stdout contains {runId, status:"running"} when --timeout polling deadline is exceeded', async () => {
4883+
it('exit 7 AND stdout contains {runId, status:\"running\"} when --timeout polling deadline is exceeded', async () => {
48694884
const creds = makeCreds();
48704885
const rerunResp = { runId: 'run_fe_01', status: 'accepted' };
4871-
const fetchImpl: FetchImpl = async (input) => {
4872-
const url = typeof input === 'string' ? input : (input as Request).url;
4873-
if (url.includes('/runs/rerun')) return new Response(JSON.stringify(rerunResp), { status: 202 });
4874-
if (url.includes('/runs/')) return new Response(JSON.stringify({ runId: rerunResp.runId, status: 'running', finishedAt: null }), { status: 200 });
4886+
4887+
const fetchImpl: FetchImpl = async (input, _init) => {
4888+
const url =
4889+
typeof input === 'string'
4890+
? input
4891+
: input instanceof URL
4892+
? input.toString()
4893+
: (input as { url: string }).url;
4894+
4895+
if (url.includes('/runs/rerun')) {
4896+
return new Response(JSON.stringify(rerunResp), { status: 202 });
4897+
}
4898+
if (url.includes('/runs/')) {
4899+
return new Response(JSON.stringify({ runId: rerunResp.runId, status: 'running', finishedAt: null }), { status: 200 });
4900+
}
48754901
return new Response(JSON.stringify({ error: { code: 'NOT_FOUND' } }), { status: 404 });
48764902
};
4903+
48774904
const stdoutLines: string[] = [];
48784905
const err = await runTestRerun(
48794906
{
@@ -4887,10 +4914,17 @@ describe('[finding-4] single FE rerun --wait: TimeoutError writes partial JSON t
48874914
maxConcurrency: 10,
48884915
output: 'json',
48894916
profile: 'default',
4890-
debug: false
4917+
debug: false,
48914918
},
4892-
{ ...creds, sleep: instantSleep, fetchImpl: fetchImpl as unknown as FetchImpl, stdout: (l) => stdoutLines.push(l), stderr: () => undefined }
4919+
{
4920+
...creds,
4921+
sleep: instantSleep,
4922+
fetchImpl: fetchImpl as unknown as FetchImpl,
4923+
stdout: (line) => stdoutLines.push(line),
4924+
stderr: () => undefined,
4925+
}
48934926
).catch((e) => e);
4927+
48944928
expect(err).toMatchObject({ exitCode: 7 });
48954929
const parsed = JSON.parse(stdoutLines.join('\n')) as { runId: string; status: string };
48964930
expect(parsed.runId).toBe(rerunResp.runId);

0 commit comments

Comments
 (0)