优化
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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-order-splitting-fixture.mjs', import.meta.url), 'utf8')
|
||||
const verify = readFileSync(new URL('./manual-order-splitting-verify.mjs', import.meta.url), 'utf8')
|
||||
|
||||
test('manual splitting modules are optional registered entries with a WAIT_SPLIT producer dependency', () => {
|
||||
assert.match(entry, /OPTIONAL_MODULES\s*=\s*\[[^\]]*'manual-order-splitting-fixture'[^\]]*'manual-order-splitting-verify'/s)
|
||||
assert.match(entry, /\['manual-order-splitting-fixture', \['inbound-measurement'\]\]/)
|
||||
assert.match(entry, /--manual-split-fixture-report/)
|
||||
assert.match(entry, /--manual-split-plan-id/)
|
||||
assert.match(entry, /manual-order-splitting-fixture[^\n]+waitSplitCount < 4/)
|
||||
})
|
||||
|
||||
test('fixture defaults to six orders while verifier requires an explicit report and plan id', () => {
|
||||
const defaultModules = parseArguments([]).modules
|
||||
assert.equal(defaultModules.includes('manual-order-splitting-fixture'), false)
|
||||
assert.equal(defaultModules.includes('manual-order-splitting-verify'), false)
|
||||
const fixtureOptions = parseArguments([
|
||||
'--gateway', 'http://127.0.0.1:9000', '--username', 'admin', '--password', 'password-value',
|
||||
'--modules', 'manual-order-splitting-fixture',
|
||||
])
|
||||
assert.deepEqual(fixtureOptions.modules, [
|
||||
'merchant-qualification-fixture', 'orders', 'inbound-measurement', 'manual-order-splitting-fixture',
|
||||
])
|
||||
assert.equal(fixtureOptions.waitSplitCount, 6)
|
||||
assert.equal(validateExecutionOptions(fixtureOptions), fixtureOptions)
|
||||
|
||||
const verifyOptions = parseArguments([
|
||||
'--gateway', 'http://127.0.0.1:9000', '--username', 'admin', '--password', 'password-value',
|
||||
'--modules', 'manual-order-splitting-verify', '--manual-split-fixture-report', 'fixture.json',
|
||||
'--manual-split-plan-id', '123',
|
||||
])
|
||||
assert.deepEqual(verifyOptions.modules, ['manual-order-splitting-verify'])
|
||||
assert.equal(validateExecutionOptions(verifyOptions), verifyOptions)
|
||||
assert.throws(() => validateExecutionOptions({ ...verifyOptions, manualSplitPlanId: '' }),
|
||||
/manual-split-plan-id/)
|
||||
assert.throws(() => validateExecutionOptions({ ...fixtureOptions, waitSplitCount: 3 }),
|
||||
/wait-split-count至少为4/)
|
||||
})
|
||||
|
||||
test('fixture prepares a partial, two full and one untouched scenario without performing split writes', () => {
|
||||
assert.match(fixture, /role: 'PARTIAL'/)
|
||||
assert.match(fixture, /role: `FULL_\$\{index \+ 1\}`/)
|
||||
assert.match(fixture, /role: 'UNASSIGNED_CONTROL'/)
|
||||
assert.match(fixture, /WAIT_SPLIT_READY_FOR_MANUAL_ASSIGNMENT/)
|
||||
assert.doesNotMatch(fixture, /context\.request\(['"]POST/)
|
||||
})
|
||||
|
||||
test('verifier is read only and checks plan, container, allocations and remaining candidates', () => {
|
||||
assert.match(verify, /context\.request\('GET', `\$\{SMART\}\/plans/)
|
||||
assert.match(verify, /context\.request\('GET', `\$\{CONTAINERS\}/)
|
||||
assert.match(verify, /inbound-candidates\?bookingId=/)
|
||||
assert.match(verify, /sourceGateway[\s\S]*sameGateway/)
|
||||
assert.match(verify, /候选列表未出现异渠道或异仓入库单/)
|
||||
assert.match(verify, /expectedAllocatedPackageCount/)
|
||||
assert.match(verify, /expectedRemainingPackageCount/)
|
||||
assert.doesNotMatch(verify, /context\.request\(['"](?:POST|PATCH|PUT|DELETE)/)
|
||||
})
|
||||
Reference in New Issue
Block a user