test: await PDA projection and pending receipts

This commit is contained in:
2026-08-25 17:25:38 +08:00
parent 4e8c15dbfa
commit 25cb3bfa54
2 changed files with 23 additions and 2 deletions
@@ -35,9 +35,14 @@ test('PDA module covers the container-number receiving contract and excludes out
assert.match(source, /第二仓库操作员抢占同柜返回409/)
assert.match(source, /WAREHOUSE_PICKER/)
assert.match(source, /lastleg:pda:operate/)
assert.match(source, /安全投影已收敛/)
assert.match(source, /projectionReady = success\(projectionResponse\) \|\| notFound\(projectionResponse\)/)
assert.match(source, /setTimeout\(resolve, 500\)/)
assert.match(source, /超收被拒绝/)
assert.match(source, /重复箱新键被拒绝/)
assert.match(source, /key\(context, `fba-bulk-\$\{index\}`\)/)
assert.match(source, /packageCount = Number\(resolved\.data\?\.pendingPackages \|\| 0\)/)
assert.match(source, /if \(packageCount <= 0\) continue/)
assert.match(source, /key\(context, `overseas-carton-\$\{index\}`\)/)
assert.match(source, /模式硬拒绝/)
assert.match(source, /current返回404正常空态/)
@@ -111,7 +111,21 @@ async function createPicker(context, index, overseasWarehouseId, access) {
const token = success(login) ? login.body?.data?.overseasAccessToken : null
context.addStep(MODULE, `海外PDA操作员${index}登录取得双区域海外令牌`, login, nonBlank(token),
`overseasTokenPresent=${nonBlank(token)}; ${trace(login)}`, OPTIONS)
return { membershipId, username, token: nonBlank(token) ? token : null }
if (!nonBlank(token)) return { membershipId, username, token: null }
let projectionResponse = null
let projectionReady = false
let projectionAttempt = 0
for (; projectionAttempt < 30; projectionAttempt += 1) {
projectionResponse = await context.requestOverseas('GET',
'/api/pda/v1/last-leg/receiving-containers/current', undefined, {}, token)
projectionReady = success(projectionResponse) || notFound(projectionResponse)
if (projectionReady || !forbidden(projectionResponse)) break
await new Promise((resolve) => setTimeout(resolve, 500))
}
context.addStep(MODULE, `海外PDA操作员${index}安全投影已收敛`, projectionResponse, projectionReady,
`attempts=${projectionAttempt + 1}; ${trace(projectionResponse)}`, OPTIONS)
return { membershipId, username, token: projectionReady ? token : null }
}
async function disablePicker(context, picker, index) {
@@ -294,13 +308,15 @@ async function receiveFba(context, token, inbound, pallet, producer) {
}
let accepted = 0
for (const [index, sku] of skus.entries()) {
const { skuCode, packageCount } = sku
const { skuCode } = sku
const resolvedResponse = await context.requestOverseas('POST',
'/api/pda/v1/last-leg/receiving-containers/current/skus/resolve', { skuCode }, {}, token)
const resolvable = success(resolvedResponse) || notFound(resolvedResponse)
context.addStep(MODULE, `解析FBA SKU候选 ${index + 1}`, resolvedResponse, resolvable, trace(resolvedResponse), OPTIONS)
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 packageCount = Number(resolved.data?.pendingPackages || 0)
if (packageCount <= 0) continue
const body = { inboundCode: inbound.inboundCode, skuCode, palletCode: pallet.palletCode,
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)