Files
prop-ai-hr/scripts/tests/knowledge-query-client-contract.test.mjs

34 lines
1.3 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 [admin, mobile] = await Promise.all([
read('frontend/src/api/aihr/sop.ts'),
read('mobile-uni/src/services/knowledge.ts')
]);
assert.match(admin, /url:\s*'\/api\/knowledge\/query'/);
assert.match(mobile, /url:\s*'\/api\/knowledge\/query'/);
for (const source of [admin, mobile]) {
assert.doesNotMatch(source, /tenantId\s*:/);
assert.doesNotMatch(source, /extPartyId\s*:/);
assert.doesNotMatch(source, /projectCodes\s*:/);
assert.doesNotMatch(source, /roles\s*:/);
}
});
test('客户端展示引用与无依据状态,并仅发送固定训练工具', async () => {
const [service, page] = await Promise.all([
read('mobile-uni/src/services/knowledge.ts'),
read('mobile-uni/src/pages/user/sop/index.vue')
]);
assert.match(service, /response\.citations/);
assert.match(service, /noEvidence/);
assert.match(page, /result\.noEvidence/);
assert.match(page, /snippet\.spaceCode/);
assert.match(service, /'MY_PRACTICE_SUMMARY' \| 'TEAM_PRACTICE_SUMMARY'/);
assert.doesNotMatch(page, /v-model="spaceCodes"/);
});