Files
baiyue-firstleg/scripts/admin-test-env-modules/inbound-hold-contract.test.mjs
T

29 lines
1.5 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { test } from 'node:test'
const entry = readFileSync(new URL('../admin-test-env-acceptance.mjs', import.meta.url), 'utf8')
const source = readFileSync(new URL('./inbound-hold.mjs', import.meta.url), 'utf8')
test('入库扣货真实 HTTP 模块进入默认全量并依赖订单造数', () => {
assert.match(entry, /CONFIGURED_MODULES\s*=\s*\[[^\n]*['"]orders['"][^\n]*['"]inbound-hold['"]/)
assert.match(entry, /\[['"]inbound-hold['"],\s*\[['"]orders['"]\]\]/)
})
test('入库扣货模块覆盖隔离、幂等、冲突、候选门禁和统一订单投影', () => {
assert.match(source, /错误客户不能读取扣货快照/)
assert.match(source, /扣货请求同键同载荷重放/)
assert.match(source, /扣货同键异载荷返回A0409/)
assert.match(source, /扣货入库单从智能装柜候选排除/)
assert.match(source, /解除后入库单恢复智能装柜候选/)
assert.match(source, /summary\?\.holdFlag/)
assert.match(source, /summary\?\.currentHoldReason/)
assert.doesNotMatch(source, /\.holdCargo\b|\.holdReason\b|\bholdCargo\s*:|\bholdReason\s*:/)
})
test('入库扣货写操作统一使用请求头 Idempotency-Key 和 expectedVersion', () => {
assert.match(source, /context\.request\('POST', path, body, context\.token, \{ 'Idempotency-Key': key \}\)/)
assert.match(source, /expectedVersion: initialVersion/)
assert.match(source, /expectedVersion: heldVersion/)
})