47 lines
2.1 KiB
JavaScript
47 lines
2.1 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 [employeePage, supervisorPage] = await Promise.all([
|
|
read('../src/pages/user/work-results/index.vue'),
|
|
read('../src/pages/supervisor/work-results/index.vue')
|
|
]);
|
|
|
|
const actionableStatuses = /\['PENDING',\s*'IN_PROGRESS'\]\.includes\(item\.businessStatus\)/;
|
|
assert.match(employeePage, actionableStatuses);
|
|
assert.match(supervisorPage, /\['PENDING','IN_PROGRESS'\]\.includes\(item\.businessStatus\)/);
|
|
assert.doesNotMatch(employeePage, /!\['COMPLETED',\s*'VOID'\]\.includes\(item\.businessStatus\)/);
|
|
assert.doesNotMatch(supervisorPage, /!\['COMPLETED','VOID'\]\.includes\(item\.businessStatus\)/);
|
|
});
|
|
|
|
test('员工成果页与主管成果页复用真实项目成果接口', async () => {
|
|
const [employeePage, supervisorPage, service] = await Promise.all([
|
|
read('../src/pages/user/work-results/index.vue'),
|
|
read('../src/pages/supervisor/work-results/index.vue'),
|
|
read('../src/services/work-results.ts')
|
|
]);
|
|
|
|
assert.match(employeePage, /generateMyWorkResult/);
|
|
assert.match(supervisorPage, /getProjectWorkResult/);
|
|
assert.match(service, /\/api\/aihr\/work-results\/mine\/generate/);
|
|
assert.match(service, /\/api\/aihr\/work-results\/project/);
|
|
});
|
|
|
|
test('员工与主管成果页都能追溯非文字原始来源', async () => {
|
|
const [employeePage, supervisorPage, preview] = await Promise.all([
|
|
read('../src/pages/user/work-results/index.vue'),
|
|
read('../src/pages/supervisor/work-results/index.vue'),
|
|
read('../src/services/source-preview.ts')
|
|
]);
|
|
|
|
assert.match(employeePage, /openProtectedSource/);
|
|
assert.match(supervisorPage, /原始来源/);
|
|
assert.match(supervisorPage, /openProtectedSource/);
|
|
assert.match(preview, /createInnerAudioContext/);
|
|
assert.match(preview, /previewMedia/);
|
|
assert.doesNotMatch(employeePage, /openDocument/);
|
|
});
|