feat: split h5 direct chat from goosed tasks
This commit is contained in:
+31
-2
@@ -189,6 +189,30 @@ test('sanitizePublicHtmlLinksInText keeps existing own public html links', () =>
|
||||
}
|
||||
});
|
||||
|
||||
test('sanitizePublicHtmlLinksInText canonicalizes wrong MindSpace public hosts', () => {
|
||||
const owner = `test-user-${Date.now()}-canonical-host`;
|
||||
const previousBase = process.env.H5_PUBLIC_BASE_URL;
|
||||
process.env.H5_PUBLIC_BASE_URL = 'http://127.0.0.1:5173';
|
||||
const htmlPath = path.join(process.cwd(), 'MindSpace', owner, 'public', 'MIT-guide.html');
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(htmlPath), { recursive: true });
|
||||
fs.writeFileSync(htmlPath, '<!doctype html><title>MIT</title>');
|
||||
const text =
|
||||
`[下载页面](https://mindspace.tkmind.com/MindSpace/${owner}/public/MIT-guide.html)`;
|
||||
const next = sanitizePublicHtmlLinksInText(text, { id: owner, username: 'john' });
|
||||
assert.doesNotMatch(next, /mindspace\.tkmind\.com/);
|
||||
assert.match(
|
||||
next,
|
||||
new RegExp(`http://127\\.0\\.0\\.1:5173/MindSpace/${owner}/public/MIT-guide\\.html`),
|
||||
);
|
||||
assert.doesNotMatch(next, /页面生成未完成/);
|
||||
} finally {
|
||||
if (previousBase == null) delete process.env.H5_PUBLIC_BASE_URL;
|
||||
else process.env.H5_PUBLIC_BASE_URL = previousBase;
|
||||
fs.rmSync(path.join(process.cwd(), 'MindSpace', owner), { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('sanitizeSessionConversationPublicHtmlLinks updates text items inside conversation messages', () => {
|
||||
const owner = `test-user-${Date.now()}-conversation`;
|
||||
const publicRoot = path.join(process.cwd(), 'MindSpace', owner, 'public');
|
||||
@@ -261,7 +285,7 @@ test('sanitizeSessionConversationPublicHtmlLinks removes internal user prompt no
|
||||
test('buildVisionPayload injects public standard image urls for page generation', async () => {
|
||||
const payload = await buildVisionPayload({
|
||||
userId: 'user-1',
|
||||
publishLayout: { publicUrl: 'https://mm.tkmind.cn/MindSpace/user-1/' },
|
||||
publishLayout: { publicUrl: 'https://m.tkmind.cn/MindSpace/user-1/' },
|
||||
userMessage: {
|
||||
content: [
|
||||
{
|
||||
@@ -273,10 +297,15 @@ test('buildVisionPayload injects public standard image urls for page generation'
|
||||
llmProviderService: {
|
||||
analyzeImagesWithVision: async () => '图片里是一位成年人。',
|
||||
},
|
||||
fetchImpl: async () => ({
|
||||
ok: true,
|
||||
arrayBuffer: async () => Buffer.from('fake-image'),
|
||||
headers: new Map([['content-type', 'image/jpeg']]),
|
||||
}),
|
||||
});
|
||||
|
||||
const text = payload?.userMessage?.content?.[0]?.text ?? '';
|
||||
assert.match(text, /https:\/\/mm\.tkmind\.cn\/MindSpace\/user-1\/public\/images\/2026-06-29\/hero\.jpg/);
|
||||
assert.match(text, /https:\/\/m\.tkmind\.cn\/MindSpace\/user-1\/public\/images\/2026-06-29\/hero\.jpg/);
|
||||
assert.doesNotMatch(text, /plain\/local:\/\//);
|
||||
assert.match(text, /无需 cookie 的公开压缩标准图片/);
|
||||
assert.match(text, /不得改写图片里人物的年龄、性别、人数或主体关系/);
|
||||
|
||||
Reference in New Issue
Block a user