From 727eeb1919a4b5039dfb47d3d73a249183493eba Mon Sep 17 00:00:00 2001 From: altair823 Date: Sat, 2 May 2026 12:36:16 +0900 Subject: [PATCH] =?UTF-8?q?fix(tag-vocab):=20T7=20review=20nit=202?= =?UTF-8?q?=EA=B1=B4=20=E2=80=94=20test=20=EC=BD=94=EB=93=9C=20ergonomics?= =?UTF-8?q?=20(#3=20v0.2.3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nit1: tag_vocab_hit/miss 테스트 payload cast dedupe (한 번에 typed 바인딩) - nit2: { kind: string; payload: unknown } 반복을 EmittedEvent 타입 alias 로 hoist skip: Minor1 (serial await — ai_succeeded 와 패턴 일관), Nit3 (magic number VOCAB_TOP_N — v0.2.4 backlog), Nit4 (한국어 코멘트 — 기존 코드와 일관) Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/unit/AiWorker.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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); }) }