Files
X-Financial/web/tests/app-shell-detail-alerts.test.mjs
caoxiaozhu 0e861d8fa6 feat: 增强风险规则生成引擎与预算中心页面
后端拆分风险规则生成为解释器、语义分析、本体对齐等子模块,
优化模板执行和流程图生成,完善员工种子数据和导入逻辑,增强
报销单权限策略和草稿持久化,前端新增预算中心视图和趋势图
组件,重构审计页面和风险规则测试对话框交互,完善文档中心
和报销创建页面细节,补充单元测试覆盖。
2026-05-26 09:15:14 +08:00

127 lines
3.5 KiB
JavaScript

import assert from 'node:assert/strict'
import test from 'node:test'
import {
buildDetailAlerts,
hasMissingAttachment,
hasPendingInfo
} from '../src/utils/detailAlerts.js'
test('detail topbar ignores system allowance rows when checking missing tickets', () => {
const request = {
node: '直属领导审批',
approvalKey: 'in_progress',
typeCode: 'travel',
typeLabel: '差旅费',
reason: '上海项目出差',
location: '上海',
city: '上海',
occurredDisplay: '2026-05-13 至 2026-05-15',
amountValue: 1008,
profilePosition: '待补充',
profileGrade: '待补充',
profileManager: '待补充',
expenseItems: [
{
id: 'outbound-train',
itemType: 'train_ticket',
itemReason: '广州南-上海虹桥',
itemLocation: '上海',
itemDate: '2026-05-13',
itemAmount: 354,
invoiceId: 'outbound.png'
},
{
id: 'hotel',
itemType: 'hotel_ticket',
itemReason: '上海中心酒店',
itemLocation: '上海',
itemDate: '2026-05-14',
itemAmount: 354,
invoiceId: 'hotel.png'
},
{
id: 'allowance',
itemType: 'travel_allowance',
itemReason: '系统自动计算出差补贴',
itemLocation: '上海',
itemDate: '2026-05-15',
itemAmount: 300,
invoiceId: '',
isSystemGenerated: true
}
]
}
const alerts = buildDetailAlerts(request).map((item) => item.label)
assert.equal(hasMissingAttachment(request), false)
assert.equal(hasPendingInfo(request), false)
assert.deepEqual(alerts, ['直属领导审批'])
})
test('detail topbar still flags real manual rows without required ticket info', () => {
const request = {
node: '待提交',
approvalKey: 'draft',
typeCode: 'travel',
typeLabel: '差旅费',
reason: '待补充',
location: '待补充',
city: '待补充',
occurredDisplay: '待补充',
amountValue: 0,
expenseItems: [
{
id: 'manual-train',
itemType: 'train_ticket',
itemReason: '',
itemLocation: '',
itemDate: '',
itemAmount: 0,
invoiceId: ''
},
{
id: 'allowance',
itemType: 'travel_allowance',
itemReason: '系统自动计算出差补贴',
itemAmount: 300,
invoiceId: '',
isSystemGenerated: true
}
]
}
const alerts = buildDetailAlerts(request).map((item) => item.label)
assert.equal(hasMissingAttachment(request), true)
assert.equal(hasPendingInfo(request), true)
assert.deepEqual(alerts, ['待提交', '缺少票据', '待补信息'])
})
test('application detail topbar does not ask for receipt attachments', () => {
const request = {
id: 'AP-20260525103045-ABCDEFGH',
claimNo: 'AP-20260525103045-ABCDEFGH',
documentTypeCode: 'application',
node: '直属领导审批',
approvalKey: 'in_progress',
typeCode: 'travel_application',
typeLabel: '差旅费用申请',
reason: '支撑国网服务器上线部署',
location: '上海',
city: '上海',
occurredDisplay: '2026-05-25 ~ 2026-05-28',
amountValue: 12000,
attachmentSummary: '申请单',
secondaryStatusValue: '已进入审批流程',
expenseItems: []
}
const alerts = buildDetailAlerts(request).map((item) => item.label)
assert.equal(hasMissingAttachment(request), false)
assert.equal(alerts.includes('缺少票据'), false)
assert.deepEqual(alerts, ['直属领导审批'])
})