feat(ai): zod due_date field + prompt {{TODAY_KST}} injection
AiResponse extends with dueDate: string|null. zod regex
^\d{4}-\d{2}-\d{2}$, follow-up roundtrip check coerces invalid
dates (2026-13-99 etc.) to null. PROMPT_VERSION → 2: prompt now
takes todayKst arg, asks model to extract due_date as ISO or null.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,4 +52,49 @@ describe('parseAiResponse', () => {
|
||||
it('rejects non-object input', () => {
|
||||
expect(() => parseAiResponse('nope')).toThrow();
|
||||
});
|
||||
|
||||
it('parses note with valid due_date', () => {
|
||||
const r = parseAiResponse({
|
||||
title: '내일 회의',
|
||||
summary: 'a\nb\nc',
|
||||
tags: [],
|
||||
due_date: '2026-04-27'
|
||||
});
|
||||
expect(r.dueDate).toBe('2026-04-27');
|
||||
});
|
||||
|
||||
it('null due_date passes through', () => {
|
||||
const r = parseAiResponse({
|
||||
title: '내일 회의',
|
||||
summary: 'a\nb\nc',
|
||||
tags: []
|
||||
});
|
||||
expect(r.dueDate).toBeNull();
|
||||
});
|
||||
|
||||
it('explicit null due_date passes through', () => {
|
||||
const r = parseAiResponse({
|
||||
title: '내일 회의',
|
||||
summary: 'a\nb\nc',
|
||||
tags: [],
|
||||
due_date: null
|
||||
});
|
||||
expect(r.dueDate).toBeNull();
|
||||
});
|
||||
|
||||
it('rejects malformed due_date string', () => {
|
||||
expect(() =>
|
||||
parseAiResponse({ title: '내일', summary: 'a\nb\nc', tags: [], due_date: 'tomorrow' })
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('coerces invalid date that passes regex (e.g. 2026-13-99) to null', () => {
|
||||
const r = parseAiResponse({
|
||||
title: '내일 회의',
|
||||
summary: 'a\nb\nc',
|
||||
tags: [],
|
||||
due_date: '2026-13-99'
|
||||
});
|
||||
expect(r.dueDate).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user