From b56dcec118d5630e6cfcd66d45ec4e9f29c3263d Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 11 Aug 2026 08:55:15 +0200 Subject: [PATCH] Type the cron registrar stub so the tests typecheck again typecheck:tests landed with the contract ratchet; the scheduler migration merged after it, and its idempotency-cleanup test stubs register() with no parameters. Reading calls[0][2] back off a no-parameter mock types every recorded call as [], which is a tuple index error, so dev has been red since. Give the stub the real register() signature and drop the cast it needed. --- server/tests/unit/idempotency-cleanup.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/tests/unit/idempotency-cleanup.test.ts b/server/tests/unit/idempotency-cleanup.test.ts index 2005738ef..4f33be11c 100644 --- a/server/tests/unit/idempotency-cleanup.test.ts +++ b/server/tests/unit/idempotency-cleanup.test.ts @@ -64,7 +64,10 @@ describe('IdempotencyCleanupJob', () => { function makeJob(enabled = true) { const registrar = { isEnabled: vi.fn(() => enabled), - register: vi.fn(() => enabled), + // Spelled out rather than vi.fn(() => enabled), because the test below + // reads the third argument back off mock.calls: a no-parameter stub types + // every recorded call as [], and indexing it fails typecheck:tests. + register: vi.fn((_name: string, _expression: string, _onTick: () => void | Promise) => enabled), unregister: vi.fn(), }; const job = new IdempotencyCleanupJob(new DatabaseService(db), registrar as unknown as CronRegistrarService); @@ -78,7 +81,7 @@ describe('IdempotencyCleanupJob', () => { // The registered callback IS the tick — drive it once over an empty table // (nothing to purge → no log, no throw). - const onTick = on.registrar.register.mock.calls[0][2] as () => void; + const onTick = on.registrar.register.mock.calls[0][2]; expect(() => onTick()).not.toThrow(); const off = makeJob(false);