30 lines
1.8 KiB
JavaScript
30 lines
1.8 KiB
JavaScript
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 every ocean booking and truck appointment list status through real APIs', () => {
|
|
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 ['DRAFT','SUBMITTED','CONFIRMED','RELEASED','FAILED','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/)
|
|
const draftPayload = source.slice(source.indexOf('function oceanPayload'), source.indexOf('async function createOcean'))
|
|
for (const field of ['billOfLadingNo', 'vesselName', 'voyageNo', 'estimatedSailingAt', 'estimatedArrivalAt']) {
|
|
assert.doesNotMatch(draftPayload, new RegExp(`${field}:`))
|
|
}
|
|
const lifecycle = source.slice(source.indexOf('async function buildOcean'), source.indexOf('function truckPayload'))
|
|
for (const field of ['billOfLadingNo', 'vesselName', 'voyageNo', 'estimatedSailingAt', 'estimatedArrivalAt']) {
|
|
assert.match(lifecycle, new RegExp(`${field}:`))
|
|
}
|
|
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.doesNotMatch(source, /DELETE/)
|
|
})
|