47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
|
|
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'
|
||
|
|
)
|
||
|
|
|
||
|
|
test('expense application submit uses rich text link and confirm dialog', () => {
|
||
|
|
const copy = '请核对上述信息无误,确认无误后 [确认](#application-submit) 提交至审批流程。'
|
||
|
|
const rendered = renderMarkdown(copy)
|
||
|
|
|
||
|
|
assert.match(
|
||
|
|
rendered,
|
||
|
|
/<a href="#application-submit" class="markdown-action-link markdown-action-link-confirm">确认<\/a>/
|
||
|
|
)
|
||
|
|
assert.match(createViewTemplate, /:open="applicationSubmitConfirmDialog\.open"/)
|
||
|
|
assert.match(createViewTemplate, /title="确认提交当前费用申请?"/)
|
||
|
|
assert.match(createViewTemplate, /description="提交后申请将进入领导审核流程,并同步纳入预算管理口径/)
|
||
|
|
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,
|
||
|
|
/async function confirmApplicationSubmit\(\)[\s\S]*rawText: '确认提交'[\s\S]*systemGenerated: true/
|
||
|
|
)
|
||
|
|
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'/
|
||
|
|
)
|
||
|
|
})
|