125 lines
8.4 KiB
JavaScript
125 lines
8.4 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
|
|
import { controlledPhotoDownload } from './phase3-container-overview.mjs'
|
|
|
|
const read = (path) => readFileSync(new URL(path, import.meta.url), 'utf8')
|
|
const overviewOpenApi = read('../../firstleg/src/main/resources/openapi/phase3-container-overview-v1.yaml')
|
|
const oceanOpenApi = read('../../firstleg/src/main/resources/openapi/ocean-bookings-v1.yaml')
|
|
const overviewAcceptance = read('phase3-container-overview.mjs')
|
|
const oceanAcceptance = read('ocean-bookings.mjs')
|
|
const oceanFixture = read('ocean-booking-fixture.mjs')
|
|
const adminRoot = '../../../apps/admin-web/src/modules/'
|
|
const releaseView = read(`${adminRoot}ocean-bookings/pages/OceanBookingDetailView.vue`)
|
|
const releaseTypes = read(`${adminRoot}ocean-bookings/types.ts`)
|
|
const truckApi = read(`${adminRoot}trucking/api/platformTrucking.ts`)
|
|
const truckAttachmentDialog = read(`${adminRoot}trucking/components/TruckAttachmentDialog.vue`)
|
|
const truckList = read(`${adminRoot}trucking/pages/TruckAppointmentsView.vue`)
|
|
const truckForm = read(`${adminRoot}trucking/components/TruckAppointmentForm.vue`)
|
|
const containerList = read(`${adminRoot}container-loading/pages/ContainersView.vue`)
|
|
const containerOverviewPanel = read(`${adminRoot}container-loading/components/ContainerOverviewPanel.vue`)
|
|
const containerLoadingAcceptance = read('phase3-container-loading.mjs')
|
|
const truckAcceptance = read('truck-appointments.mjs')
|
|
const matrix = read('../../../docs/三期/货柜管理全链验收矩阵-2026-08-13.md')
|
|
|
|
test('registration freezes all five transport fields and release reuses the confirmed snapshot', () => {
|
|
assert.match(oceanOpenApi, /required: \[expectedVersion, billOfLadingNo, vesselName, voyageNo, estimatedSailingAt, estimatedArrivalAt\]/)
|
|
for (const field of ['billOfLadingNo', 'vesselName', 'voyageNo', 'estimatedSailingAt', 'estimatedArrivalAt']) {
|
|
assert.match(releaseTypes, new RegExp(`${field}: string`), field)
|
|
assert.match(releaseView, new RegExp(`form\\.data\\.${field}`), field)
|
|
assert.match(releaseView, new RegExp(`detail\\.value\\.${field}`), field)
|
|
assert.match(oceanFixture, new RegExp(`${field}:`), field)
|
|
}
|
|
assert.match(releaseView, /当前订舱缺少已确认运输资料,无法放舱/)
|
|
assert.match(releaseView, /放舱不会重新采集或修改这些信息/)
|
|
})
|
|
|
|
test('overview regression requires workflowStatus and distinguishes 100 percent awaiting review', () => {
|
|
assert.match(overviewAcceptance, /'workflowStatus'/)
|
|
assert.match(overviewAcceptance, /workflowStatus === 'AWAITING_REVIEW'/)
|
|
assert.match(overviewOpenApi, /workflowStatus:/)
|
|
assert.doesNotMatch(matrix, /PDA overview `workflowStatus` 缺失[\s\S]*BLOCKED_CONTRACT/)
|
|
})
|
|
|
|
test('active overview photos download through controlled paths while void history has no download entry', () => {
|
|
assert.match(overviewOpenApi, /\/api\/platform\/v1\/containers\/\{id\}\/pda\/photos\/\{fileId\}\/download/)
|
|
assert.match(overviewAcceptance, /\['evidenceId', 'fileId', 'status'\]\.every/)
|
|
assert.doesNotMatch(overviewAcceptance, /\['evidenceId', 'fileId', 'status', 'downloadPath'\]\.every/)
|
|
assert.match(overviewAcceptance, /context\.requestBinary\('GET', downloadPath\)/)
|
|
assert.match(overviewAcceptance, /photo\.status === 'VOID'/)
|
|
assert.match(overviewAcceptance, /overview PDA 作废照片 \$\{index \+ 1\} 无下载入口/)
|
|
assert.match(overviewAcceptance, /photo\.status !== 'ACTIVE' \|\| !controlledPath/)
|
|
assert.match(overviewOpenApi, /status: \{type: string, enum: \[ACTIVE, VOID\]\}/)
|
|
assert.match(overviewOpenApi, /downloadPath: \{type: string, nullable: true, description: '仅 ACTIVE 照片提供鉴权下载路径;VOID 历史照片为空'\}/)
|
|
assert.equal(overviewAcceptance.indexOf("if (photo.status === 'VOID')")
|
|
< overviewAcceptance.indexOf("context.requestBinary('GET', downloadPath)"), true)
|
|
assert.equal(controlledPhotoDownload('/api/platform/v1/containers/7/pda/photos/23/download', {
|
|
http: 200, bytes: new Uint8Array([1]), contentType: 'image/png',
|
|
}), true)
|
|
for (const [path, response] of [
|
|
['https://example.test/file', { http: 200, bytes: new Uint8Array([1]), contentType: 'image/png' }],
|
|
['/api/platform/v1/files/loading-evidence/21/22/23', { http: 200, bytes: new Uint8Array([1]), contentType: 'image/png' }],
|
|
['/api/platform/v1/containers/7/pda/photos/23/download', { http: 200, bytes: new Uint8Array([1]), contentType: 'application/json' }],
|
|
['/api/platform/v1/containers/7/pda/photos/23/download', { http: 404, bytes: new Uint8Array(), contentType: 'image/png' }],
|
|
]) assert.equal(controlledPhotoDownload(path, response), false)
|
|
})
|
|
|
|
test('truck attachment API and Admin upload-reference-delete flow are frozen', () => {
|
|
assert.match(truckApi, /referenceTruckAppointmentAttachment/)
|
|
assert.match(truckApi, /uploadTruckAppointmentAttachment/)
|
|
assert.match(truckApi, /deleteTruckAppointmentAttachment/)
|
|
assert.match(truckAttachmentDialog, /uploadTruckAppointmentAttachment/)
|
|
assert.match(truckAttachmentDialog, /上传并关联/)
|
|
assert.match(truckAttachmentDialog, /confirmButtonText: '确认', cancelButtonText: '取消'/)
|
|
assert.match(truckAcceptance, /删除后回查拖车预约附件列表/)
|
|
assert.match(truckAcceptance, /!remainingAttachments\.some/)
|
|
assert.match(matrix, /拖车附件闭环[\s\S]*`LANDED`/)
|
|
})
|
|
|
|
test('existing container number replacement keeps container plan and PDA identities stable', () => {
|
|
assert.match(containerLoadingAcceptance, /replacementContainerNo/)
|
|
assert.match(containerLoadingAcceptance, /containerBookingId: containerId/)
|
|
assert.match(containerLoadingAcceptance, /loadingPlanId: planId/)
|
|
assert.match(containerLoadingAcceptance, /pdaTaskId: taskId/)
|
|
assert.match(containerLoadingAcceptance, /pdaIdentityStable: true/)
|
|
})
|
|
|
|
test('PDA task opens only after no-number push, real-container merge, release and plan-level confirmation', () => {
|
|
assert.match(containerLoadingAcceptance, /无真实柜号推送预装计划成功/)
|
|
assert.match(containerLoadingAcceptance, /无号 push 成功后 PDA 查询 A0404/)
|
|
assert.match(containerLoadingAcceptance, /realContainerBookingId: id\(requirement\.containerBookingId\)/)
|
|
assert.match(containerLoadingAcceptance, /合并后列表仅保留模拟柜原地转成的一条 ACTIVE 操作身份/)
|
|
assert.match(containerLoadingAcceptance, /订舱已关联但未 RELEASED 不生成 PDA 任务/)
|
|
assert.match(containerLoadingAcceptance, /ocean-bookings\/\$\{bookingId\}\/release/)
|
|
assert.match(containerLoadingAcceptance, /订舱携带已冻结运输快照放舱并满足 PDA 门禁/)
|
|
assert.match(containerLoadingAcceptance, /订舱 RELEASED 但预装未 CONFIRMED 不生成 PDA 任务/)
|
|
assert.match(containerLoadingAcceptance, /loading-plans\/\$\{planId\}\/confirm/)
|
|
assert.match(containerLoadingAcceptance, /计划级原子确认整份预装并触发唯一 PDA 任务/)
|
|
assert.match(containerLoadingAcceptance, /confirmationStatus === 'CONFIRMED'/)
|
|
assert.match(containerLoadingAcceptance, /readiness\?\.readyForPda === true/)
|
|
assert.match(containerLoadingAcceptance, /taskId === confirmedTaskId/)
|
|
assert.match(containerLoadingAcceptance, /计划级确认同 key 异参返回冲突/)
|
|
assert.match(containerLoadingAcceptance, /已确认计划使用新 key 重复确认返回冲突/)
|
|
assert.doesNotMatch(containerLoadingAcceptance, /\/preload\/confirming|\/preload\/confirm\?tenantId=/)
|
|
assert.match(containerLoadingAcceptance, /releasedBooking\?\.oceanBooking\?\.status === 'RELEASED'/)
|
|
})
|
|
|
|
test('customer public display uses tenantName without a legalName fallback', () => {
|
|
for (const source of [truckList, containerList]) {
|
|
assert.match(source, /label: customer\.tenantName/)
|
|
}
|
|
assert.match(truckForm, /return customer\.tenantName/)
|
|
for (const source of [truckList, containerList, truckForm])
|
|
assert.doesNotMatch(source, /customer\.legalName\?\.trim\(\) \|\| customer\.tenantName/)
|
|
assert.match(matrix, /客户公开名称一致性[\s\S]*已统一 `tenantName`[\s\S]*`LANDED`/)
|
|
})
|
|
|
|
test('Chinese status dialogs and 390px layout are landed', () => {
|
|
assert.match(releaseView, /确认放舱/)
|
|
assert.match(containerOverviewPanel, /AWAITING_REVIEW: '待人工复核'/)
|
|
assert.match(containerOverviewPanel, /PHOTO_STEP_EMPTY_CONTAINER: '空柜照片'/)
|
|
assert.match(matrix, /中文状态、弹框与 390px 布局[\s\S]*`LANDED`/)
|
|
assert.doesNotMatch(matrix, /拖车附件新增入口缺失|中文状态、弹框与 390px 布局[^\n]*BLOCKED_CONTRACT/)
|
|
})
|