test: verify virtual receiving location rejects pallet restore

This commit is contained in:
2026-09-29 15:02:15 +08:00
parent cb8e5fb145
commit 60f61d7e0a
@@ -110,7 +110,8 @@ async function resolvePublicLocation(context, fixture, sourceLocationCode) {
success(response) && longId(id(location?.id)) && nonBlank(location?.locationCode),
`locationId=${id(location?.id) || 'missing'}, locationCode=${location?.locationCode || 'missing'}; ${trace(response)}`, OPTIONS)
return success(response) && location
? { locationId: id(location.id), locationCode: location.locationCode } : null
? { locationId: id(location.id), locationCode: location.locationCode,
sourceLocationType: locations.find((item) => item.locationCode === sourceLocationCode)?.locationType } : null
}
export function remainingRelabelItem(detail, usedItemIds) {
@@ -222,7 +223,8 @@ async function verifyInventoryMove(context, token, fixture) {
await expectConflict(context, token, 'POST', 'P3移库同键异载荷A0409', path,
{ ...body, reason: `${body.reason}-DIFFERENT` })
await expectConflict(context, token, 'POST', 'P3移库旧托盘版本A0409', path, {
...body, targetLocationCode: originalLocationCode, idempotencyKey: key(context, 'MOVE-STALE'),
...body, expectedPalletVersion: Math.max(0, body.expectedPalletVersion - 1),
idempotencyKey: key(context, 'MOVE-STALE'),
})
pallet = (await resolvePallet(context, token, pallet.palletCode, 'P3回查托盘已位于目标库位')).data
context.assert(MODULE, 'P3托盘与库存位置同步到目标库位', moved.response,
@@ -231,6 +233,15 @@ async function verifyInventoryMove(context, token, fixture) {
const restoreBody = { sourcePalletCode: pallet.palletCode, targetLocationCode: originalLocationCode,
expectedPalletVersion: Number(pallet.palletVersion), idempotencyKey: key(context, 'MOVE-RESTORE'),
reason: `${context.marker}-move-restore` }
if (target.sourceLocationType === 'VIRTUAL') {
const rejected = await expectConflict(context, token, 'POST', 'P3禁止回移到虚拟收货位', path, restoreBody)
const retained = (await resolvePallet(context, token, pallet.palletCode, 'P3拒绝回移后仍在上架库位')).data
context.assert(MODULE, 'P3虚拟位回移失败不改变托盘和库存', rejected,
conflict(rejected) && retained?.locationCode === target.locationCode
&& Number(retained?.palletVersion) === Number(pallet.palletVersion)
&& Number(retained?.totalPackages) === Number(pallet.totalPackages), trace(rejected), OPTIONS)
return conflict(rejected) && retained?.locationCode === target.locationCode
}
const restored = await request(context, token, 'POST', 'P3整托移回原库位供后续验证', path, restoreBody)
return success(restored.response) && restored.data?.targetLocationCode === originalLocationCode
}