test(phase3): complete remaining hard-gate fixtures

This commit is contained in:
2026-08-24 13:57:02 +08:00
parent 23335ee8d0
commit f041cf524b
5 changed files with 21 additions and 6 deletions
@@ -18,4 +18,6 @@ test('truck matrix remains independent while retaining its own lifecycle', () =>
assert.match(source, new RegExp(`['\"]${status}['\"]`))
}
assert.match(source, /page=1&size=100&status=/)
assert.match(source, /category=TRUCKING&status=ACTIVE/)
assert.match(source, /carrierId: id\(carrier\.id\), carrierName: carrier\.name/)
})
@@ -69,13 +69,13 @@ async function buildOcean(context, template, status, index) {
throw new Error(`unsupported ocean status ${status}`)
}
function truckPayload(context, oceanBooking, index) {
function truckPayload(context, oceanBooking, carrier, index) {
const value = suffix(context, index)
return { outboundOrderId: null, oceanBookingId: oceanBooking.id,
containerBookingId: null, loadingPlanId: null,
warehouseId: oceanBooking.warehouseId, customerId: oceanBooking.customerId,
customerName: oceanBooking.customerName,
carrierId: null, carrierName: null, fleetContact: '人工验收联系人', fleetPhone: '13800000004',
customerName: null,
carrierId: id(carrier.id), carrierName: carrier.name, fleetContact: '人工验收联系人', fleetPhone: '13800000004',
driverName: `人工司机-${value}`, driverPhone: '13800000005', vehicleNo: `粤B${value.slice(-6)}`,
storeName: '人工验收仓', storeContact: '仓库联系人', storePhone: '13800000006',
storeAddress: '深圳市南山区人工验收地址', storeCity: '深圳市', storeZipcode: '518000',
@@ -85,7 +85,12 @@ function truckPayload(context, oceanBooking, index) {
}
async function createTruck(context, oceanBooking, index) {
const response = await context.request('POST', TRUCK_BASE, truckPayload(context, oceanBooking, index))
const carrierResponse = await context.request('GET',
'/api/platform/v1/suppliers?tenantId=0&category=TRUCKING&status=ACTIVE&page=1&size=20')
const carrierPage = context.apiSuccess(MODULE, `读取拖车状态样本 ${index} 的 ACTIVE 承运商`, carrierResponse, '', OPTIONS)
const carrier = carrierPage?.records?.find?.((item) => item?.id && item?.name)
if (!carrier) throw new Error(`创建拖车样本 ${index} 缺少 ACTIVE 承运商`)
const response = await context.request('POST', TRUCK_BASE, truckPayload(context, oceanBooking, carrier, index))
const value = context.apiSuccess(MODULE, `创建拖车状态样本 ${index}`, response, '', OPTIONS)
if (!value?.id) throw new Error(`创建拖车样本 ${index} 失败`)
return value
@@ -407,6 +407,14 @@ async function loadOneFragment(context, state) {
`HTTP=${differentReplay.http}, code=${codeOf(differentReplay)}, requestId=${differentReplay.requestId || 'missing'}, traceId=${differentReplay.traceId || 'missing'}`, OPTIONS)
}
const labelResponse = await context.requestBinary('POST',
`/api/platform/inbounds/${encodeURIComponent(id(candidate.inboundId))}/carton-label-pdf?tenantId=${encodeURIComponent(tenantId)}`)
context.assert(MODULE, `${sourceOrderNo} 完成前生成可交接箱唛池`, labelResponse,
labelResponse.http === 200 && String(labelResponse.contentType || '').toLowerCase().includes('pdf')
&& Number(labelResponse.bytes?.length) > 0,
`HTTP=${labelResponse.http}, contentType=${labelResponse.contentType || 'missing'}, bytes=${labelResponse.bytes?.length ?? 0}`, OPTIONS)
if (labelResponse.http !== 200 || !Number(labelResponse.bytes?.length)) return null
if (!await ensureCompletionEvidence(context, tenantId, id(candidate.inboundId), operationBase)) return null
const completePath = `${PDA}/tasks/${taskId}/complete`
@@ -499,7 +499,7 @@ test('downstream container consumers prefer the phase3Loading fixture', () => {
assert.match(serviceCenter, /if \(!allocationMatches\) return/)
assert.match(serviceCenter, /const customerName = String\(oceanDetail\?\.oceanBooking\?\.customerName \|\| ''\)\.trim\(\)/)
assert.match(serviceCenter, /category=TRUCKING&status=ACTIVE/)
assert.match(serviceCenter, /customerId, customerName, carrierId: id\(carrier\.id\), carrierName: carrier\.name/)
assert.match(serviceCenter, /customerId, customerName: null, carrierId: id\(carrier\.id\), carrierName: carrier\.name/)
assert.doesNotMatch(serviceCenter, /链路承运商-/)
assert.doesNotMatch(serviceCenter, /customerName: `服务中心链路客户-/)
const schedules = source('./phase3-port-schedules.mjs')
@@ -87,7 +87,7 @@ export async function run(context) {
warehouseId: linkContainer
? id(containerFlow.warehouseId)
: id(context.createdResources?.warehouse?.id || context.context?.warehouseId || '193000000000000001'),
customerId, customerName, carrierId: id(carrier.id), carrierName: carrier.name,
customerId, customerName: null, carrierId: id(carrier.id), carrierName: carrier.name,
fleetContact: '链路车队联系人', fleetPhone: '13800000007', driverName: '链路司机', driverPhone: '13800000008',
driverIdCard: null, vehicleNo: `粤D-${suffix.slice(-6)}`, storeName: `链路门店-${suffix}`, storeContact: '链路联系人',
storePhone: '13800000009', storeAddress: '深圳市南山区链路地址', storeCity: '深圳市', storeZipcode: '518000',