test: align outbound producer with container customs
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
const MODULE = 'phase3-container-documents'
|
||||
const OPTIONS = { scenario: 'phase3-container-four-documents', deploymentBlocker: true }
|
||||
const OPTIONS = { scenario: 'phase3-container-operational-documents', deploymentBlocker: true }
|
||||
const CONTAINERS = '/api/platform/v1/containers'
|
||||
const FIRST_LEG = '/api/platform/v1/first-leg'
|
||||
|
||||
export const DOCUMENT_TYPES = Object.freeze([
|
||||
'DESTINATION_CLEARANCE', 'CUSTOMS_DECLARATION', 'DELIVERY_ORDER', 'PICKUP_ORDER',
|
||||
'DESTINATION_CLEARANCE', 'DELIVERY_ORDER', 'PICKUP_ORDER',
|
||||
])
|
||||
|
||||
function id(value) { return value == null ? '' : String(value) }
|
||||
@@ -37,7 +36,7 @@ async function upload(context, path, type, expectedVersion, operationReason, ide
|
||||
}
|
||||
|
||||
async function uploadAndVerify(context, { type, uploadPath, readPath, completePath = null }) {
|
||||
const operationReason = `${context.marker} 四类货柜资料全链验收`
|
||||
const operationReason = `${context.marker} 货柜作业资料全链验收`
|
||||
const uploadKey = key(context, `${type}-upload`)
|
||||
const response = await upload(context, uploadPath, type, 0, operationReason, uploadKey)
|
||||
let document = context.apiSuccess(MODULE, `上传${type}`, response, `documentType=${type}`, OPTIONS)
|
||||
@@ -102,7 +101,7 @@ export async function run(context) {
|
||||
const warehouseId = id(fixture?.warehouseId)
|
||||
if (fixture?.marker !== context.marker || fixture?.finalizeSucceeded !== true
|
||||
|| fixture?.finalStatus !== 'LOADED' || !containerId || !planId || !warehouseId) {
|
||||
context.addStep(MODULE, '取得本轮LOADED柜次四类资料前置', null, false,
|
||||
context.addStep(MODULE, '取得本轮LOADED柜次作业资料前置', null, false,
|
||||
`marker=${fixture?.marker || 'missing'}, status=${fixture?.finalStatus || 'missing'}, containerBookingId=${containerId || 'missing'}, loadingPlanId=${planId || 'missing'}, warehouseId=${warehouseId || 'missing'}`,
|
||||
OPTIONS)
|
||||
return
|
||||
@@ -115,12 +114,6 @@ export async function run(context) {
|
||||
readPath: `${CONTAINERS}/${containerId}/clearance`,
|
||||
completePath: `${CONTAINERS}/${containerId}/clearance/complete`,
|
||||
},
|
||||
{
|
||||
type: 'CUSTOMS_DECLARATION',
|
||||
uploadPath: `${FIRST_LEG}/loading-lists/${planId}/customs/document/upload?warehouseId=${encodeURIComponent(warehouseId)}`,
|
||||
readPath: `${FIRST_LEG}/loading-lists/${planId}/customs?warehouseId=${encodeURIComponent(warehouseId)}`,
|
||||
completePath: `${FIRST_LEG}/loading-lists/${planId}/customs/complete?warehouseId=${encodeURIComponent(warehouseId)}`,
|
||||
},
|
||||
...['DELIVERY_ORDER', 'PICKUP_ORDER'].map((type) => ({
|
||||
type,
|
||||
uploadPath: `${CONTAINERS}/${containerId}/documents/${type}/upload`,
|
||||
@@ -131,9 +124,9 @@ export async function run(context) {
|
||||
const documents = []
|
||||
for (const spec of specs) documents.push(await uploadAndVerify(context, spec))
|
||||
const overviewResponse = await context.request('GET', `${CONTAINERS}/${containerId}/overview`)
|
||||
const overview = context.apiSuccess(MODULE, '回查货柜四类资料聚合', overviewResponse, '', OPTIONS)
|
||||
const overview = context.apiSuccess(MODULE, '回查货柜作业资料聚合', overviewResponse, '', OPTIONS)
|
||||
const storedTypes = new Set((overview?.documents || []).map((item) => item?.documentType))
|
||||
context.assert(MODULE, '同一LOADED柜次聚合返回四类资料且身份未漂移', overviewResponse,
|
||||
context.assert(MODULE, '同一LOADED柜次聚合返回作业资料且身份未漂移', overviewResponse,
|
||||
id(overview?.container?.id) === containerId && documents.every(Boolean)
|
||||
&& DOCUMENT_TYPES.every((type) => storedTypes.has(type)),
|
||||
`containerBookingId=${containerId}, documentTypes=${[...storedTypes].join('|') || 'none'}`, OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user