Files
memind/wechat/morning-greeting-library.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

46 lines
1.3 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
MORNING_GREETING_LIBRARY,
formatMorningGreetingDeliveryText,
pickDailyMorningGreeting,
} from './morning-greeting-library.mjs';
test('pickDailyMorningGreeting returns stable message for same user and day', () => {
const args = {
userId: 'user-a',
timezone: 'Asia/Shanghai',
now: Date.parse('2026-09-10T08:00:00+08:00'),
};
const first = pickDailyMorningGreeting(args);
const second = pickDailyMorningGreeting(args);
assert.equal(first, second);
assert.ok(MORNING_GREETING_LIBRARY.includes(first));
});
test('pickDailyMorningGreeting changes message across days', () => {
const userId = 'user-b';
const dayOne = pickDailyMorningGreeting({
userId,
timezone: 'Asia/Shanghai',
now: Date.parse('2026-09-10T08:00:00+08:00'),
});
const dayTwo = pickDailyMorningGreeting({
userId,
timezone: 'Asia/Shanghai',
now: Date.parse('2026-09-11T08:00:00+08:00'),
});
assert.notEqual(dayOne, dayTwo);
});
test('formatMorningGreetingDeliveryText wraps greeting with morning header', () => {
const text = formatMorningGreetingDeliveryText({
userId: 'user-c',
timezone: 'Asia/Shanghai',
now: Date.parse('2026-09-10T08:00:00+08:00'),
});
assert.match(text, /^☀️ 早安\n\n/);
assert.ok(text.length > 20);
});