Files
X-Financial/web/tests/rule-digital-list-visual-consistency.test.mjs
caoxiaozhu 92444e7eae feat: 扩展风险规则体系、审批动态路由与预算中心列表化改造
- 新增 25+ 条风险规则(预算/报销/申请/通用类),完善风险规则模拟与反馈发布机制
- 引入费用审批动态路由、平台风险分级、预审与风险阶段管理
- 预算中心列表化改造,优化票据夹仪表盘与数字员工工作看板
- 新增 Hermes 风险线索收集器、Agent 链路追踪中心
- 扩展数字员工能力库(18 个领域 Skill)与交通费用自动预估
- 完善报销申请快速预览、权限控制与前端测试覆盖
2026-06-01 17:07:14 +08:00

78 lines
4.1 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
const auditAssetList = readFileSync(
fileURLToPath(new URL('../src/components/audit/AuditAssetList.vue', import.meta.url)),
'utf8'
)
const auditViewStyles = readFileSync(
fileURLToPath(new URL('../src/assets/styles/views/audit-view.css', import.meta.url)),
'utf8'
)
const digitalEmployeeList = readFileSync(
fileURLToPath(new URL('../src/components/audit/DigitalEmployeeListPanel.vue', import.meta.url)),
'utf8'
)
const digitalEmployeesView = readFileSync(
fileURLToPath(new URL('../src/views/DigitalEmployeesView.vue', import.meta.url)),
'utf8'
)
const digitalEmployeesViewModel = readFileSync(
fileURLToPath(new URL('../src/views/scripts/digitalEmployeesViewModel.js', import.meta.url)),
'utf8'
)
const digitalEmployeeStyles = readFileSync(
fileURLToPath(new URL('../src/assets/styles/views/digital-employees-view.css', import.meta.url)),
'utf8'
)
test('audit rule name column stays left aligned', () => {
assert.match(auditAssetList, /<table class="audit-asset-table">/)
assert.match(auditViewStyles, /\.audit-asset-table th:first-child,[\s\S]*?text-align: left;/)
assert.match(auditViewStyles, /\.skill-name-cell \{[\s\S]*?text-align: left;/)
})
test('digital employee skill name keeps text avatar prefix', () => {
assert.match(digitalEmployeeList, /class="digital-skill-cell"/)
assert.match(digitalEmployeeList, /class="digital-skill-avatar"/)
assert.match(digitalEmployeeStyles, /\.digital-skill-cell \{[\s\S]*?text-align: left;/)
assert.match(digitalEmployeeStyles, /\.digital-skill-cell \{[\s\S]*?grid-template-columns: 38px minmax\(0, 1fr\);/)
assert.match(digitalEmployeeStyles, /\.digital-skill-avatar \{[\s\S]*?width: 38px;[\s\S]*?border-radius: 11px;/)
assert.match(digitalEmployeeStyles, /\.digital-skill-avatar\.blue \{[\s\S]*?linear-gradient\(135deg, #3b82f6, #2563eb\);/)
})
test('digital employee skill list uses real pagination', () => {
assert.match(digitalEmployeeList, /:show-pagination="!loading && !errorMessage && visibleEmployees\.length > 0"/)
assert.match(digitalEmployeeList, /:show-page-size="true"/)
assert.match(digitalEmployeeList, /:page-size-options="pageSizeOptions"/)
assert.match(digitalEmployeeList, /@page-size-change="changePageSize"/)
assert.match(digitalEmployeeList, /v-for="employee in pagedEmployees"/)
assert.match(digitalEmployeeList, /const pageSize = ref\(10\)/)
assert.match(digitalEmployeeList, /label: '10 条\/页', value: 10/)
assert.match(digitalEmployeeList, /label: '20 条\/页', value: 20/)
assert.match(digitalEmployeeList, /label: '50 条\/页', value: 50/)
assert.match(digitalEmployeeList, /每页 \$\{pageSize\.value\} 条/)
assert.match(digitalEmployeeList, /function changePageSize\(size\) \{[\s\S]*?currentPage\.value = 1/)
})
test('digital employee skill type filter is wired through list and model', () => {
assert.match(digitalEmployeeList, /id="skillCategory"/)
assert.match(digitalEmployeeList, /:label="selectedSkillCategoryLabel"/)
assert.match(digitalEmployeeList, /:options="skillCategoryOptions"/)
assert.match(digitalEmployeeList, /:selected-value="selectedSkillCategory"/)
assert.match(digitalEmployeeList, /selectFilter\('skillCategory', \$event\)/)
assert.match(digitalEmployeeList, /props\.selectedSkillCategory/)
assert.match(digitalEmployeesView, /:selected-skill-category="selectedSkillCategory"/)
assert.match(digitalEmployeesView, /:skill-category-options="skillCategoryOptions"/)
assert.match(digitalEmployeesView, /selectedSkillCategory: selectedSkillCategory\.value/)
assert.match(digitalEmployeesView, /if \(type === 'skillCategory'\)[\s\S]*?selectedSkillCategory\.value = value/)
assert.match(digitalEmployeesView, /selectedSkillCategory\.value = ''/)
assert.match(digitalEmployeesViewModel, /selectedSkillCategory = normalizeText\(filters\.selectedSkillCategory\)/)
assert.match(digitalEmployeesViewModel, /hasSkillCategory/)
assert.match(digitalEmployeesViewModel, /normalizeText\(item\.skillCategory\) !== selectedSkillCategory/)
})