42 lines
2.3 KiB
JavaScript
42 lines
2.3 KiB
JavaScript
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-preload-push-fixture.mjs', import.meta.url), 'utf8')
|
||
|
|
const verify = readFileSync(new URL('./manual-preload-push-verify.mjs', import.meta.url), 'utf8')
|
||
|
|
|
||
|
|
test('manual preload modules are optional and require an explicit source report', () => {
|
||
|
|
assert.match(entry, /OPTIONAL_MODULES\s*=\s*\[[^\]]*'manual-preload-push-fixture'[^\]]*'manual-preload-push-verify'/s)
|
||
|
|
const defaults = parseArguments([]).modules
|
||
|
|
assert.equal(defaults.includes('manual-preload-push-fixture'), false)
|
||
|
|
assert.equal(defaults.includes('manual-preload-push-verify'), false)
|
||
|
|
for (const module of ['manual-preload-push-fixture', 'manual-preload-push-verify']) {
|
||
|
|
const options = parseArguments(['--gateway', 'http://127.0.0.1:9000', '--username', 'admin',
|
||
|
|
'--password', 'password-value', '--modules', module, '--manual-preload-source-report', 'source.json'])
|
||
|
|
assert.deepEqual(options.modules, [module])
|
||
|
|
assert.equal(validateExecutionOptions(options), options)
|
||
|
|
assert.throws(() => validateExecutionOptions({ ...options, manualPreloadSourceReport: '' }),
|
||
|
|
/manual-preload-source-report/)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
test('preload preparation is read only and freezes the pre-push plan snapshot', () => {
|
||
|
|
assert.match(fixture, /manualOrderSplittingVerification/)
|
||
|
|
assert.match(fixture, /beforePlanVersion/)
|
||
|
|
assert.match(fixture, /beforeItems/)
|
||
|
|
assert.match(fixture, /未点击推送前不存在预装 bridge/)
|
||
|
|
assert.doesNotMatch(fixture, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('post-push verifier proves EDITING bridge visibility and PDA A0404 without writes', () => {
|
||
|
|
assert.match(verify, /Number\(plan\?\.version\) > Number\(fixture\.beforePlanVersion\)/)
|
||
|
|
assert.match(verify, /allocatedPackageCount/)
|
||
|
|
assert.match(verify, /preloadStatus === 'PENDING'/)
|
||
|
|
assert.match(verify, /readiness\?\.canConfirm === false/)
|
||
|
|
assert.match(verify, /codeOf\(taskResponse\) === 'A0404'/)
|
||
|
|
assert.match(verify, /container\?\.containerNo == null/)
|
||
|
|
assert.doesNotMatch(verify, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/)
|
||
|
|
})
|