Files
memind/wechat/page-refine-target.test.mjs
T
john 8f88eec2bd
Memind CI / Test, build, and release guards (push) Successful in 4m40s
Separate WeChat chat, page refine, and task flows with explicit routing.
Add channel prefixes, pin edit targets in Cursor prompts, and force fresh sessions for page refine URLs so DeepSeek/Goose chat history does not pollute page tasks.

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

58 lines
2.4 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { buildPageGenerateAgentPrompt } from './prompts/page-generate.mjs';
import {
buildPageRefineTargetPromptBlock,
buildWechatPageRefineUserMessageTemplate,
extractMindSpacePublicHtmlPath,
isWechatPageRefineRequestText,
} from './page-refine-target.mjs';
test('extractMindSpacePublicHtmlPath parses MindSpace public URLs', () => {
assert.equal(
extractMindSpacePublicHtmlPath(
'https://m.tkmind.cn/MindSpace/a70ff537-8908-486e-9b6c-042e07cc25db/public/shengsi-3day-guide.html请改详细',
),
'public/shengsi-3day-guide.html',
);
assert.equal(extractMindSpacePublicHtmlPath('public/demo.html'), null);
});
test('buildPageRefineTargetPromptBlock pins relative path for URL refine', () => {
const block = buildPageRefineTargetPromptBlock(
'https://m.tkmind.cn/MindSpace/a70ff537-8908-486e-9b6c-042e07cc25db/public/shengsi-3day-guide.html 页面更详细到时间节点',
);
assert.match(block, /public\/shengsi-3day-guide\.html/);
assert.match(block, /edit_file/);
});
test('buildPageRefineTargetPromptBlock covers refine without URL', () => {
const block = buildPageRefineTargetPromptBlock('页面还不够详细,必须详细到时间节点');
assert.match(block, /改页任务/);
assert.doesNotMatch(block, /相对路径:public\//);
});
test('buildPageGenerateAgentPrompt includes page refine target block', () => {
const prompt = buildPageGenerateAgentPrompt({
agentText: 'https://m.tkmind.cn/MindSpace/a70ff537-8908-486e-9b6c-042e07cc25db/public/shengsi-3day-guide.html 把页面更新更详细',
});
assert.match(prompt, /改页目标文件/);
assert.match(prompt, /public\/shengsi-3day-guide\.html/);
});
test('buildWechatPageRefineUserMessageTemplate formats copy-paste message', () => {
const text = buildWechatPageRefineUserMessageTemplate({
publicHtmlPath: 'public/shengsi-3day-guide.html',
requirements: '按 Day1/Day2/Day3 细化到具体时间点',
publicUrl: 'https://m.tkmind.cn/MindSpace/u/public/shengsi-3day-guide.html',
});
assert.match(text, /public\/shengsi-3day-guide\.html/);
assert.match(text, /Day1/);
assert.match(text, /不要新建页面/);
});
test('isWechatPageRefineRequestText detects refine intents', () => {
assert.equal(isWechatPageRefineRequestText('页面还不够详细'), true);
assert.equal(isWechatPageRefineRequestText('帮我推荐跑步路线'), false);
});