49 lines
2.4 KiB
JavaScript
49 lines
2.4 KiB
JavaScript
import assert from 'node:assert/strict'
|
|||
|
|
import { readFile } from 'node:fs/promises'
|
||
|
|
import test from 'node:test'
|
||
|
|
import { fileURLToPath } from 'node:url'
|
||
|
|
import { normalizeModuleOrder } from '../admin-test-env-acceptance.mjs'
|
||
|
|
|
||
|
|
const source = await readFile(fileURLToPath(new URL('./phase5-terminal-drayage.mjs', import.meta.url)), 'utf8')
|
||
|
|
|
||
|
|
test('terminal drayage runs after pickup-ready and overseas unloading but before final carrier validation', () => {
|
||
|
|
const modules = normalizeModuleOrder(['phase4-carrier-nodes'])
|
||
|
|
const pickup = modules.indexOf('phase4-carrier-pickup-ready')
|
||
|
|
const pda = modules.indexOf('phase4-overseas-pda')
|
||
|
|
const drayage = modules.indexOf('phase5-terminal-drayage')
|
||
|
|
const finalCarrier = modules.indexOf('phase4-carrier-nodes')
|
||
|
|
assert.ok(pickup >= 0 && pickup < pda)
|
||
|
|
assert.ok(pda < drayage && drayage < finalCarrier)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('module uses only public business endpoints and reuses public trucking master data', () => {
|
||
|
|
for (const path of [
|
||
|
|
'/api/platform/v1/terminal-drayages', "'fleet'", "'pickup-appointment'", "'pickup'", "'empty-return'", '/history',
|
||
|
|
'category=TRUCKING',
|
||
|
|
]) assert.ok(source.includes(path), `missing ${path}`)
|
||
|
|
assert.doesNotMatch(source, /\/internal\//)
|
||
|
|
assert.doesNotMatch(source, /POST[^\n]*\/api\/platform\/v1\/suppliers/)
|
||
|
|
assert.match(source, /脚本不临时创建主数据/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('all four commands cover idempotent replay hash conflict and lifecycle semantics', () => {
|
||
|
|
for (const token of [
|
||
|
|
'选择车队', '预约提柜', '确认实际提柜', '确认实际还柜',
|
||
|
|
'同键重放', '同键异载荷返回A0409', 'PICKED_UP', 'UNLOADED', 'EMPTY_RETURNED',
|
||
|
|
'SELECT_FLEET', 'SCHEDULE_PICKUP', 'RECORD_PICKUP', 'RECORD_EMPTY_RETURN', 'RESOLVED',
|
||
|
|
]) assert.ok(source.includes(token), `missing ${token}`)
|
||
|
|
assert.match(source, /JSON\.stringify\(replay\.data\) === JSON\.stringify\(first\.data\)/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('target is strictly current-marker pickup and completed-PDA container', () => {
|
||
|
|
assert.match(source, /matrix\?\.marker !== context\.marker/)
|
||
|
|
assert.match(source, /pda\?\.marker !== context\.marker/)
|
||
|
|
assert.match(source, /pda\?\.finalStatus !== 'COMPLETED'/)
|
||
|
|
assert.match(source, /completedContainerFacts/)
|
||
|
|
assert.match(source, /item\?\.shippingReady === true/)
|
||
|
|
assert.match(source, /carrierScheduleQueryId/)
|
||
|
|
assert.match(source, /carrierLatestActualAt/)
|
||
|
|
assert.match(source, /phase4CarrierPickupReady =/)
|
||
|
|
assert.match(source, /禁止借历史货柜/)
|
||
|
|
})
|