Files
memind/wechat-subscribe-morning-llm.test.mjs
T
john e42417bd6e feat(wechat): add subscribe morning reminder, plaza welcome, and LLM fallback
Enable daily morning greeting on reply 1 (with custom time, modify, and cancel),
random greeting delivery, M发现 in subscribe welcome, and optional LLM parsing when
rules miss. Also fix WeChat MP draft/config error passthrough and add Tang E2E scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-10 17:32:10 +08:00

59 lines
1.5 KiB
JavaScript

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);
});