test(firstleg): package carrier node demo checks
This commit is contained in:
@@ -4,21 +4,21 @@ import path from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { currentOutboundFixture, ownsCarrierQuery } from './phase3-carrier-schedule-queries.mjs'
|
||||
import { currentOutboundFixture, ownsCarrierQuery, validContainerNo } from './phase3-carrier-schedule-queries.mjs'
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url))
|
||||
const source = fs.readFileSync(path.join(here, 'phase3-carrier-schedule-queries.mjs'), 'utf8')
|
||||
|
||||
function context(marker = 'RUN') {
|
||||
return { marker, createdResources: {
|
||||
phase3Loading: { marker, tenantId: '10001', oceanBookingId: '20001', containerBookingId: '30001', containerNo: 'TSTU1234567' },
|
||||
phase3Loading: { marker, tenantId: '10001', oceanBookingId: '20001', containerBookingId: '30001', containerNo: 'ZCSU7881970' },
|
||||
phase3OutboundDispatch: { marker, tenantId: '10001', containerBookingId: '30001', confirmedStatus: 'WAITING_FOR_LOADING' },
|
||||
} }
|
||||
}
|
||||
|
||||
test('outbound fixture requires exact current marker and matching loading/outbound container', () => {
|
||||
assert.deepEqual(currentOutboundFixture(context()), {
|
||||
marker: 'RUN', customerId: '10001', oceanBookingId: '20001', containerBookingId: '30001', trackingNo: 'TSTU1234567',
|
||||
marker: 'RUN', customerId: '10001', oceanBookingId: '20001', containerBookingId: '30001', trackingNo: 'ZCSU7881970',
|
||||
})
|
||||
const old = context(); old.createdResources.phase3OutboundDispatch.marker = 'OLD'
|
||||
assert.equal(currentOutboundFixture(old), null)
|
||||
@@ -26,6 +26,13 @@ test('outbound fixture requires exact current marker and matching loading/outbou
|
||||
assert.equal(currentOutboundFixture(mismatch), null)
|
||||
})
|
||||
|
||||
test('carrier fixture only accepts normalized ISO 6346 physical container numbers', () => {
|
||||
assert.equal(validContainerNo('ZCSU7881970'), true)
|
||||
assert.equal(validContainerNo('zcsu7881970'), false)
|
||||
assert.equal(validContainerNo('ZCSU7881971'), false)
|
||||
assert.equal(validContainerNo('CAB-260901-0001'), false)
|
||||
})
|
||||
|
||||
test('carrier query ownership requires explicit outbound-confirm marker registration', () => {
|
||||
assert.equal(ownsCarrierQuery({ queryId: '1', marker: 'RUN', ownedByModule: true,
|
||||
triggerSource: 'OUTBOUND_CONFIRM' }, 'RUN'), true)
|
||||
@@ -41,6 +48,8 @@ test('phase3 script only discovers the current outbound task and blocks missing
|
||||
assert.match(source, /缺少本轮phase3出仓fixture,禁止借历史Query验收/)
|
||||
assert.match(source, /deploymentBlocker:\s*true/)
|
||||
assert.match(source, /triggerSource === 'OUTBOUND_CONFIRM'/)
|
||||
assert.match(source, /trackingType === 'CONTAINER_NO'/)
|
||||
assert.match(source, /validContainerNo\(task\?\.trackingNo\)/)
|
||||
assert.match(source, /DEPARTED_WAREHOUSE/)
|
||||
assert.match(source, /providerEventId/)
|
||||
assert.match(source, /\^\\d\{16,/)
|
||||
|
||||
Reference in New Issue
Block a user