2026-08-26 16:50:22 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
import { parseArguments, validateExecutionOptions } from '../admin-test-env-acceptance.mjs'
|
|
|
|
|
|
|
|
|
|
const entry = readFileSync(new URL('../admin-test-env-acceptance.mjs', import.meta.url), 'utf8')
|
|
|
|
|
const fixture = readFileSync(new URL('./manual-pda-ready-fixture.mjs', import.meta.url), 'utf8')
|
|
|
|
|
const verify = readFileSync(new URL('./manual-pda-ready-verify.mjs', import.meta.url), 'utf8')
|
|
|
|
|
|
|
|
|
|
test('manual PDA-ready modules are optional and require a source report', () => {
|
|
|
|
|
assert.match(entry, /OPTIONAL_MODULES\s*=\s*\[[^\]]*'manual-pda-ready-fixture'[^\]]*'manual-pda-ready-verify'/s)
|
|
|
|
|
const defaults = parseArguments([]).modules
|
|
|
|
|
assert.equal(defaults.includes('manual-pda-ready-fixture'), false)
|
|
|
|
|
assert.equal(defaults.includes('manual-pda-ready-verify'), false)
|
|
|
|
|
for (const module of ['manual-pda-ready-fixture', 'manual-pda-ready-verify']) {
|
|
|
|
|
const options = parseArguments(['--gateway', 'http://127.0.0.1:9000', '--username', 'admin',
|
|
|
|
|
'--password', 'password-value', '--modules', module, '--manual-pda-source-report', 'source.json'])
|
2026-10-22 11:56:47 +08:00
|
|
|
assert.deepEqual(options.modules, ['merchant-qualification-fixture', module])
|
2026-08-26 16:50:22 +08:00
|
|
|
assert.equal(validateExecutionOptions(options), options)
|
|
|
|
|
assert.throws(() => validateExecutionOptions({ ...options, manualPdaSourceReport: '' }),
|
|
|
|
|
/manual-pda-source-report/)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('PDA-ready preparation is read only and proves all three prerequisites are absent', () => {
|
|
|
|
|
assert.match(fixture, /manualPreloadPushVerification/)
|
|
|
|
|
assert.match(fixture, /container\?\.containerNo == null/)
|
|
|
|
|
assert.match(fixture, /container\?\.oceanBookingId == null/)
|
|
|
|
|
assert.match(fixture, /readiness\?\.canConfirm === false/)
|
|
|
|
|
assert.match(fixture, /codeOf\(taskResponse\) === 'A0404'/)
|
|
|
|
|
assert.doesNotMatch(fixture, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('PDA-ready verifier checks release, stable link, confirmation and one unassigned task without writes', () => {
|
|
|
|
|
assert.match(verify, /oceanBooking\?\.status === 'RELEASED'/)
|
|
|
|
|
assert.match(verify, /positiveId\(allocation\?\.requirementId\)/)
|
|
|
|
|
assert.match(verify, /confirmationStatus === 'CONFIRMED'/)
|
|
|
|
|
assert.match(verify, /readyForPda === true/)
|
|
|
|
|
assert.match(verify, /workflowStatus === 'UNASSIGNED'/)
|
|
|
|
|
assert.match(verify, /processStatus === 'WAIT_SPLIT'/)
|
|
|
|
|
assert.doesNotMatch(verify, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/)
|
|
|
|
|
})
|