test(admin): follow real loading start sequence
This commit is contained in:
@@ -100,7 +100,7 @@ export async function run(context) {
|
||||
const containerDetail = context.apiSuccess(MODULE, '回查货柜详情', containerDetailResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '货柜详情保留候选货物路线约束', containerDetailResponse,
|
||||
containerDetail?.destinationWarehouseCode === (candidate.destinationWarehouseCode || null)
|
||||
&& containerDetail?.planStatus === 'EDITING',
|
||||
&& containerDetail?.planStatus === 'WAIT_LOADING',
|
||||
`planStatus=${containerDetail?.planStatus || 'missing'}`, OPTIONS)
|
||||
|
||||
const planResponse = await request(context, 'POST', `${SMART}/plans`, { bookingId: containerId, remark: context.marker })
|
||||
@@ -147,24 +147,24 @@ export async function run(context) {
|
||||
const pushResponse = await request(context, 'POST', `${SMART}/plans/${planId}/push-preload`,
|
||||
{ expectedVersion: Number(assigned.version) }, { 'Idempotency-Key': pushKey })
|
||||
const pushed = context.apiSuccess(MODULE, '推送预装并创建 PDA 任务', pushResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '推送后计划进入 LOADING 且版本递增', pushResponse,
|
||||
pushed?.status === 'LOADING' && Number(pushed?.version) === Number(assigned.version) + 1,
|
||||
context.assert(MODULE, '推送后计划保持 EDITING 且版本递增', pushResponse,
|
||||
pushed?.status === 'EDITING' && Number(pushed?.version) === Number(assigned.version) + 1,
|
||||
`status=${pushed?.status || 'missing'}, version=${pushed?.version ?? 'missing'}`, OPTIONS)
|
||||
if (pushed?.status !== 'LOADING') return
|
||||
if (pushed?.status !== 'EDITING') return
|
||||
|
||||
const pushReplayResponse = await request(context, 'POST', `${SMART}/plans/${planId}/push-preload`,
|
||||
{ expectedVersion: Number(assigned.version) }, { 'Idempotency-Key': pushKey })
|
||||
const pushReplay = context.apiSuccess(MODULE, '推送预装 Idempotency-Key 重放', pushReplayResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '推送重放保持同一 LOADING 计划', pushReplayResponse,
|
||||
id(pushReplay?.id) === planId && pushReplay?.status === 'LOADING'
|
||||
context.assert(MODULE, '推送重放保持同一 EDITING 计划', pushReplayResponse,
|
||||
id(pushReplay?.id) === planId && pushReplay?.status === 'EDITING'
|
||||
&& Number(pushReplay?.version) === Number(pushed.version),
|
||||
`planId=${id(pushReplay?.id) || 'missing'}, version=${pushReplay?.version ?? 'missing'}`, OPTIONS)
|
||||
|
||||
const preloadPageResponse = await context.request('GET',
|
||||
`${FIRST_LEG}/loading-plans?warehouseId=${encodeURIComponent(warehouseId)}&keyword=${encodeURIComponent(containerNo)}&page=1&size=20`)
|
||||
const preloadPage = context.apiSuccess(MODULE, '查询本轮预装清单', preloadPageResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '预装清单包含本轮 LOADING 计划', preloadPageResponse,
|
||||
records(preloadPage).some((item) => id(item.planId) === planId && item.status === 'LOADING'),
|
||||
context.assert(MODULE, '预装清单包含本轮已推送 EDITING 计划', preloadPageResponse,
|
||||
records(preloadPage).some((item) => id(item.planId) === planId && item.status === 'EDITING'),
|
||||
`records=${records(preloadPage).length}`, OPTIONS)
|
||||
|
||||
const taskResponse = await context.request('GET',
|
||||
@@ -185,7 +185,8 @@ export async function run(context) {
|
||||
failure(wrongWarehouseResponse), `HTTP=${wrongWarehouseResponse.http}, code=${codeOf(wrongWarehouseResponse)}`, OPTIONS)
|
||||
|
||||
const claimResponse = await request(context, 'POST', `${PDA}/tasks/${taskId}/claim`, {
|
||||
expectedAssignmentVersion: 0, operationId: `${context.marker}-pda-claim`.slice(0, 128),
|
||||
expectedAssignmentVersion: Number(task?.assignment?.version || 0),
|
||||
operationId: `${context.marker}-pda-claim`.slice(0, 128),
|
||||
})
|
||||
const claimed = context.apiSuccess(MODULE, '领取本轮柜次 PDA 任务', claimResponse, '', OPTIONS)
|
||||
context.assert(MODULE, 'PDA 任务只分配给当前登录作业员', claimResponse,
|
||||
@@ -193,6 +194,12 @@ export async function run(context) {
|
||||
&& Number(claimed?.assignment?.version) === 0,
|
||||
`workflow=${claimed?.workflowStatus || 'missing'}, assigneeId=${id(claimed?.assignment?.assigneeId) || 'missing'}`, OPTIONS)
|
||||
|
||||
const claimedPlanResponse = await context.request('GET', `${SMART}/plans/${planId}`)
|
||||
const claimedPlan = context.apiSuccess(MODULE, '领取后回查装柜计划', claimedPlanResponse, '', OPTIONS)
|
||||
context.assert(MODULE, '仅领取任务不提前开始装柜', claimedPlanResponse,
|
||||
claimedPlan?.status === 'EDITING' && Number(claimedPlan?.version) === Number(pushed?.version),
|
||||
`status=${claimedPlan?.status || 'missing'}, version=${claimedPlan?.version ?? 'missing'}`, OPTIONS)
|
||||
|
||||
const batchPath = `${PDA}/tasks/${taskId}/batch`
|
||||
const batchItems = [{ itemId: id(pickItem.id), action: 'PICK', pickedPackageCount: 1,
|
||||
finalPickedPackageCount: null, releaseMode: 'MANUAL', locationIds: [],
|
||||
@@ -261,6 +268,7 @@ export async function run(context) {
|
||||
id(confirmedDetail?.summary?.planId) === planId && confirmedDetail?.summary?.status === 'COMPLETED'
|
||||
&& confirmedDetail?.items?.some?.((item) => id(item.inboundId) === inboundId
|
||||
&& id(item.accountId) === tenantId && Boolean(item.frozenAt))
|
||||
&& confirmedDetail?.histories?.some?.((item) => item.actionType === 'START_LOADING')
|
||||
&& confirmedDetail?.histories?.some?.((item) => item.actionType === 'PDA_COMPLETE_LOADING'
|
||||
&& Boolean(item.operatorName) && Boolean(item.occurredAt)),
|
||||
`items=${confirmedDetail?.items?.length ?? 'n/a'}, histories=${confirmedDetail?.histories?.length ?? 'n/a'}`, OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user