9b4a25799f
Replace fixed ackText with a rule-based AckProvider that picks response templates by message type and intent (translate, summary, rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync, zero I/O, auto-falls back to config.ackText on any error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { createScheduleService } from './schedule-service.mjs';
|
|
|
|
test('listUserNotifications accepts mysql JSON columns returned as objects', async () => {
|
|
const service = createScheduleService({
|
|
async query(sql) {
|
|
assert.match(sql, /FROM h5_user_notifications/);
|
|
return [
|
|
[
|
|
{
|
|
id: 'notification-1',
|
|
user_id: 'user-1',
|
|
channel: 'wechat',
|
|
notification_type: 'balance_low',
|
|
title: '余额不足提醒',
|
|
body: '你的账户余额已低于 20.00 元,请及时充值。',
|
|
data_json: { thresholdCents: 2000 },
|
|
status: 'unread',
|
|
read_at: null,
|
|
created_at: 1782313300000,
|
|
updated_at: 1782313300000,
|
|
},
|
|
],
|
|
];
|
|
},
|
|
});
|
|
|
|
const notifications = await service.listUserNotifications({ userId: 'user-1' });
|
|
|
|
assert.equal(notifications.length, 1);
|
|
assert.deepEqual(notifications[0].data, { thresholdCents: 2000 });
|
|
});
|