Files
baiyue-firstleg/scripts/admin-test-env-modules/manual-state-ocean-trucking-contract.test.mjs
T

31 lines
1.7 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('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', 'RESCHEDULED', 'EXCEPTION', 'CANCELLED']) {
assert.match(source, new RegExp(`['\"]${status}['\"]`))
}
assert.match(source, /page=1&size=100&status=/)
assert.match(source, /category=TRUCKING&status=ACTIVE/)
assert.match(source, /carrierId: id\(carrier\.id\), carrierName: carrier\.name/)
const completion = readFileSync(new URL('../../firstleg/src/main/java/com/baiyue/firstleg/service/TruckAppointmentCompletionService.java', import.meta.url), 'utf8')
const statuses = readFileSync(new URL('../../firstleg/src/main/java/com/baiyue/firstleg/domain/TruckAppointmentStatus.java', import.meta.url), 'utf8')
assert.doesNotMatch(statuses, /\bDEPARTED\b/)
assert.match(statuses, /\bCOMPLETED\b/)
assert.match(completion, /if \(!allDeparted\(rows\)\) return/)
assert.match(completion, /history\.setAction\("AUTO_COMPLETE"\)/)
assert.match(completion, /history\.setToStatus\("COMPLETED"\)/)
})