import assert from 'node:assert/strict'; import test from 'node:test'; import { normalizeSubscribeMorningLlmIntent, parseSubscribeMorningIntentWithLlm, } from './wechat-subscribe-morning-llm.mjs'; test('normalizeSubscribeMorningLlmIntent maps pending confirm with time', () => { const intent = normalizeSubscribeMorningLlmIntent({ action: 'confirm', hour: 7, minute: 30, confidence: 0.92, }, { phase: 'pending', defaultHour: 8, defaultMinute: 0 }); assert.deepEqual(intent, { action: 'confirm', confidence: 0.92, message: null, hour: 7, minute: 30, }); }); test('normalizeSubscribeMorningLlmIntent rejects low confidence', () => { const intent = normalizeSubscribeMorningLlmIntent({ action: 'modify', hour: 7, minute: 0, confidence: 0.2, }, { phase: 'active', minConfidence: 0.65 }); assert.equal(intent.action, 'none'); }); test('parseSubscribeMorningIntentWithLlm uses llm provider json', async () => { const intent = await parseSubscribeMorningIntentWithLlm({ text: '不要八点,改七点半', phase: 'pending', defaultHour: 8, defaultMinute: 0, llmProviderService: { async createChatCompletion() { return { ok: true, reply: JSON.stringify({ action: 'confirm', hour: 7, minute: 30, confidence: 0.95, }), }; }, }, }); assert.equal(intent?.action, 'confirm'); assert.equal(intent?.hour, 7); assert.equal(intent?.minute, 30); });