Files
baiyue-firstleg/scripts/admin-test-env-modules/manual-state-loading-pda-contract.test.mjs
T
2026-08-13 09:49:55 +08:00

44 lines
2.2 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-loading-pda.mjs', import.meta.url), 'utf8')
test('retains all clickable container, loading-list and PDA workflow states through public APIs', () => {
for (const status of ['WAIT_LOADING', 'EDITING', 'LOADING', 'COMPLETED',
'UNASSIGNED', 'IN_PROGRESS', 'AWAITING_REVIEW']) assert.match(source, new RegExp(`['"]${status}['"]`))
for (const endpoint of ['/ocean-bookings', '/smart-loading', '/push-preload', '/inventory-snapshot',
'/batch', '/complete', '/loading-plans', '/loading-lists']) assert.match(source, new RegExp(endpoint))
assert.match(source, /requiredStatuses/)
assert.match(source, /detailPath/)
assert.match(source, /loading-plans\/\$\{fixture\.id\}/)
assert.match(source, /loading-lists\/\$\{listFixture\.id\}/)
assert.match(source, /prepareInbound/)
assert.match(source, /\.\/orders\.mjs/)
assert.match(source, /\.\/inbound-measurement\.mjs/)
})
test('does not mutate historical fixtures or remove retained records', () => {
assert.doesNotMatch(source, /\bDELETE\b/)
assert.doesNotMatch(source, /createdResources\?\.phase3ContainerLoading/)
assert.doesNotMatch(source, /orchestrationFixtures\?\./)
assert.match(source, /fixtureMarker/)
assert.match(source, /context\.marker = originalMarker/)
})
test('covers simplified clearance and customs actions through public multipart upload and complete APIs', () => {
assert.match(source, /new FormData\(\)/)
assert.match(source, /form\.append\('file'/)
assert.match(source, /form\.append\('expectedVersion'/)
assert.match(source, /form\.append\('operationReason'/)
assert.match(source, /'Idempotency-Key'/)
assert.match(source, /clearancePath\}\/document\/upload/)
assert.match(source, /clearancePath\}\/complete/)
assert.match(source, /customsPath\}\/document\/upload\?\$\{warehouse\}/)
assert.match(source, /customsPath\}\/complete\?\$\{warehouse\}/)
assert.match(source, /matrix\.pages\.containerLoading\.actions/)
assert.match(source, /matrix\.pages\.loadingLists\.actions/)
assert.doesNotMatch(source, /internal\/file|business-files/)
assert.doesNotMatch(source, /\{\s*fileId\s*:/)
})