Skip to content

Commit 715329b

Browse files
mchwangclaude
andcommitted
Test that the wait between required-check inspections doubles to its cap
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cffdf4c commit 715329b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎test/merge-job.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,19 @@ it('ends the job cancelled when the task is cancelled during the job\'s own revi
737737
expect(await settled(f.coordinator)).toMatchObject({ state: 'cancelled', reason: 'Task cancelled.' });
738738
expect(f.gh.merged).toEqual([]);
739739
});
740+
it('doubles the wait between required-check inspections from the first delay up to the maximum', async () => {
741+
// Required checks stay pending long enough for the wait to reach its maximum; only the sleeps between inspections count.
742+
const f = setup({ checks: n => (n <= 6 ? [pending()] : [passing()]) });
743+
const coordinator = new MergeJobCoordinator(f.review, f.prep.fake, f.merges, undefined, { checkWaitMs: 60_000, firstDelayMs: 3, maxDelayMs: 20 }); jobs.push(coordinator);
744+
const waits: number[] = [];
745+
const timer = setTimeout, spy = vi.spyOn(globalThis, 'setTimeout').mockImplementation(((handler: () => void, ms?: number, ...args: unknown[]) => {
746+
// Record the wait only while the job is between inspections of its required checks.
747+
if (coordinator.latest()?.step === 'checks') waits.push(ms ?? 0);
748+
return timer(handler, ms, ...args);
749+
}) as typeof setTimeout);
750+
try {
751+
await coordinator.start('review-token', randomUUID());
752+
expect(await settled(coordinator)).toMatchObject({ state: 'merged' });
753+
} finally { spy.mockRestore(); }
754+
expect(waits).toEqual([3, 6, 12, 20, 20, 20]);
755+
});

0 commit comments

Comments
 (0)