test(firstleg): verify trucking detail after dispatch
This commit is contained in:
@@ -196,9 +196,19 @@ export async function run(context) {
|
||||
{ expectedVersion: Number(firstData?.version), reason: '派车' },
|
||||
{ 'Idempotency-Key': `${context.marker}-truck-dispatch`.slice(0, 128) })
|
||||
const dispatched = context.apiSuccess(MODULE, '有效提单后派车', dispatch, '', OPTIONS)
|
||||
context.assert(MODULE, '派车状态及稳定字段完整', dispatch,
|
||||
dispatched?.status === 'DISPATCHED' && truckAppointmentFieldGaps(dispatched).length === 0,
|
||||
`status=${dispatched?.status || 'missing'}`, OPTIONS)
|
||||
context.assert(MODULE, '派车命令返回状态身份与版本正确', dispatch,
|
||||
dispatched?.status === 'DISPATCHED' && id(dispatched?.id) === appointmentId
|
||||
&& Number(dispatched?.version) > Number(firstData?.version),
|
||||
`id=${id(dispatched?.id) || 'missing'}, status=${dispatched?.status || 'missing'}, version=${dispatched?.version ?? 'missing'}`, OPTIONS)
|
||||
const detailResponse = await request(context, 'GET', path); const detail = data(detailResponse)
|
||||
context.apiSuccess(MODULE, '派车后回查拖车完整详情', detailResponse, '', OPTIONS)
|
||||
const detailGaps = truckAppointmentFieldGaps(detail)
|
||||
context.assert(MODULE, '详情字段完整且订舱柜号身份无客户字段漂移', detailResponse,
|
||||
detail?.status === 'DISPATCHED' && detailGaps.length === 0
|
||||
&& !Object.hasOwn(detail || {}, 'customerId') && !Object.hasOwn(detail || {}, 'customerName')
|
||||
&& id(detail?.oceanBookingId) === identity.oceanBookingId
|
||||
&& id(detail?.containerBookingId) === identity.containerBookingId,
|
||||
`missing=${detailGaps.join(',') || 'none'}, oceanBookingId=${id(detail?.oceanBookingId) || 'missing'}, containerBookingId=${id(detail?.containerBookingId) || 'missing'}`, OPTIONS)
|
||||
context.createdResources.truckAppointment = { id: appointmentId, marker: context.marker, finalStatus: 'DISPATCHED',
|
||||
oceanBookingId: identity.oceanBookingId, containerBookingId: identity.containerBookingId }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user