import assert from 'node:assert/strict'; import test from 'node:test'; import { handleWechatScheduledTaskIntent } from './scheduled-task.mjs'; test('handleWechatScheduledTaskIntent passes create requests to goose', async () => { const reply = await handleWechatScheduledTaskIntent({ intent: { msgType: 'text', agentText: '每天6点帮我做今日新闻页面', msgId: 'msg-1', }, user: { userId: 'user-1' }, scheduledTaskService: { async createTask() { throw new Error('should not create from inbound regex'); }, }, }); assert.equal(reply, null); }); test('handleWechatScheduledTaskIntent passes incomplete create requests to goose', async () => { const reply = await handleWechatScheduledTaskIntent({ intent: { msgType: 'text', agentText: '帮我设一个定时自动任务', msgId: 'msg-1', }, user: { userId: 'user-1' }, scheduledTaskService: { async createTask() { throw new Error('should not create from inbound regex'); }, }, }); assert.equal(reply, null); }); test('handleWechatScheduledTaskIntent ignores non automation text', async () => { const reply = await handleWechatScheduledTaskIntent({ intent: { msgType: 'text', agentText: '明天下午三点提醒我开会', msgId: 'msg-1', }, user: { userId: 'user-1' }, scheduledTaskService: { async createTask() { throw new Error('should not create'); }, }, }); assert.equal(reply, null); }); test('handleWechatScheduledTaskIntent still lists tasks', async () => { const reply = await handleWechatScheduledTaskIntent({ intent: { msgType: 'text', agentText: '看看我的定时自动任务', msgId: 'msg-1', }, user: { userId: 'user-1' }, scheduledTaskService: { async listTasks() { return [{ title: '新闻页面', recurrence: 'daily', hour: 6, minute: 0, timezone: 'Asia/Shanghai' }]; }, }, }); assert.match(reply, /新闻页面/u); });