33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
|
|
/** P1-9:任务证据读取面的后台入口必须存在,且只给超级管理员。 */
|
|
|
|
test('task evidence menu is super-admin only', () => {
|
|
const routes = readSource('src/router/routes.ts')
|
|
assert.match(routes, /path: 'records\/task-evidence'[\s\S]*?menuKey: 'admin_task_evidence'[\s\S]*?superAdminOnly: true/,
|
|
'任务证据路由必须带 superAdminOnly')
|
|
|
|
const scope = readSource('src/config/company-scope.ts')
|
|
assert.match(scope, /SUPER_ADMIN_ONLY_MENU_KEYS[^\n]*admin_task_evidence/,
|
|
'菜单 key 必须在超级管理员可见清单里')
|
|
|
|
const guide = readSource('src/layout/operation-guides.ts')
|
|
assert.match(guide, /admin_task_evidence:\s*\{/, '菜单必须配操作指引')
|
|
})
|
|
|
|
test('task evidence page never renders object keys', () => {
|
|
const page = readSource('src/pages/records/TaskEvidencePage.vue')
|
|
assert.doesNotMatch(page, /objectKey|object_key|presign/i, '页面不得展示或持有对象直链')
|
|
assert.match(page, /taskEvidenceDownloadUrl/, '下载必须走鉴权接口')
|
|
assert.match(page, /deleteTaskEvidence/, '删除必须走鉴权接口')
|
|
})
|
|
|
|
test('task evidence api is wired to admin endpoints', () => {
|
|
const api = readSource('src/api/task-evidence.ts')
|
|
assert.match(api, /\/admin\/task-evidence\/files/)
|
|
assert.match(api, /\/admin\/task-evidence\/download\?fileId=/)
|
|
assert.match(api, /\/admin\/task-evidence\/delete/)
|
|
})
|