58 lines
2.6 KiB
JavaScript
58 lines
2.6 KiB
JavaScript
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, />当前项目</);
|
|
assert.match(page, /选择当前项目/);
|
|
assert.match(page, /搜索项目名称/);
|
|
assert.match(page, /saveCurrentProject\(project\)/);
|
|
assert.match(page, /resetConversation\(false\)/);
|
|
assert.match(page, /currentProject\.value\?\.projectCode/);
|
|
assert.match(service, /projectCode/);
|
|
assert.match(auth, /aihr_mobile_current_project:\$\{tenantId/);
|
|
assert.match(auth, /reconcileCurrentProject/);
|
|
});
|
|
|
|
test('项目选择面板避开底栏且确认卡内容增长后重新滚到底部', async () => {
|
|
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\)/);
|
|
});
|