35 lines
2.0 KiB
JavaScript
35 lines
2.0 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import test from 'node:test'
|
|
|
|
const source = readFileSync(new URL('./phase3-order-splitting.mjs', import.meta.url), 'utf8')
|
|
|
|
test('each remainder follows confirmed booking before scoped smart-loading candidates', () => {
|
|
assert.match(source, /POST', '\/api\/platform\/v1\/ocean-bookings'/)
|
|
assert.match(source, /ocean-bookings\/\$\{oceanBookingId\}\/submit/)
|
|
assert.match(source, /ocean-bookings\/\$\{oceanBookingId\}\/confirm/)
|
|
assert.match(source, /containerAllocations\?\.\[0\]\?\.containerBookingId/)
|
|
assert.match(source, /candidates\?bookingId=\$\{encodeURIComponent\(containerId\)\}&warehouseId=\$\{encodeURIComponent\(warehouseId\)\}/)
|
|
assert.match(source, /`\$\{SMART\}\/plans`, \{ bookingId: containerId/)
|
|
assert.doesNotMatch(source, /request\(context, 'POST', CONTAINERS/)
|
|
assert.doesNotMatch(source, /candidates\?warehouseId=/)
|
|
})
|
|
|
|
test('PDA opens only after a real container number and uses stable plan identity', () => {
|
|
const pushIndex = source.indexOf("`${SMART}/plans/${planId}/push-preload`")
|
|
const transportIndex = source.indexOf("`${CONTAINERS}/${encodeURIComponent(containerId)}/transport`")
|
|
const taskIndex = source.indexOf("`${PDA}/tasks?loadingPlanId=${encodeURIComponent(planId)}&warehouseId=${encodeURIComponent(warehouseId)}`")
|
|
assert.ok(pushIndex >= 0 && transportIndex > pushIndex && taskIndex > transportIndex)
|
|
assert.match(source, /containerNo: realContainerNo/)
|
|
assert.match(source, /id\(task\?\.loadingPlanId\) === planId/)
|
|
assert.match(source, /id\(task\?\.containerBookingId\) === containerId/)
|
|
assert.doesNotMatch(source, /\$\{PDA\}\/tasks\?containerNo=/)
|
|
})
|
|
|
|
test('booking freezes the source customer channel and warehouse scope', () => {
|
|
assert.match(source, /customerId: source\.tenantId/)
|
|
assert.match(source, /channelCode: source\.channelCode/)
|
|
assert.match(source, /warehouseId: source\.warehouseId/)
|
|
assert.match(source, /containerRequirements: \[\{ containerType: '40HQ'/)
|
|
})
|