From 096ab8d48b8c3d93c9bee9877c52df697d10c4c5 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 8 Sep 2026 12:45:46 +0800 Subject: [PATCH] fix(test): align receiving pallets with FBA destinations --- ...-overseas-pda-operations-contract.test.mjs | 12 +++++++++- .../phase4-overseas-pda-operations.mjs | 23 +++++++++++++++---- .../phase4-overseas-pda.mjs | 4 +++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda-operations-contract.test.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda-operations-contract.test.mjs index 28fb043bb..1a741c306 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-pda-operations-contract.test.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-pda-operations-contract.test.mjs @@ -5,7 +5,7 @@ import test from 'node:test' import { fileURLToPath } from 'node:url' import { normalizeModuleOrder } from '../admin-test-env-acceptance.mjs' -import { run } from './phase4-overseas-pda-operations.mjs' +import { auxiliaryPalletFbaWarehouseCode, run } from './phase4-overseas-pda-operations.mjs' const here = path.dirname(fileURLToPath(import.meta.url)) const source = fs.readFileSync(path.join(here, 'phase4-overseas-pda-operations.mjs'), 'utf8') @@ -58,6 +58,16 @@ test('P2 to P5 cover all frozen endpoints, replays and conflict boundaries witho assert.match(source, /traceId=/) }) +test('auxiliary pallets use the authoritative inbound FBA code and never the business destination fallback', () => { + assert.equal(auxiliaryPalletFbaWarehouseCode('FBA', ' ABE3 '), 'ABE3') + assert.equal(auxiliaryPalletFbaWarehouseCode('OVERSEAS', 'ABE3'), null) + assert.equal(auxiliaryPalletFbaWarehouseCode('FBA', ''), null) + assert.match(receivingSource, + /destinationType: inbound\.destinationType,[\s\S]*fbaWarehouseCode: inbound\.destinationType === 'FBA' \? inbound\.fbaWarehouseCode : null/) + assert.match(source, /fbaWarehouseCode,\s*\n\s*remark:/) + assert.doesNotMatch(source, /createEmptyPallet\([^\n]*main\.destinationWarehouseCode/) +}) + test('fixture failure still disables both picker accounts and removes all transient tokens', async () => { const cleanups = [] const gaps = [] diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda-operations.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda-operations.mjs index 3a173ffd3..272642a7e 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-pda-operations.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-pda-operations.mjs @@ -95,13 +95,26 @@ async function createLocation(context, warehouseId, suffix) { return success(response) ? { locationId, locationCode } : null } -async function createEmptyPallet(context, token, fixture, suffix, destinationWarehouseCode) { +export function auxiliaryPalletFbaWarehouseCode(destinationType, fbaWarehouseCode) { + if (destinationType === 'OVERSEAS') return null + if (destinationType === 'FBA' && nonBlank(fbaWarehouseCode)) return fbaWarehouseCode.trim() + return null +} + +async function createEmptyPallet(context, token, fixture, suffix) { + const fbaWarehouseCode = auxiliaryPalletFbaWarehouseCode( + fixture.destinationType, fixture.fbaWarehouseCode) + if (fixture.destinationType === 'FBA' && !fbaWarehouseCode) { + blocker(context, `${suffix}辅助空托盘`, + `当前FBA入仓码 ${fixture.inboundCode || 'missing'} 缺少权威fbaWarehouseCode`) + return null + } const palletCode = `PDAOPS-${context.marker}-${suffix}`.replace(/[^A-Za-z0-9_-]/g, '').slice(-120) const response = await context.requestOverseas('POST', `/api/platform/v1/warehouse-admin/${encodeURIComponent(fixture.overseasWarehouseId)}/pallets`, { palletCode, palletType: '木托盘', capacityCbm: 10, unitPrice: 0, status: 'IDLE', locationId: fixture.location.locationId, - fbaWarehouseCode: destinationWarehouseCode || null, + fbaWarehouseCode, remark: `${context.marker}-pda-operations-${suffix}`, }) context.addStep(MODULE, `创建${suffix}辅助空托盘`, response, success(response), trace(response), OPTIONS) @@ -234,9 +247,9 @@ async function verifyPalletOperations(context, token, fixture) { '主托盘只有一箱可用库存,解绑会清空唯一业务托盘;必须由本轮生产矩阵提供至少两箱') return false } - const swapTarget = await createEmptyPallet(context, token, fixture, 'SWAP', main.destinationWarehouseCode) - const splitTarget = await createEmptyPallet(context, token, fixture, 'SPLIT', main.destinationWarehouseCode) - const unbindTarget = await createEmptyPallet(context, token, fixture, 'UNBIND', main.destinationWarehouseCode) + const swapTarget = await createEmptyPallet(context, token, fixture, 'SWAP') + const splitTarget = await createEmptyPallet(context, token, fixture, 'SPLIT') + const unbindTarget = await createEmptyPallet(context, token, fixture, 'UNBIND') if (!swapTarget || !splitTarget || !unbindTarget) { blocker(context, 'P4辅助实物托盘', '无法创建换托、拆托和解绑所需辅助托盘') return false diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda.mjs index cb6b1c6b8..ee1b299f6 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-pda.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-pda.mjs @@ -669,7 +669,9 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe pallets.get(inbound.inboundCode), inbound.destinationType) if (warehouseFacts && context.context?.phase4OverseasPdaOperations) { context.context.phase4OverseasPdaOperations.completedFixtures.push({ - containerNo, order, ...warehouseFacts, + containerNo, order, destinationType: inbound.destinationType, + fbaWarehouseCode: inbound.destinationType === 'FBA' ? inbound.fbaWarehouseCode : null, + ...warehouseFacts, }) } }