import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import test from 'node:test'; const read = (path) => readFile(new URL(path, import.meta.url), 'utf8'); test('问师傅为文字、媒体和数据工具请求携带同一短期会话版本', async () => { const service = await read('../src/services/knowledge.ts'); assert.match(service, /conversationId:\s*conversation\?\.conversationId/); assert.match(service, /contextVersion:\s*conversation\?\.contextVersion/); assert.match(service, /conversationId:\s*conversation\.conversationId/); assert.match(service, /resources:\s*response\.resources \|\| \[\]/); }); test('问师傅支持显式新对话、版本回写和受控原文件或视频卡', async () => { const [page, header] = await Promise.all([ read('../src/pages/user/sop/index.vue'), read('../src/components/chat/AskSourceHeader.vue') ]); assert.match(page, /@new-conversation="startNewConversation"/); assert.match(header, /@click="emit\('newConversation'\)">新对话/); assert.match(page, /const contextVersion = ref\(0\)/); assert.match(page, /applyConversationState\(nextResult\)/); assert.match(page, /authenticatedFileUrl\(resource\.contentUrl\)/); assert.match(page, /releaseAuthenticatedFileUrl\(resource\.localUrl\)/); assert.match(page, /resource\.type === 'VIDEO' && resource\.localUrl/); assert.match(page, /msg\.result\.rewrittenQuery !== msg\.result\.queryText/); assert.match(page, /已结合本次对话理解/); }); test('工作助手按项目名称选择并为文字、媒体和工具请求携带项目上下文', async () => { const [page, service, auth] = await Promise.all([ read('../src/pages/user/sop/index.vue'), read('../src/services/knowledge.ts'), read('../src/services/auth.ts') ]); assert.match(page, />当前项目 { const page = await read('../src/pages/user/sop/index.vue'); assert.match(page, /inset:\s*0 0 var\(--window-bottom, 0px\)/); assert.match(page, /let scrollSeq = 0/); assert.match(page, /threadScrollTop\.value = 100000 \+ \(\+\+scrollSeq \* 200\)/); });