fix: require docx generation for downloadable pages

This commit is contained in:
john
2026-07-01 12:07:46 +08:00
parent 6cb1a2475d
commit ee3dd3b23c
9 changed files with 88 additions and 4 deletions
+20
View File
@@ -4,6 +4,7 @@ import fs from 'node:fs';
import path from 'node:path';
import test from 'node:test';
import {
buildWechatAgentPrompt,
buildWechatTextReply,
createWechatMpService,
guardMissingPublicHtmlLinks,
@@ -128,6 +129,25 @@ test('splitWechatText respects WeChat 2048-byte customer service limit', () => {
assert.equal(chunks.join(''), longChinese);
});
test('buildWechatAgentPrompt requires docx generation before html when Word download is requested', () => {
const prompt = buildWechatAgentPrompt({
msgType: 'text',
content: '帮我生成一个行业分布报告页面,提供链接word给我来下载',
});
assert.match(prompt, /docx-generate/);
assert.match(prompt, /public\/\*\.docx/);
assert.match(prompt, /static-page-publish/);
});
test('buildWechatAgentPrompt keeps normal html guidance without docx requirement for plain page requests', () => {
const prompt = buildWechatAgentPrompt({
msgType: 'text',
content: '帮我生成一个简单页面',
});
assert.match(prompt, /static-page-publish/);
assert.doesNotMatch(prompt, /docx-generate/);
});
test('guardMissingPublicHtmlLinks blocks missing MindSpace public html links', async () => {
const text =
'页面已创建:\nhttps://m.tkmind.cn/MindSpace/a70ff537-8908-486e-9b6c-042e07cc25db/public/missing.html';