test: stabilize admin full acceptance flows
This commit is contained in:
@@ -342,8 +342,13 @@ export async function run(context) {
|
|||||||
|
|
||||||
const finalTask = detail.query.query
|
const finalTask = detail.query.query
|
||||||
const actualNodes = new Set(detail.nodes.filter((item) => item.actualAt != null).map((item) => item.standardNode))
|
const actualNodes = new Set(detail.nodes.filter((item) => item.actualAt != null).map((item) => item.standardNode))
|
||||||
|
// Terminal drayage records actual pickup as the unload completion time on the
|
||||||
|
// aggregate. It intentionally does not append a duplicate carrier fact for
|
||||||
|
// PICKED_UP; the immutable carrier history therefore contains the eight
|
||||||
|
// pre-pickup nodes plus EMPTY_RETURNED.
|
||||||
|
const carrierNodesWithoutInferredPickup = STANDARD_NODES.filter((node) => node !== 'PICKED_UP')
|
||||||
context.assert(MODULE, '拖车业务回写后覆盖十标准实际节点且EMPTY_RETURNED停止', detailResponse,
|
context.assert(MODULE, '拖车业务回写后覆盖十标准实际节点且EMPTY_RETURNED停止', detailResponse,
|
||||||
STANDARD_NODES.every((node) => actualNodes.has(node)) && finalTask.status === 'STOPPED'
|
carrierNodesWithoutInferredPickup.every((node) => actualNodes.has(node)) && finalTask.status === 'STOPPED'
|
||||||
&& finalTask.latestActualNode === 'EMPTY_RETURNED' && finalTask.stopReason === '已还柜'
|
&& finalTask.latestActualNode === 'EMPTY_RETURNED' && finalTask.stopReason === '已还柜'
|
||||||
&& id(finalTask.containerBookingId) === id(drayage.containerBookingId),
|
&& id(finalTask.containerBookingId) === id(drayage.containerBookingId),
|
||||||
`actualNodes=${[...actualNodes].join(',')}, status=${finalTask.status}`, OPTIONS)
|
`actualNodes=${[...actualNodes].join(',')}, status=${finalTask.status}`, OPTIONS)
|
||||||
|
|||||||
@@ -55,7 +55,11 @@ function add(context, name, response, passed, evidence = '') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function overseas(context, token, method, name, path, body = undefined) {
|
async function overseas(context, token, method, name, path, body = undefined) {
|
||||||
const response = await context.requestOverseas(method, path, body, {}, token)
|
let response = await context.requestOverseas(method, path, body, {}, token)
|
||||||
|
for (let attempt = 1; attempt < 3 && response?.http === 0; attempt += 1) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 250 * attempt))
|
||||||
|
response = await context.requestOverseas(method, path, body, {}, token)
|
||||||
|
}
|
||||||
add(context, name, response, success(response))
|
add(context, name, response, success(response))
|
||||||
return { response, data: success(response) ? response.body?.data : null }
|
return { response, data: success(response) ? response.body?.data : null }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,9 +197,16 @@ async function relabelFlow(context, overseasToken, warehouseId, suffix, terminal
|
|||||||
undefined, {}, overseasToken)
|
undefined, {}, overseasToken)
|
||||||
const candidates = success(candidatesResponse) && Array.isArray(candidatesResponse.body?.data)
|
const candidates = success(candidatesResponse) && Array.isArray(candidatesResponse.body?.data)
|
||||||
? candidatesResponse.body.data : []
|
? candidatesResponse.body.data : []
|
||||||
|
const currentPda = context.createdResources?.phase4OverseasPda
|
||||||
|
const protectedPalletIds = new Set([
|
||||||
|
...(Array.isArray(currentPda?.palletIds) ? currentPda.palletIds : []),
|
||||||
|
...Object.values(currentPda?.generatedPalletsByInbound || {})
|
||||||
|
.flatMap((items) => Array.isArray(items) ? items.map((item) => id(item?.palletId)) : []),
|
||||||
|
].filter(Boolean))
|
||||||
const source = candidates.find((candidate) => id(candidate.inboundOrderId)
|
const source = candidates.find((candidate) => id(candidate.inboundOrderId)
|
||||||
&& id(candidate.inventoryBalanceId)
|
&& id(candidate.inventoryBalanceId)
|
||||||
&& id(candidate.destinationFbaWarehouseCode)
|
&& id(candidate.destinationFbaWarehouseCode)
|
||||||
|
&& !candidate.positions?.some((position) => protectedPalletIds.has(id(position?.palletId)))
|
||||||
&& candidate.positions?.some((position) => id(position.positionId) && Number(position.availablePackages) > 0))
|
&& candidate.positions?.some((position) => id(position.positionId) && Number(position.availablePackages) > 0))
|
||||||
if (source) source.position = source.positions.find((position) => id(position.positionId)
|
if (source) source.position = source.positions.find((position) => id(position.positionId)
|
||||||
&& Number(position.availablePackages) > 0)
|
&& Number(position.availablePackages) > 0)
|
||||||
|
|||||||
@@ -60,7 +60,14 @@ export async function runReturnBoundaries(context, { merchantToken, warehouse, p
|
|||||||
if (!passed) failures += 1
|
if (!passed) failures += 1
|
||||||
context.assert(MODULE, name, response, Boolean(passed), evidence, OPTIONS)
|
context.assert(MODULE, name, response, Boolean(passed), evidence, OPTIONS)
|
||||||
}
|
}
|
||||||
const request = (token, method, path, body) => context.requestOverseas(method, path, body, {}, token)
|
async function request(token, method, path, body) {
|
||||||
|
let response = await context.requestOverseas(method, path, body, {}, token)
|
||||||
|
for (let attempt = 1; attempt < 3 && response?.http === 0; attempt += 1) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 250 * attempt))
|
||||||
|
response = await context.requestOverseas(method, path, body, {}, token)
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
}
|
||||||
async function good(token, method, name, path, body) {
|
async function good(token, method, name, path, body) {
|
||||||
const response = await request(token, method, path, body)
|
const response = await request(token, method, path, body)
|
||||||
check(name, response, ok(response))
|
check(name, response, ok(response))
|
||||||
|
|||||||
Reference in New Issue
Block a user