This commit is contained in:
2026-10-27 17:44:41 +08:00
parent 57cd211973
commit db0e72daeb
37 changed files with 701 additions and 671 deletions
+19 -3
View File
@@ -6,13 +6,16 @@ import { join, dirname, resolve, basename } from 'node:path'
import { parseGrayPoolArguments, runGrayPoolAcceptance } from './fleet-capacity-pool-gray.mjs'
import { parseCrossCustomerArguments, runCrossCustomer, runFleetPoolGrayCrossCustomer } from './fleet-cross-customer-test-env.mjs'
import { parsePoolArguments, runPoolAcceptance, poolReportName, POOL_COVERAGE } from './fleet-capacity-pool-test-env.mjs'
import { AcceptanceRun, parseArguments, validateExecutionOptions, createFleetPoolGrayOptions } from './admin-test-env-acceptance.mjs'
import { AcceptanceRun, parseArguments, validateExecutionOptions, createFleetPoolGrayOptions, grayFixedCustomerOptions } from './admin-test-env-acceptance.mjs'
const args = ['--execute', '--environment', 'GRAY', '--run-id', 'pool-gray-offline', '--warehouse-id', '900', '--destination-warehouse-id', '901']
const env = { CHONGCHONG_ENV: 'prod', CHONGCHONG_ADMIN_API_BASE_URL: 'https://gray.example.invalid/api',
CHONGCHONG_ADMIN_USERNAME: 'offline-user', CHONGCHONG_ADMIN_PASSWORD: 'offline-secret' }
CHONGCHONG_ADMIN_USERNAME: 'offline-user', CHONGCHONG_ADMIN_PASSWORD: 'offline-secret',
CHONGCHONG_ACCEPTANCE_CUSTOMER_ID: '100', CHONGCHONG_MERCHANT_USERNAME: 'existing-a', CHONGCHONG_MERCHANT_PASSWORD: 'offline-a',
CHONGCHONG_ACCEPTANCE_SECONDARY_CUSTOMER_ID: '101', CHONGCHONG_SECONDARY_MERCHANT_USERNAME: 'existing-b', CHONGCHONG_SECONDARY_MERCHANT_PASSWORD: 'offline-b',
CHONGCHONG_ACCEPTANCE_FLEET_RESOURCES: '[{"vehicleId":"501","driverId":"502"}]' }
const transport = { gateway: 'https://gray.example.invalid', username: 'offline-user', password: 'offline-secret',
output: 'reports/fleet-pool-gray-offline', markerNamespace: 'gray-offline' }
output: 'reports/fleet-pool-gray-offline', markerNamespace: 'gray-offline', ...grayFixedCustomerOptions(env) }
test('GRAY plan is zero-network and preserves exact existing pool coverage without F40', async () => {
const original = globalThis.fetch; globalThis.fetch = () => assert.fail('network forbidden')
@@ -53,6 +56,9 @@ test('dedicated constructor factory is branded frozen gray and carries no generi
assert.equal(options.executionScope, 'FLEET_CAPACITY_POOL_GRAY')
assert.deepEqual(options.modules, []); assert.deepEqual(options.requestedModules, [])
assert.equal(options.verifyUnloadEventRecovery, false)
assert.equal(options.fixedCustomerId, '100'); assert.equal(options.fixedSecondaryCustomer.customerId, '101')
assert.ok(Object.isFrozen(options.fixedSecondaryCustomer))
assert.deepEqual(context.options.fixedFleetResources, [{ vehicleId: '501', driverId: '502' }])
assert.throws(() => options.modules.push('phase5-root-fulfillment'), TypeError)
assert.throws(() => new AcceptanceRun({ ...options }), /gray 仅支持/)
assert.throws(() => createFleetPoolGrayOptions({ ...transport, modules: ['phase5-root-fulfillment'] }), /configuration/)
@@ -61,6 +67,16 @@ test('dedicated constructor factory is branded frozen gray and carries no generi
assert.throws(() => createFleetPoolGrayOptions({ ...transport, gateway: 'https://gray.example.invalid/api' }), /HTTPS/)
})
test('gray pool missing either existing customer or using the same customer stops before evidence, files or HTTP', async () => {
const config = parseGrayPoolArguments(args)
for (const key of ['CHONGCHONG_ACCEPTANCE_CUSTOMER_ID', 'CHONGCHONG_MERCHANT_PASSWORD',
'CHONGCHONG_ACCEPTANCE_SECONDARY_CUSTOMER_ID', 'CHONGCHONG_SECONDARY_MERCHANT_PASSWORD']) {
const bad = { ...env }; delete bad[key]
await assert.rejects(runFleetPoolGrayCrossCustomer(config, { env: bad, verify: () => assert.fail('no verify'), contextFactory: () => assert.fail('no context') }), /固定客户|第二个客户|GRAY 必须配置/)
}
assert.throws(() => grayFixedCustomerOptions({ ...env, CHONGCHONG_ACCEPTANCE_SECONDARY_CUSTOMER_ID: 'TEN100' }), /必须不同/)
})
test('ordinary Admin gray CLI and string-forged scope cannot opt into dedicated empty modules', () => {
assert.throws(() => validateExecutionOptions({ environment: 'gray', executionScope: 'FLEET_CAPACITY_POOL_GRAY',
requestedModules: [], modules: [], waitSplitCount: 1 }), /gray 仅支持/)