test(firstleg): assert atomic smart coload recommendation

This commit is contained in:
2026-08-30 15:58:14 +08:00
parent 9a15e78b2e
commit 4581c8a294
2 changed files with 11 additions and 12 deletions
@@ -516,7 +516,8 @@ export async function run(context) {
const groupedCandidates = candidates.filter((item) => id(item?.coLoadGroupId) === groupId)
context.assert(MODULE, '每个组成员候选携带相同整组事实', candidateResponse,
groupedCandidates.length === 2 && groupedCandidates.every((item) => Number(item?.memberCount) === 2
&& Number(item?.groupTotalBoxes) === first.packages + second.packages && item?.locked !== true),
&& Number(item?.groupTotalBoxes) === first.packages + second.packages && item?.locked !== true
&& String(item?.blockReason || '').includes('同柜不可拆组整体超过当前柜剩余容量')),
`count=${groupedCandidates.length}, groupTotal=${first.packages + second.packages}`, OPTIONS)
let isolatedCandidates = candidates
@@ -565,15 +566,13 @@ export async function run(context) {
expectedVersion: Number(plan?.version),
operationId: `${context.marker}-coload-capacity-recommend`.slice(0, 128),
})
const capacityRejected = recommendResponse?.http === 200 && code(recommendResponse) === 'A0422'
&& String(recommendResponse?.body?.message || '').includes('同柜不可拆组整体超过货柜')
context.assert(MODULE, '目标同柜组整体超容时智能推荐明确拒绝', recommendResponse,
capacityRejected,
evidence(recommendResponse, `targetGroupId=${groupId}, members=${[first.inboundId, second.inboundId].join('|')}, message=${recommendResponse?.body?.message || 'none'}`), OPTIONS)
const afterRecommend = await readPlan(context, planId, '回读整组容量拒绝后计划')
context.assert(MODULE, '整组容量不足时推荐事务零漂移', afterRecommend.response,
planSignature(beforeRecommend) === planSignature(afterRecommend.data),
`before=${planSignature(beforeRecommend)}, after=${planSignature(afterRecommend.data)}`, OPTIONS)
const capacityRecommendation = context.apiSuccess(MODULE, '目标同柜组整体超容时智能推荐跳过整组',
recommendResponse, evidence(recommendResponse, `targetGroupId=${groupId}`), OPTIONS)
const capacityGroupItems = (capacityRecommendation?.items || [])
.filter((item) => [first.inboundId, second.inboundId].includes(id(item?.inboundId)))
context.assert(MODULE, '整组容量不足时智能推荐全不取且不产生部分成员', recommendResponse,
capacityGroupItems.length === 0,
`targetGroupId=${groupId}, assignedMembers=${capacityGroupItems.map((item) => id(item?.inboundId)).join('|') || 'none'}, before=${planSignature(beforeRecommend)}, after=${planSignature(capacityRecommendation)}`, OPTIONS)
const recommendSimulationResponse = await context.request('POST', '/api/platform/v1/containers', {
channelCode: first.channelCode, warehouseId: first.warehouseId, containerType: '40HC',