test(acceptance): verify native outbound ownership and exact relabel carton quantities

This commit is contained in:
2026-10-23 05:21:30 +08:00
parent 18ef338036
commit 2b54e709f8
7 changed files with 148 additions and 20 deletions
@@ -5,7 +5,7 @@ import { mkdtemp, readFile, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve, basename } from 'node:path'
import { DISPATCH_BASE as BASE, dispatchEvidenceContext, dispatchIo } from './grouped-dispatch-acceptance.mjs'
import { run, createClientRelabelDispatch, selectDispatchRouteFixture, dispatchRouteMatches, dispatchBusinessSnapshot, verifyDispatchRouteLifecycle } from './phase4-overseas-dispatch.mjs'
import { run, createClientRelabelDispatch, createPdaRelabelDispatch, selectDispatchRouteFixture, dispatchRouteMatches, dispatchBusinessSnapshot, verifyDispatchRouteLifecycle } from './phase4-overseas-dispatch.mjs'
const clone = value => structuredClone(value)
const rows = () => [1, 2, 3].map(n => ({ selection: { sourceType: 'INBOUND_PLAN', planPalletId: `2${n}`, returnReceiptId: null, relabelNo: null, warehousePalletId: `3${n}`, sourceVersion: `${n}`.repeat(64) },
@@ -119,6 +119,23 @@ test('client original relabel gets its own exact dispatch and refuses repeat exe
assert.equal(h.calls.filter(c => c.method === 'POST').length, writes)
})
test('PDA relabel candidates do not inherit original receiving plan filters and missing sources fail before writes', async () => {
for (const missing of [false, true]) {
const h = server(); addClientRelabel(h)
const fixture = h.context.createdResources.phase4OverseasClientServices.relabelFulfillment
h.context.createdResources.phase4OverseasRelabel = { ...fixture, overseasWarehouseId: fixture.warehouseId }
if (missing) h.candidates.pop()
const proof = {}, io = dispatchIo(h.context, 'test', proof, 'PDA-RELABEL'); io.planIds = ['old-plan']
const original = io.command.bind(io)
io.command = async (method, path, ...args) => {
if (path.includes('/candidates?')) assert.equal(new URL(path, 'https://offline.invalid').searchParams.has('planIds'), false)
return original(method, path, ...args)
}
if (missing) { await assert.rejects(createPdaRelabelDispatch(h.context, io, proof)); assert.equal(h.calls.some(c => c.method === 'POST'), false) }
else { await createPdaRelabelDispatch(h.context, io, proof); assert.equal(h.context.createdResources.phase4OverseasRelabel.dispatchNo, 'DS-1') }
}
})
for (const fault of ['customer', 'pallet', 'missing']) test(`client relabel excludes ${fault} candidates before writes`, async () => {
const h = server(); addClientRelabel(h)
if (fault === 'customer') h.candidates.at(-1).customerId = '99'