test: isolate pda receipt idempotency keys

This commit is contained in:
2026-08-25 09:27:45 +08:00
parent df4b7a1f6e
commit 46dd0b54eb
2 changed files with 6 additions and 4 deletions
@@ -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/)
@@ -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
}