test: accept automatic outbound confirmation
This commit is contained in:
@@ -98,15 +98,24 @@ export async function run(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const confirmBody = { expectedVersion, remark: context.marker }
|
const confirmBody = { expectedVersion, remark: context.marker }
|
||||||
|
let confirmed
|
||||||
|
if (aggregate.dispatchStatus === 'WAITING_FOR_LOADING') {
|
||||||
|
confirmed = detail
|
||||||
|
context.assert(MODULE, '整柜报关完成事件已自动确认国内出仓', detailResponse,
|
||||||
|
confirmed?.aggregate?.dispatchStatus === 'WAITING_FOR_LOADING'
|
||||||
|
&& confirmed?.aggregate?.inbounds?.every?.((item) => item?.inboundStatus === 'LOADED')
|
||||||
|
&& confirmed?.timeline?.some?.((item) => item.module === 'OUTBOUND_DISPATCH'
|
||||||
|
&& item.action === 'CONFIRM_DISPATCH'),
|
||||||
|
`dispatch=${confirmed?.aggregate?.dispatchStatus || 'missing'}, version=${confirmed?.aggregate?.version ?? 'missing'}`, OPTIONS)
|
||||||
|
} else {
|
||||||
const confirmResponse = await request(context, 'POST', `${BASE}/${encodeURIComponent(containerBookingId)}/confirm`, confirmBody,
|
const confirmResponse = await request(context, 'POST', `${BASE}/${encodeURIComponent(containerBookingId)}/confirm`, confirmBody,
|
||||||
{ 'Idempotency-Key': confirmKey })
|
{ 'Idempotency-Key': confirmKey })
|
||||||
const confirmed = context.apiSuccess(MODULE, '确认国内出仓进入等待装船', confirmResponse, '', OPTIONS)
|
confirmed = context.apiSuccess(MODULE, '确认国内出仓进入等待装船', confirmResponse, '', OPTIONS)
|
||||||
context.assert(MODULE, 'confirm-dispatch 推进 WAITING_FOR_LOADING 并递增版本', confirmResponse,
|
context.assert(MODULE, 'confirm-dispatch 推进 WAITING_FOR_LOADING 并递增版本', confirmResponse,
|
||||||
confirmed?.aggregate?.dispatchStatus === 'WAITING_FOR_LOADING'
|
confirmed?.aggregate?.dispatchStatus === 'WAITING_FOR_LOADING'
|
||||||
&& confirmed?.aggregate?.inbounds?.every?.((item) => item?.inboundStatus === 'LOADED')
|
&& confirmed?.aggregate?.inbounds?.every?.((item) => item?.inboundStatus === 'LOADED')
|
||||||
&& Number(confirmed?.aggregate?.version) === expectedVersion + 1,
|
&& Number(confirmed?.aggregate?.version) === expectedVersion + 1,
|
||||||
`dispatch=${confirmed?.aggregate?.dispatchStatus || 'missing'}, inbounds=${confirmed?.aggregate?.inbounds?.length ?? 'missing'}, version=${confirmed?.aggregate?.version ?? 'missing'}`, OPTIONS)
|
`dispatch=${confirmed?.aggregate?.dispatchStatus || 'missing'}, inbounds=${confirmed?.aggregate?.inbounds?.length ?? 'missing'}, version=${confirmed?.aggregate?.version ?? 'missing'}`, OPTIONS)
|
||||||
if (!confirmed?.aggregate) return
|
|
||||||
|
|
||||||
const replayResponse = await request(context, 'POST', `${BASE}/${encodeURIComponent(containerBookingId)}/confirm`, confirmBody,
|
const replayResponse = await request(context, 'POST', `${BASE}/${encodeURIComponent(containerBookingId)}/confirm`, confirmBody,
|
||||||
{ 'Idempotency-Key': confirmKey })
|
{ 'Idempotency-Key': confirmKey })
|
||||||
@@ -121,6 +130,8 @@ export async function run(context) {
|
|||||||
context.addStep(MODULE, '相同 Idempotency-Key 不同请求拒绝', hashConflict,
|
context.addStep(MODULE, '相同 Idempotency-Key 不同请求拒绝', hashConflict,
|
||||||
hashConflict.http === 200 && codeOf(hashConflict) === 'A0409',
|
hashConflict.http === 200 && codeOf(hashConflict) === 'A0409',
|
||||||
`HTTP=${hashConflict.http}, code=${codeOf(hashConflict)}`, OPTIONS)
|
`HTTP=${hashConflict.http}, code=${codeOf(hashConflict)}`, OPTIONS)
|
||||||
|
}
|
||||||
|
if (!confirmed?.aggregate) return
|
||||||
|
|
||||||
const reverseKey = `${context.marker}-outbound-reverse`.slice(0, 128)
|
const reverseKey = `${context.marker}-outbound-reverse`.slice(0, 128)
|
||||||
const reverseResponse = await request(context, 'POST', `${BASE}/${encodeURIComponent(containerBookingId)}/reverse`, {
|
const reverseResponse = await request(context, 'POST', `${BASE}/${encodeURIComponent(containerBookingId)}/reverse`, {
|
||||||
|
|||||||
Reference in New Issue
Block a user