From 46dd0b54eb146b8120052666bd9624b2a1a696bf Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 25 Aug 2026 09:27:45 +0800 Subject: [PATCH] test: isolate pda receipt idempotency keys --- .../phase4-overseas-pda-contract.test.mjs | 2 ++ scripts/admin-test-env-modules/phase4-overseas-pda.mjs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda-contract.test.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda-contract.test.mjs index 45e5a374e..87c2addb0 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-pda-contract.test.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-pda-contract.test.mjs @@ -34,6 +34,8 @@ test('PDA module covers the container-number receiving contract and excludes out assert.match(source, /lastleg:pda:operate/) assert.match(source, /超收被拒绝/) assert.match(source, /重复箱新键被拒绝/) + assert.match(source, /key\(context, `fba-bulk-\$\{index\}`\)/) + assert.match(source, /key\(context, `overseas-carton-\$\{index\}`\)/) assert.match(source, /模式硬拒绝/) assert.match(source, /current返回404正常空态/) assert.match(source, /安全扫描返回A0400/) diff --git a/scripts/admin-test-env-modules/phase4-overseas-pda.mjs b/scripts/admin-test-env-modules/phase4-overseas-pda.mjs index 011a96b26..9a57ec520 100644 --- a/scripts/admin-test-env-modules/phase4-overseas-pda.mjs +++ b/scripts/admin-test-env-modules/phase4-overseas-pda.mjs @@ -212,7 +212,7 @@ async function receiveFba(context, token, inbound, pallet, producer) { const resolved = { response: resolvedResponse, data: success(resolvedResponse) ? resolvedResponse.body?.data : null } if (!success(resolved.response) || resolved.data?.inboundCode !== inbound.inboundCode || resolved.data?.destinationType !== 'FBA') continue const body = { inboundCode: inbound.inboundCode, skuCode, palletCode: pallet.palletCode, - packageCount, idempotencyKey: key(context, 'fba-bulk', skuCode) } + packageCount, idempotencyKey: key(context, `fba-bulk-${index}`) } const first = await pda(context, token, 'POST', `FBA SKU ${skuCode}按箱数实收`, '/api/pda/v1/last-leg/receiving-containers/current/receipts/bulk', body) if (!success(first.response)) return false accepted += Number(first.data?.acceptedPackages || 0) @@ -222,7 +222,7 @@ async function receiveFba(context, token, inbound, pallet, producer) { await expected(context, token, 'POST', `FBA SKU ${skuCode}同键异载荷冲突`, '/api/pda/v1/last-leg/receiving-containers/current/receipts/bulk', { ...body, packageCount: packageCount + 1 }, conflict) await expected(context, token, 'POST', `FBA SKU ${skuCode}超收被拒绝`, '/api/pda/v1/last-leg/receiving-containers/current/receipts/bulk', - { ...body, packageCount: Number(inbound.totalPackages) + 1, idempotencyKey: key(context, 'fba-over', skuCode) }, conflict) + { ...body, packageCount: Number(inbound.totalPackages) + 1, idempotencyKey: key(context, `fba-over-${index}`) }, conflict) } if (accepted <= 0) { blockerGap(context, `FBA入仓码${inbound.inboundCode}实收`, `候选 SKU 均未唯一解析到当前入仓码;skuCount=${skus.length}`) @@ -250,7 +250,7 @@ async function receiveOverseas(context, token, inbounds, pallets, producerCarton return false } const body = { cartonMark, palletCode: pallet.palletCode, - idempotencyKey: key(context, 'overseas-carton', cartonMark) } + idempotencyKey: key(context, `overseas-carton-${index}`) } const first = await pda(context, token, 'POST', `OVERSEAS逐箱实收${index + 1}`, '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', body) if (!success(first.response)) return false @@ -263,7 +263,7 @@ async function receiveOverseas(context, token, inbounds, pallets, producerCarton { ...body, palletCode: `${pallet.palletCode}-MUTATED` }, conflict) await expected(context, token, 'POST', `OVERSEAS重复箱新键被拒绝${index + 1}`, '/api/pda/v1/last-leg/receiving-containers/current/receipts/carton', - { ...body, idempotencyKey: key(context, 'overseas-duplicate', cartonMark) }, conflict) + { ...body, idempotencyKey: key(context, `overseas-duplicate-${index}`) }, conflict) } return true }