优化
This commit is contained in:
@@ -1,35 +1,21 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
const source = readFileSync(new URL('./manual-state-ocean-trucking.mjs', import.meta.url), 'utf8')
|
||||
|
||||
test('retains only operational ocean booking states from direct CONFIRMED registration', () => {
|
||||
assert.match(source, /const OCEAN_BASE = ['"]\/api\/platform\/v1\/ocean-bookings['"]/)
|
||||
assert.doesNotMatch(source, /\/api\/platform\/v1\/first-leg\/ocean-bookings/)
|
||||
for (const status of ['CONFIRMED','RELEASED','CHANGE_PENDING','CANCELLED',
|
||||
'PENDING_DISPATCH','DISPATCHED','PICKUP_IN_PROGRESS','ARRIVED_WAREHOUSE','LOADING','DEPARTED',
|
||||
'COMPLETED','RESCHEDULED','EXCEPTION']) assert.match(source, new RegExp(`['"]${status}['"]`))
|
||||
assert.match(source, /change-request/)
|
||||
assert.match(source, /const OCEAN_LIST_STATUSES = \['CONFIRMED', 'CHANGE_PENDING', 'RELEASED', 'CANCELLED'\]/)
|
||||
assert.match(source, /const OCEAN_STATUSES = \[\.\.\.OCEAN_LIST_STATUSES\]/)
|
||||
assert.doesNotMatch(source, /OCEAN_HIDDEN_STATUSES|hiddenFixtures|verifyHiddenOcean/)
|
||||
assert.match(source, /一次创建直接返回 CONFIRMED/)
|
||||
assert.doesNotMatch(source, /ocean-bookings\/\$\{[^}]+\}\/submit|ocean-bookings\/\$\{[^}]+\}\/confirm/)
|
||||
const draftPayload = source.slice(source.indexOf('function oceanPayload'), source.indexOf('async function createOcean'))
|
||||
for (const field of ['billOfLadingNo', 'vesselName', 'voyageNo', 'estimatedSailingAt', 'estimatedArrivalAt']) {
|
||||
assert.match(draftPayload, new RegExp(`${field}:`))
|
||||
test('manual matrix retains only DRAFT and RELEASED ocean booking states', () => {
|
||||
assert.match(source, /const OCEAN_LIST_STATUSES = \['DRAFT', 'RELEASED'\]/)
|
||||
assert.match(source, /containerRequirements:/)
|
||||
assert.doesNotMatch(source, /change-request|\/cancel/)
|
||||
assert.doesNotMatch(source, /realContainerBookingId|containerNo:\s*`MAN-/)
|
||||
assert.match(source, /status === 'DRAFT'/)
|
||||
assert.match(source, /status === 'RELEASED'/)
|
||||
})
|
||||
|
||||
test('truck matrix remains independent while retaining its own lifecycle', () => {
|
||||
for (const status of ['DRAFT', 'PENDING_DISPATCH', 'DISPATCHED', 'PICKUP_IN_PROGRESS',
|
||||
'ARRIVED_WAREHOUSE', 'LOADING', 'DEPARTED', 'COMPLETED', 'RESCHEDULED', 'EXCEPTION', 'CANCELLED']) {
|
||||
assert.match(source, new RegExp(`['\"]${status}['\"]`))
|
||||
}
|
||||
const lifecycle = source.slice(source.indexOf('async function buildOcean'), source.indexOf('function truckPayload'))
|
||||
assert.doesNotMatch(lifecycle, /'submit'|'confirm'|'fail'/)
|
||||
assert.match(source, /\/reschedule\?plannedLoadingAt=/)
|
||||
assert.match(source, /page=1&size=100&status=/)
|
||||
assert.match(source, /customerId: oceanBooking\.customerId/)
|
||||
assert.match(source, /warehouseId: oceanBooking\.warehouseId/)
|
||||
assert.doesNotMatch(source, /customerId: ['"]10001['"]/)
|
||||
assert.doesNotMatch(source, /warehouseId: ['"]193000000000200001['"]/)
|
||||
assert.match(source, /carrierId: null, carrierName: null/)
|
||||
assert.doesNotMatch(source, /人工验收车队-/)
|
||||
assert.match(source, /billOfLadingNo: value\.oceanBooking\.billOfLadingNo/)
|
||||
assert.doesNotMatch(source, /DELETE/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user