fix(tag-vocab): T7 review nit 2건 — test 코드 ergonomics (#3 v0.2.3)
- 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) <noreply@anthropic.com>
This commit is contained in:
@@ -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> = {}): 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); }) }
|
||||
|
||||
Reference in New Issue
Block a user