2026-05-22 16:00:19 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
|
|
|
|
import { isArchivedExpenseClaim } from '../src/utils/expenseClaimArchive.js'
|
|
|
|
|
|
|
|
|
|
test('isArchivedExpenseClaim recognizes finance archive stage', () => {
|
|
|
|
|
assert.equal(
|
|
|
|
|
isArchivedExpenseClaim({ status: 'approved', approval_stage: '归档入账' }),
|
|
|
|
|
true
|
|
|
|
|
)
|
2026-05-26 09:15:14 +08:00
|
|
|
assert.equal(
|
|
|
|
|
isArchivedExpenseClaim({
|
|
|
|
|
status: 'approved',
|
|
|
|
|
approval_stage: '审批完成',
|
|
|
|
|
claim_no: 'AP-20260525120000-ABCDEFGH',
|
|
|
|
|
expense_type: 'travel_application'
|
|
|
|
|
}),
|
2026-06-06 17:19:07 +08:00
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
assert.equal(
|
|
|
|
|
isArchivedExpenseClaim({
|
|
|
|
|
status: 'approved',
|
|
|
|
|
approval_stage: '申请归档',
|
|
|
|
|
claim_no: 'AP-20260525120000-ABCDEFGH',
|
|
|
|
|
expense_type: 'travel_application'
|
|
|
|
|
}),
|
2026-05-26 09:15:14 +08:00
|
|
|
true
|
|
|
|
|
)
|
2026-05-28 12:09:49 +08:00
|
|
|
assert.equal(
|
|
|
|
|
isArchivedExpenseClaim({ status: 'paid', approval_stage: '已付款' }),
|
|
|
|
|
true
|
|
|
|
|
)
|
2026-05-22 16:00:19 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('isArchivedExpenseClaim ignores in-progress claims', () => {
|
|
|
|
|
assert.equal(
|
|
|
|
|
isArchivedExpenseClaim({ status: 'submitted', approval_stage: '财务审批' }),
|
|
|
|
|
false
|
|
|
|
|
)
|
2026-05-28 12:09:49 +08:00
|
|
|
assert.equal(
|
|
|
|
|
isArchivedExpenseClaim({ status: 'pending_payment', approval_stage: '待付款' }),
|
|
|
|
|
false
|
|
|
|
|
)
|
2026-05-22 16:00:19 +08:00
|
|
|
})
|
|
|
|
|
|
2026-05-26 09:15:14 +08:00
|
|
|
test('archive data stays available through api client but archive center is removed from navigation', () => {
|
2026-05-22 16:00:19 +08:00
|
|
|
const navigationScript = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/composables/useNavigation.js', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const reimbursementsService = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/services/reimbursements.js', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-26 09:15:14 +08:00
|
|
|
assert.doesNotMatch(navigationScript, /id:\s*'archive'/)
|
2026-05-22 16:00:19 +08:00
|
|
|
assert.match(reimbursementsService, /\/reimbursements\/claims\/archives/)
|
|
|
|
|
})
|
2026-05-23 19:54:42 +08:00
|
|
|
|
|
|
|
|
test('archive center uses generic archive category and type wording', () => {
|
|
|
|
|
const archiveView = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/views/ArchiveCenterView.vue', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
const archiveScript = readFileSync(
|
|
|
|
|
fileURLToPath(new URL('../src/views/scripts/ArchiveCenterView.js', import.meta.url)),
|
|
|
|
|
'utf8'
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-26 09:15:14 +08:00
|
|
|
assert.match(archiveScript, /const tabs = \[ARCHIVE_TAB_ALL, ARCHIVE_TAB_APPLICATION, ARCHIVE_TAB_REIMBURSEMENT\]/)
|
|
|
|
|
assert.match(archiveScript, /const ARCHIVE_TAB_APPLICATION = '申请归档'/)
|
2026-05-23 19:54:42 +08:00
|
|
|
assert.match(archiveScript, /const ARCHIVE_TAB_REIMBURSEMENT = '报销归档'/)
|
2026-05-26 09:15:14 +08:00
|
|
|
assert.match(archiveScript, /archiveType:\s*isApplicationDocument \? ARCHIVE_TYPE_APPLICATION : ARCHIVE_TYPE_REIMBURSEMENT/)
|
|
|
|
|
assert.match(archiveScript, /archiveTab:\s*isApplicationDocument \? ARCHIVE_TAB_APPLICATION : ARCHIVE_TAB_REIMBURSEMENT/)
|
|
|
|
|
assert.match(archiveScript, /const ARCHIVE_TYPE_REIMBURSEMENT = '报销'/)
|
|
|
|
|
assert.match(archiveScript, /const ARCHIVE_TYPE_APPLICATION = '申请'/)
|
2026-05-23 19:54:42 +08:00
|
|
|
assert.doesNotMatch(archiveScript, /'差旅报销'/)
|
|
|
|
|
assert.doesNotMatch(archiveScript, /'招待报销'/)
|
|
|
|
|
assert.doesNotMatch(archiveScript, /'其他费用'/)
|
|
|
|
|
assert.match(archiveView, /placeholder="搜索单号、申请人、部门、归档类型\.\.\."/)
|
|
|
|
|
assert.match(archiveView, /<th>归档类型<\/th>/)
|
|
|
|
|
assert.match(archiveView, /\{\{\s*row\.archiveType\s*\}\}/)
|
|
|
|
|
assert.doesNotMatch(archiveView, /<th>报销类型<\/th>/)
|
|
|
|
|
})
|