fix: validate transfer rejection and align dispatch HTTP contracts

This commit is contained in:
2026-09-14 13:46:32 +08:00
parent a2ea0ba9e6
commit d8e2dc59ae
9 changed files with 120 additions and 13 deletions
@@ -1,4 +1,5 @@
import test from 'node:test'
import { relabelOutboundMarksMatch } from './phase5-overseas-fulfillment.mjs'
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
@@ -84,3 +85,14 @@ test('phase-five writes carry idempotency and record deployment blockers instead
assert.match(source, /addCoverageGap\(MODULE, SCENARIO/)
assert.match(source, /deploymentBlocker: true/)
})
test('relabel marks are checked on the authoritative outbound DTO without weakening identity checks', () => {
const relabel = { relabelCartonMarks: ['NEW-1', 'NEW-2'], sourceCartonMarks: ['OLD-1', 'OLD-2'] }
const detail = { outbound: { packageCount: 2 }, pallets: [{ cartonMarks: 'NEW-1,NEW-2' }] }
assert.equal(relabelOutboundMarksMatch(detail, relabel), true)
for (const cartonMarks of ['', 'NEW-1', 'NEW-1,NEW-1', 'NEW-1,OLD-2', 'NEW-1,NEW-2,OTHER']) {
assert.equal(relabelOutboundMarksMatch({ ...detail, pallets: [{ cartonMarks }] }, relabel), false)
}
assert.equal(relabelOutboundMarksMatch({ ...detail, outbound: { packageCount: 3 } }, relabel), false)
assert.match(source, /detail\.data\?\.outbound\?\.dispatchNo === relabel\.dispatchNo/)
assert.match(source, /relabel\?\.marker !== context\.marker/)
})