test: honor runtime inbound code policy in HTTP order fixtures

This commit is contained in:
2026-09-15 12:07:43 +08:00
parent 6e35993e61
commit a400563552
2 changed files with 29 additions and 2 deletions
@@ -2,10 +2,24 @@ import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { orderPersistenceFacts, requestedOrderDestinationType } from './orders.mjs'
import { fixtureInboundCode, orderPersistenceFacts, requestedOrderDestinationType } from './orders.mjs'
const source = readFileSync(new URL('orders.mjs', import.meta.url), 'utf8')
test('fresh fixture obeys the authoritative inbound-code policy without changing global settings', () => {
assert.deepEqual(fixtureInboundCode({ mode: 'AUTO', manualEntryRequired: false }, 'batch-A'), {})
const policy = { mode: 'LEGACY_MANUAL', manualEntryRequired: true }
const first = fixtureInboundCode(policy, 'batch-A')
assert.deepEqual(first, fixtureInboundCode(policy, 'batch-A'))
assert.notEqual(first.inboundCode, fixtureInboundCode(policy, 'batch-B').inboundCode)
assert.match(first.inboundCode, /^AT[A-F0-9]{20}$/)
assert.ok(`${first.inboundCode}#9999-9999`.length <= 34)
for (const invalid of [null, {}, { mode: 'AUTO', manualEntryRequired: true }, { mode: 'UNKNOWN', manualEntryRequired: false }]) {
assert.throws(() => fixtureInboundCode(invalid, 'batch-A'), /入仓码策略/)
}
assert.match(source, /GET', `\$\{createPath\}\/inbound-code-policy`/)
})
test('order demo payload covers multi-box multi-SKU images and both destination families', () => {
for (const boxType of ['SMALL', 'MEDIUM', 'LARGE', 'EXTRA_LARGE']) {
assert.match(source, new RegExp(`boxType: '${boxType}'`))