2026-05-25 13:35:39 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
|
|
|
|
import { renderMarkdown } from '../src/utils/markdown.js'
|
|
|
|
|
|
|
|
|
|
const createViewTemplate = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/views/TravelReimbursementCreateView.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const createViewScript = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/views/scripts/TravelReimbursementCreateView.js', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
2026-05-27 12:27:17 +08:00
|
|
|
const messageItemStyles = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/assets/styles/components/travel-reimbursement-message-item.css', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
2026-05-25 13:35:39 +08:00
|
|
|
|
|
|
|
|
test('expense application submit uses rich text link and confirm dialog', () => {
|
2026-05-27 12:27:17 +08:00
|
|
|
const copy = '请确认上述的信息是否填写正确?如果准确无误,点击 [确认](#application-submit) 进入审批环节。'
|
2026-05-25 13:35:39 +08:00
|
|
|
const rendered = renderMarkdown(copy)
|
|
|
|
|
|
2026-05-27 12:27:17 +08:00
|
|
|
assert.match(copy, /请确认上述的信息是否填写正确/)
|
|
|
|
|
assert.match(copy, /进入审批环节/)
|
2026-05-25 13:35:39 +08:00
|
|
|
assert.match(
|
|
|
|
|
rendered,
|
|
|
|
|
/<a href="#application-submit" class="markdown-action-link markdown-action-link-confirm">确认<\/a>/
|
|
|
|
|
)
|
2026-05-27 12:27:17 +08:00
|
|
|
assert.match(messageItemStyles, /\.application-preview-footer \{[\s\S]*margin-top: 48px;/)
|
|
|
|
|
assert.match(messageItemStyles, /\.message-answer-markdown :deep\(\.markdown-action-link\) \{[\s\S]*text-decoration: underline;/)
|
2026-05-25 13:35:39 +08:00
|
|
|
assert.match(createViewTemplate, /:open="applicationSubmitConfirmDialog\.open"/)
|
|
|
|
|
assert.match(createViewTemplate, /title="确认提交当前费用申请?"/)
|
2026-05-26 17:29:35 +08:00
|
|
|
assert.match(createViewTemplate, /description="提交后申请将进入领导审核流程,请确认关键申请信息和预计费用已经核对无误。"/)
|
2026-05-25 13:35:39 +08:00
|
|
|
assert.match(createViewTemplate, /@confirm="confirmApplicationSubmit"/)
|
|
|
|
|
assert.match(createViewScript, /const APPLICATION_SUBMIT_HREF = '#application-submit'/)
|
|
|
|
|
assert.match(
|
|
|
|
|
createViewScript,
|
|
|
|
|
/href === APPLICATION_SUBMIT_HREF[\s\S]*openApplicationSubmitConfirm\(message\)/
|
|
|
|
|
)
|
|
|
|
|
assert.match(
|
|
|
|
|
createViewScript,
|
2026-05-26 09:15:14 +08:00
|
|
|
/async function confirmApplicationSubmit\(\)[\s\S]*const applicationSubmitText[\s\S]*rawText: applicationSubmitText[\s\S]*systemGenerated: true[\s\S]*skipScopeGuard: true/
|
2026-05-25 13:35:39 +08:00
|
|
|
)
|
|
|
|
|
assert.match(
|
|
|
|
|
createViewScript,
|
|
|
|
|
/applicationSubmitConfirmDialog\.value = \{[\s\S]*open: false,[\s\S]*message: null[\s\S]*\}[\s\S]*const payload = await submitComposer/
|
|
|
|
|
)
|
|
|
|
|
assert.match(
|
|
|
|
|
createViewScript,
|
|
|
|
|
/emit\('draft-saved', \{[\s\S]*status: 'submitted'[\s\S]*documentType: 'application'/
|
|
|
|
|
)
|
2026-06-03 09:25:23 +08:00
|
|
|
assert.match(createViewScript, /buildTravelPlanningNudgeMessage\(applicationPreview, draftPayload\)/)
|
|
|
|
|
assert.match(createViewScript, /buildTravelPlanningSuggestedActions\(applicationPreview, draftPayload\)/)
|
|
|
|
|
assert.match(createViewScript, /meta:\s*\['行程规划推荐'\]/)
|
|
|
|
|
assert.match(createViewScript, /TRAVEL_PLANNING_ACTION_GENERATE/)
|
|
|
|
|
assert.match(createViewScript, /buildTravelPlanningRecommendation\(sourcePreview, sourceDraftPayload\)/)
|
|
|
|
|
assert.match(createViewScript, /TRAVEL_PLANNING_ACTION_SKIP/)
|
2026-05-25 13:35:39 +08:00
|
|
|
})
|