73 lines
3.8 KiB
JavaScript
73 lines
3.8 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
const source = fs.readFileSync(path.join(here, 'finance-demo-fixtures.mjs'), 'utf8')
|
|
|
|
test('演示数据只消费本轮固定 marker 和客户 10001', () => {
|
|
assert.match(source, /const MARKER = 'FIN-DEMO-20260812'/)
|
|
assert.match(source, /fixture\.marker !== runMarker/)
|
|
assert.match(source, /fixture\.customerId !== '10001'/)
|
|
assert.match(source, /const runMarker = `\$\{MARKER\}-/)
|
|
assert.match(source, /禁止借历史来源/)
|
|
assert.doesNotMatch(source, /DELETE|cleanup|remove/i)
|
|
})
|
|
|
|
test('覆盖费用、对账单、AR 和 AP 页面分层状态', () => {
|
|
for (const value of ['pendingReview', 'approvedUnbilled', 'draft', 'arUnpaid', 'arPartial', 'arPaid',
|
|
'apUnpaid', 'apPartial', 'apPaid']) assert.match(source, new RegExp(value))
|
|
for (const status of ['DRAFT', 'PENDING_REVIEW', 'ISSUED']) assert.match(source, new RegExp(`'${status}'`))
|
|
assert.match(source, /reviewStatus === 'PENDING'/)
|
|
assert.match(source, /reviewStatus === 'APPROVED'/)
|
|
assert.doesNotMatch(source, /settlementIncluded|settlement-inclusion/)
|
|
})
|
|
|
|
test('平台列表默认全量查询不带 customerId,未部署时登记 blocker', () => {
|
|
assert.match(source, /\['statements', 'receivable-settlements', 'payable-settlements', 'receipts', 'cost-entries'\]/)
|
|
assert.match(source, /context\.request\('GET', `\$\{BASE\}\/\$\{path\}`\)/)
|
|
assert.match(source, /finance-unfiltered-list-not-deployed/)
|
|
})
|
|
|
|
test('所有财务写操作使用 marker 幂等键并上传真实凭证', () => {
|
|
assert.match(source, /'Idempotency-Key': key\(context, operation\)/)
|
|
assert.match(source, /fixture\.voucherFileId/)
|
|
assert.match(source, /finance-full-fixtures\.mjs/)
|
|
assert.match(source, /context\.createdResources\.financeDemo = matrix/)
|
|
assert.match(source, /`source-\$\{role\}-\$\{source\.feeSourceId\}-submit`/)
|
|
assert.match(source, /`ap-\$\{role\}-\$\{source\.feeSourceId\}-\$\{source\.supplierId\}-create`/)
|
|
})
|
|
|
|
test('额外应付审核路径先追加 feeId 再追加 accountId 查询参数', () => {
|
|
assert.match(source, /`\$\{basePath\}\/\$\{created\.id\}\/approve\?accountId=10001`/)
|
|
assert.doesNotMatch(source, /fee-details\?accountId=10001\/\$\{created\.id\}/)
|
|
})
|
|
|
|
test('费用来源使用 operationVersion,应付供应商长整型保持字符串精度', () => {
|
|
assert.match(source, /expectedVersion: operationVersion\(current\.value\)/)
|
|
assert.match(source, /supplierId: id\(source\.supplierId\)/)
|
|
assert.doesNotMatch(source, /supplierId: Number\(source\.supplierId\)/)
|
|
assert.match(source, /supplierId, remark:/)
|
|
assert.doesNotMatch(source, /partnerId|partnerName/)
|
|
})
|
|
|
|
test('恢复模式只续补固定报告来源并校验 AR AP 金额状态', () => {
|
|
assert.match(source, /process\.env\.FINANCE_DEMO_RECOVERY_REPORT/)
|
|
assert.match(source, /恢复报告不是 FIN-DEMO-20260812/)
|
|
assert.match(source, /拒绝借历史数据/)
|
|
assert.match(source, /const recoverySupplierId = role === 'apPartial'/)
|
|
assert.match(source, /matrix\.payableSettlements\?\.apPaid\?\.supplierId/)
|
|
assert.match(source, /process\.env\.FINANCE_DEMO_AP_UNPAID_ID/)
|
|
assert.match(source, /process\.env\.FINANCE_DEMO_AP_PARTIAL_ID/)
|
|
assert.match(source, /const payableIds = \['307', '310'\]/)
|
|
assert.match(source, /finance-container-partner-not-deployed/)
|
|
assert.match(source, /recoverPayable/)
|
|
assert.match(source, /const existing = await recoverPayable/)
|
|
assert.match(source, /finance-settlement-payment-status-not-deployed/)
|
|
assert.match(source, /\['arUnpaid', 'UNPAID'\]/)
|
|
assert.match(source, /\['arPartial', 'PARTIALLY_PAID'\]/)
|
|
assert.match(source, /\['arPaid', 'PAID'\]/)
|
|
})
|