diff --git a/tests/unit/AiWorker.test.ts b/tests/unit/AiWorker.test.ts index 4212940..cc62f66 100644 --- a/tests/unit/AiWorker.test.ts +++ b/tests/unit/AiWorker.test.ts @@ -7,6 +7,8 @@ import type { AiTelemetryEmitter } from '@main/ai/AiWorker.js'; import type { InferenceProvider } from '@main/ai/InferenceProvider.js'; import type { AiResponse } from '@main/ai/schema.js'; +type EmittedEvent = { kind: string; payload: unknown }; + function makeProvider(overrides: Partial = {}): InferenceProvider { return { name: 'mock', @@ -464,7 +466,7 @@ describe('AiWorker — vocab fetch + per-tag hit/miss (v0.2.3 #3 T7)', () => { dueDate: null })) }); - const emits: Array<{ kind: string; payload: unknown }> = []; + const emits: EmittedEvent[] = []; const w = new AiWorker(repo, provider, { backoffsMs: [0, 0, 0], telemetry: { @@ -477,9 +479,11 @@ describe('AiWorker — vocab fetch + per-tag hit/miss (v0.2.3 #3 T7)', () => { const miss = emits.filter((e) => e.kind === 'tag_vocab_miss'); expect(hit).toHaveLength(1); expect(miss).toHaveLength(1); - expect((hit[0]!.payload as { tagId: number }).tagId).toBeGreaterThan(0); - expect((hit[0]!.payload as { vocabSize: number }).vocabSize).toBe(1); - expect((miss[0]!.payload as { vocabSize: number }).vocabSize).toBe(1); + const hitPayload = hit[0]!.payload as { tagId: number; vocabSize: number }; + const missPayload = miss[0]!.payload as { vocabSize: number }; + expect(hitPayload.tagId).toBeGreaterThan(0); + expect(hitPayload.vocabSize).toBe(1); + expect(missPayload.vocabSize).toBe(1); }); it('all tags miss when vocab is empty', async () => { @@ -492,7 +496,7 @@ describe('AiWorker — vocab fetch + per-tag hit/miss (v0.2.3 #3 T7)', () => { dueDate: null })) }); - const emits: Array<{ kind: string; payload: unknown }> = []; + const emits: EmittedEvent[] = []; const w = new AiWorker(repo, provider, { backoffsMs: [0, 0, 0], telemetry: { emit: vi.fn(async (input) => { emits.push(input); }) } @@ -517,7 +521,7 @@ describe('AiWorker — vocab fetch + per-tag hit/miss (v0.2.3 #3 T7)', () => { dueDate: null })) }); - const emits: Array<{ kind: string; payload: unknown }> = []; + const emits: EmittedEvent[] = []; const w = new AiWorker(repo, provider, { backoffsMs: [0, 0, 0], telemetry: { emit: vi.fn(async (input) => { emits.push(input); }) }