Files
memind/scheduled-task-intent.test.mjs
T
john 81e63c16d3
Memind CI / Test, build, and release guards (push) Failing after 18s
Add scheduled task automation skill with worker execution pipeline.
Introduce scheduled-task-automation for H5 and WeChat, persist tasks in h5_scheduled_tasks, and run due jobs via a dedicated worker that executes agent tasks and delivers results.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-31 08:02:49 +08:00

49 lines
2.2 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
isScheduledTaskIntent,
parseScheduledTaskIntent,
shouldUseScheduledTaskAutomation,
} from './scheduled-task-intent.mjs';
import { shouldUseScheduleAssistant } from './schedule-intent.mjs';
test('detects daily news page automation intent', () => {
assert.equal(shouldUseScheduledTaskAutomation('每天6点帮我做今日新闻页面'), true);
const intent = parseScheduledTaskIntent('每天6点帮我做今日新闻页面');
assert.equal(intent.action, 'create_scheduled_task');
assert.equal(intent.recurrence, 'daily');
});
test('detects explicit scheduled task phrase', () => {
assert.equal(shouldUseScheduledTaskAutomation('帮我设一个定时自动任务'), true);
const intent = parseScheduledTaskIntent('帮我设一个定时自动任务');
assert.equal(intent.action, 'create_scheduled_task');
assert.ok(intent.needsClarification?.includes('schedule'));
assert.ok(intent.needsClarification?.includes('task_spec'));
});
test('does not capture daily todo digest', () => {
assert.equal(shouldUseScheduledTaskAutomation('每天早上7点把当天待办发给我'), false);
assert.equal(parseScheduledTaskIntent('每天早上7点把当天待办发给我').action, 'none');
});
test('does not capture plain reminders', () => {
assert.equal(shouldUseScheduledTaskAutomation('明天下午三点提醒我开会'), false);
assert.equal(shouldUseScheduleAssistant('明天下午三点提醒我开会'), true);
});
test('scheduled automation takes precedence over schedule assistant keyword overlap', () => {
assert.equal(shouldUseScheduledTaskAutomation('每天6点定时任务做新闻页'), true);
assert.equal(shouldUseScheduleAssistant('每天6点定时任务做新闻页'), false);
});
test('parses cancel and list intents', () => {
assert.equal(parseScheduledTaskIntent('取消我的定时任务').action, 'cancel_scheduled_task');
assert.equal(parseScheduledTaskIntent('看看我的定时自动任务').action, 'list_scheduled_tasks');
});
test('isScheduledTaskIntent excludes none', () => {
assert.equal(isScheduledTaskIntent({ action: 'create_scheduled_task' }), true);
assert.equal(isScheduledTaskIntent({ action: 'none' }), false);
});