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-loading-complete-fixture.mjs', import.meta.url), 'utf8') const verify = readFileSync(new URL('./manual-loading-complete-verify.mjs', import.meta.url), 'utf8') test('manual loading-complete modules are optional and require a source report', () => { assert.match(entry, /OPTIONAL_MODULES\s*=\s*\[[^\]]*'manual-loading-complete-fixture'[^\]]*'manual-loading-complete-verify'/s) const defaults = parseArguments([]).modules assert.equal(defaults.includes('manual-loading-complete-fixture'), false) assert.equal(defaults.includes('manual-loading-complete-verify'), false) for (const module of ['manual-loading-complete-fixture', 'manual-loading-complete-verify']) { const options = parseArguments(['--gateway', 'http://127.0.0.1:9000', '--username', 'admin', '--password', 'password-value', '--modules', module, '--manual-loading-complete-source-report', 'source.json']) assert.deepEqual(options.modules, ['merchant-qualification-fixture', module]) assert.equal(validateExecutionOptions(options), options) assert.throws(() => validateExecutionOptions({ ...options, manualLoadingCompleteSourceReport: '' }), /manual-loading-complete-source-report/) } }) test('completion preparation is read only and freezes evidence, task, plan and booking gates', () => { assert.match(fixture, /manualPdaBatchVerification/) assert.match(fixture, /PHOTO_STEP_1.*PHOTO_STEP_2.*PHOTO_STEP_3.*PHOTO_STEP_4.*SEAL/) assert.match(fixture, /activeEvidence\.length === 0/) assert.match(fixture, /finalCompletionStatus === 'IN_PROGRESS'/) assert.match(fixture, /oceanBooking\?\.status === 'RELEASED'/) assert.doesNotMatch(fixture, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/) }) test('completion verifier proves five images, one completion audit and LOADED projections without writes', () => { assert.match(verify, /task\?\.taskStatus === 'COMPLETED'/) assert.match(verify, /activeEvidence\.length === fixture\.requiredEvidenceTypes\.length/) assert.match(verify, /controlledImage\(download\)/) assert.match(verify, /completeOperations\.length === 1/) assert.match(verify, /plan\?\.status === 'COMPLETED'/) assert.match(verify, /processStatus === 'LOADED'/) assert.match(verify, /mainStatus === 'LOADED'/) assert.match(verify, /splitRole === 'LOADED'/) assert.doesNotMatch(verify, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/) })