Files
X-Financial/web/tests/travel-reimbursement-composer-tools.test.mjs
caoxiaozhu 88ff04bef8 feat: 新增归档中心页面并完善知识库与报销查询能力
新增前端归档中心视图及相关工具函数,扩充知识库文档分类和
提取器支持多种格式,增强编排器报销查询的多维度检索,优
化本体规则和用户代理审核消息,前端完善报销创建和审批详
情交互细节,补充单元测试覆盖。
2026-05-22 16:00:19 +08:00

41 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
import {
buildStructuredComposerSubmitText
} from '../src/views/scripts/useTravelReimbursementComposerTools.js'
const submitComposerScript = readFileSync(
fileURLToPath(new URL('../src/views/scripts/useTravelReimbursementSubmitComposer.js', import.meta.url)),
'utf8'
)
test('composer formats date-picker expense text into readable structured fields', () => {
const formatted = buildStructuredComposerSubmitText(
'发生时间2026-05-20 至 2026-05-23去上海支撑上海国电的服务器部署出差3天',
{
mode: 'range',
start_date: '2026-05-20',
end_date: '2026-05-23',
business_time: '2026-05-20 至 2026-05-23'
}
)
assert.equal(
formatted,
[
'发生时间2026-05-20 至 2026-05-23',
'地点:上海',
'事由:支撑上海国电的服务器部署',
'天数3天'
].join('\n')
)
})
test('composer keeps backend raw text but displays structured user message', () => {
assert.match(submitComposerScript, /const rawText = resolveComposerSubmitText\(options\.rawText\)\.trim\(\)/)
assert.match(submitComposerScript, /resolveComposerDisplaySubmitText\(rawText\)/)
})