test: cover overseas pda warehouse operation lifecycles
This commit is contained in:
@@ -50,7 +50,15 @@ async function captureCompletedOrder(context, containerNo, expectedCustomerId) {
|
||||
if (mapped) {
|
||||
context.createdResources.phase4OverseasPda.orderId = id(order.id)
|
||||
context.createdResources.phase4OverseasPda.customerId = id(order.customerId)
|
||||
const detailPath = `/api/platform/v1/last-leg/orders/${encodeURIComponent(id(order.id))}?customerId=${encodeURIComponent(id(order.customerId))}`
|
||||
const detail = await context.requestOverseas('GET', detailPath)
|
||||
context.assert(MODULE, '完成柜回查尾程订单货物明细供后续PDA作业', detail,
|
||||
success(detail) && id(detail.body?.data?.order?.id) === id(order.id)
|
||||
&& Array.isArray(detail.body?.data?.cargo) && detail.body.data.cargo.length > 0,
|
||||
`orderId=${id(order.id)}, cargo=${detail.body?.data?.cargo?.length ?? 'missing'}; ${trace(detail)}`, OPTIONS)
|
||||
return success(detail) ? detail.body?.data : null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function loginMerchantForNegativeProbe(context) {
|
||||
@@ -172,6 +180,9 @@ async function verifyWarehouseQueries(context, token, inboundCode, pallet) {
|
||||
&& historyRows.some((item) => String(item?.operationType || '').startsWith('RECEIVING_'))
|
||||
&& Number(history.data?.page) === 1 && Number(history.data?.size) === 50,
|
||||
`records=${historyRows.length}; ${trace(history.response)}`, OPTIONS)
|
||||
return success(inventory.response) && success(location.response) && success(resolvedPallet.response)
|
||||
? { inboundCode, pallet: resolvedPallet.data, location: location.data, inventory: inventory.data?.items || [] }
|
||||
: null
|
||||
}
|
||||
|
||||
async function uploadPhotos(context, token) {
|
||||
@@ -432,10 +443,15 @@ async function runReceiving(context, token, secondaryToken, merchantToken, prefe
|
||||
context.addStep(MODULE, '完成后current返回404正常空态', after, notFound(after), trace(after), OPTIONS)
|
||||
context.createdResources.phase4OverseasPda.finalStatus = completed.data?.status || null
|
||||
if (context.createdResources.phase4OverseasPda.finalStatus === 'COMPLETED') {
|
||||
await captureCompletedOrder(context, containerNo, preferredProducer?.tenantId)
|
||||
const firstInbound = current.data.inbounds.find((item) => pallets.has(item.inboundCode))
|
||||
if (firstInbound) {
|
||||
await verifyWarehouseQueries(context, token, firstInbound.inboundCode, pallets.get(firstInbound.inboundCode))
|
||||
const order = await captureCompletedOrder(context, containerNo, preferredProducer?.tenantId)
|
||||
for (const inbound of current.data.inbounds.filter((item) => pallets.has(item.inboundCode))) {
|
||||
const warehouseFacts = await verifyWarehouseQueries(context, token, inbound.inboundCode,
|
||||
pallets.get(inbound.inboundCode))
|
||||
if (warehouseFacts && context.context?.phase4OverseasPdaOperations) {
|
||||
context.context.phase4OverseasPdaOperations.completedFixtures.push({
|
||||
containerNo, order, ...warehouseFacts,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,6 +478,19 @@ export async function run(context) {
|
||||
for (const picker of [primary, secondary]) if (picker?.membershipId) {
|
||||
context.createdResources.phase4OverseasPda.pickerMembershipIds.push(picker.membershipId)
|
||||
}
|
||||
let handoffReady = false
|
||||
const cleanup = async () => {
|
||||
await disablePicker(context, secondary, 2)
|
||||
await disablePicker(context, primary, 1)
|
||||
}
|
||||
context.context.phase4OverseasPdaOperations = {
|
||||
marker: context.marker,
|
||||
primary: primary ? { membershipId: primary.membershipId, username: primary.username, token: primary.token } : null,
|
||||
secondary: secondary ? { membershipId: secondary.membershipId, username: secondary.username, token: secondary.token } : null,
|
||||
overseasWarehouseId: sharedWarehouse.id,
|
||||
completedFixtures: [],
|
||||
cleanup,
|
||||
}
|
||||
try {
|
||||
if (!primary?.token || !secondary?.token) {
|
||||
blockerGap(context, '海外PDA双操作员账号', '未能创建并登录两个WAREHOUSE_PICKER平台账号,无法验证全局一柜锁')
|
||||
@@ -486,10 +515,13 @@ export async function run(context) {
|
||||
context.createdResources.phase4OverseasPda.completedContainers.push(producer?.containerNo || null)
|
||||
}
|
||||
}
|
||||
handoffReady = context.context.phase4OverseasPdaOperations.completedFixtures.length > 0
|
||||
} finally {
|
||||
delete context.pdaContainerSuffix
|
||||
await disablePicker(context, secondary, 2)
|
||||
await disablePicker(context, primary, 1)
|
||||
if (!handoffReady) {
|
||||
try { await cleanup() }
|
||||
finally { delete context.context.phase4OverseasPdaOperations }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user