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

40 lines
1.3 KiB
JavaScript

import assert from 'node:assert/strict'
import test from 'node:test'
import {
formatDocumentListTime,
formatDocumentDurationSince,
resolveDocumentStayTimeDisplay
} from '../src/utils/documentCenterTime.js'
test('document center list time keeps the full year in created time', () => {
assert.equal(formatDocumentListTime('2026-05-20T09:30:00'), '2026-05-20 09:30')
assert.equal(formatDocumentListTime('2026-05-20 创建成功'), '2026-05-20 创建成功')
})
test('document center stay time uses current workflow step stay label first', () => {
const label = resolveDocumentStayTimeDisplay({
progressSteps: [
{ label: '创建单据', current: false, time: '已完成' },
{ label: '直属领导审批', current: true, time: '停留 2天3小时' }
],
updatedAt: '2026-05-20T00:00:00.000Z'
})
assert.equal(label, '2天3小时')
})
test('document center stay time falls back to elapsed time from row timestamp', () => {
assert.equal(
formatDocumentDurationSince('2026-05-20T00:00:00.000Z', Date.parse('2026-05-21T01:30:00.000Z')),
'1天1小时'
)
assert.equal(
resolveDocumentStayTimeDisplay(
{ updatedAt: '2026-05-20T00:00:00.000Z' },
Date.parse('2026-05-20T01:05:00.000Z')
),
'1小时5分钟'
)
})