test: release split bookings before pda
This commit is contained in:
@@ -4,12 +4,21 @@ import test from 'node:test'
|
||||
|
||||
const source = readFileSync(new URL('./phase3-order-splitting.mjs', import.meta.url), 'utf8')
|
||||
|
||||
test('each remainder uses a simulation explicitly linked to a confirmed booking', () => {
|
||||
test('each remainder uses a simulation linked to a confirmed then released booking', () => {
|
||||
assert.match(source, /POST', CONTAINERS/)
|
||||
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, /ocean-booking-link/)
|
||||
assert.match(source, /bookingDetail\.oceanBooking\.status === 'CONFIRMED'/)
|
||||
assert.match(source, /`\$\{bookingPath\}\/release`/)
|
||||
const releaseStart = source.indexOf('const releaseResponse')
|
||||
const releaseBlock = source.slice(releaseStart, source.indexOf('bookingDetailResponse = await', releaseStart))
|
||||
for (const field of ['billOfLadingNo', 'vesselName', 'voyageNo', 'estimatedSailingAt',
|
||||
'estimatedArrivalAt', 'expectedVersion']) assert.match(releaseBlock, new RegExp(`${field}:`))
|
||||
assert.match(releaseBlock, /'Idempotency-Key': `\$\{operationBase\}-booking-release`\.slice\(0, 128\)/)
|
||||
assert.match(source, /oceanBooking\?\.status === 'RELEASED' && releasedAllocationMatches/)
|
||||
assert.match(source, /id\(item\?\.containerBookingId\) === containerId/)
|
||||
assert.match(source, /candidates\?bookingId=\$\{encodeURIComponent\(containerId\)\}&warehouseId=\$\{encodeURIComponent\(warehouseId\)\}/)
|
||||
assert.match(source, /`\$\{SMART\}\/plans`, \{ bookingId: containerId/)
|
||||
assert.doesNotMatch(source, /candidates\?warehouseId=/)
|
||||
@@ -18,8 +27,9 @@ test('each remainder uses a simulation explicitly linked to a confirmed booking'
|
||||
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 releaseIndex = source.indexOf("`${bookingPath}/release`")
|
||||
const taskIndex = source.indexOf("`${PDA}/tasks?loadingPlanId=${encodeURIComponent(planId)}&warehouseId=${encodeURIComponent(warehouseId)}`")
|
||||
assert.ok(transportIndex >= 0 && pushIndex > transportIndex && taskIndex > pushIndex)
|
||||
assert.ok(transportIndex >= 0 && releaseIndex > transportIndex && pushIndex > releaseIndex && taskIndex > pushIndex)
|
||||
assert.match(source, /containerNo: realContainerNo/)
|
||||
assert.match(source, /const transportStable = transported\?\.containerNo === realContainerNo/)
|
||||
assert.match(source, /transported\?\.cabinetNo === simulation\.cabinetNo/)
|
||||
|
||||
Reference in New Issue
Block a user