Files
X-Financial/web/tests/app-shell-detail-alerts.test.mjs
caoxiaozhu d4d5d40569 feat: 新增预算费控模型与报销审批流引擎
后端新增预算费控服务和报销单审批流模块,引入申请人费用画像
算法,优化知识库 RAG 运行时和同步逻辑,完善报销单工作流常
量和明细同步,更新差旅报销规则电子表格,前端新增预算分析
组件和数字员工模型,完善审批对话框和洞察面板交互,优化侧
边栏和顶栏样式,补充单元测试。
2026-05-27 17:31:27 +08:00

151 lines
4.2 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, ['SLA 催单次数 0'])
})
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, ['SLA 催单次数 0', '缺少票据', '待补信息'])
})
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, ['SLA 催单次数 0'])
})
test('detail topbar shows SLA reminder count from direct fields and reminder events', () => {
const directAlerts = buildDetailAlerts({
node: '直属领导审批',
approvalKey: 'in_progress',
slaReminderCount: 2,
expenseItems: []
})
const eventAlerts = buildDetailAlerts({
node: '直属领导审批',
approvalKey: 'in_progress',
riskFlags: [
{ source: 'sla_reminder', message: '下属已催单' },
{ event_type: 'urge', message: '再次催单' }
],
expenseItems: []
})
assert.equal(directAlerts[0].label, 'SLA 催单次数 2')
assert.equal(directAlerts[0].tone, 'warning')
assert.equal(directAlerts[0].icon, 'mdi mdi-bell-ring-outline')
assert.equal(eventAlerts[0].label, 'SLA 催单次数 2')
})