Files
baiyue-firstleg/scripts/admin-test-env-modules/phase4-overseas-wallet-and-pallet-cost-contract.test.mjs
T

59 lines
2.9 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { beijingDate, matchesProcurementNo } from './phase4-overseas-wallet-and-pallet-cost.mjs'
const source = readFileSync(new URL('./phase4-overseas-wallet-and-pallet-cost.mjs', import.meta.url), 'utf8')
const entry = readFileSync(new URL('../admin-test-env-acceptance.mjs', import.meta.url), 'utf8')
const pda = readFileSync(new URL('./phase4-overseas-pda.mjs', import.meta.url), 'utf8')
test('采购单号按北京时间日期执行精确合同', () => {
const instant = new Date('2026-09-05T16:30:00.000Z')
assert.equal(beijingDate(instant), '20260906')
assert.equal(matchesProcurementNo('QLYSXDKH202609060001', 'QLYSXDKH', instant), true)
assert.equal(matchesProcurementNo('QLYSXDKH202609050001', 'QLYSXDKH', instant), false)
assert.equal(matchesProcurementNo('QLYSXDKH20260906001', 'QLYSXDKH', instant), false)
})
test('钱包闭环覆盖充值、授信、采购冻结结算和换标结算释放', () => {
for (const token of [
'/accounts/${encodeURIComponent(customerId)}/credit-limit',
'/accounts/${encodeURIComponent(customerId)}/adjustments',
"const CLIENT_FINANCE = '/api/client/finance/v1'",
"['VOUCHER', 'RECEIPT']",
"walletStatus === 'FROZEN'",
"walletStatus === 'SETTLED'",
"'RELEASED'",
"terminalStatus === 'COMPLETED'",
"'CANCELLED'",
'relabelPayload(context, warehouseId, suffix, 0.01)',
]) assert.ok(source.includes(token), token)
assert.match(source, /actualBalance[\s\S]*frozenBalance[\s\S]*availableBalance[\s\S]*creditLimit[\s\S]*creditUsed[\s\S]*availableCredit/)
assert.doesNotMatch(source, /internal\/finance|jdbc|mysql|process\.env|https?:\/\//i)
})
test('托盘汇总和拆柜成本验证总数、分摊及跨区金额守恒', () => {
for (const token of [
'/api/platform/v1/pallets/summary',
'/api/platform/v1/warehouse-admin/pallets/summary',
'/pallets/summary?page=1&size=20',
'CONTAINER_DESTUFFING',
'DESTUFF_PALLET',
'expectedPalletCost',
'sourceFeeId',
'pollRequests=',
]) assert.ok(source.includes(token), token)
assert.match(source, /Number\(d\.totalCount\) === Number\(d\.idleCount\) \+ Number\(d\.occupiedCount\)/)
assert.match(source, /allocated === money\(fact\.expectedPalletCost\)/)
assert.match(source, /delivered\.reduce[\s\S]*fact\.expectedPalletCost/)
assert.match(pda, /unitPrice = Number\(\(1\.01 \+ index\)\.toFixed\(2\)\)/)
assert.match(pda, /completedContainerFacts\.push/)
})
test('模块进入默认全量并绑定真实商户和海外PDA生产链', () => {
assert.match(entry, /CONFIGURED_MODULES[^\n]*'phase4-overseas-wallet-and-pallet-cost'/)
assert.match(entry, /\['phase4-overseas-wallet-and-pallet-cost', \['phase4-overseas-business', 'phase4-overseas-pda-operations'\]\]/)
assert.match(source, /OPTIONS = \{ scenario: SCENARIO, deploymentBlocker: true \}/)
assert.match(source, /completedFacts\.length > 0/)
})