fix: complete single-order acceptance and add Lingxing WMS integration
This commit is contained in:
@@ -3,9 +3,8 @@ import assert from 'node:assert/strict'
|
||||
import { plan, config, assertCustomer, allowedRequest, client, listAll, preflight, main, DOMESTIC_WAREHOUSE_CODES } from './prod-release-acceptance.mjs'
|
||||
|
||||
function environment() {
|
||||
const env = { CHONGCHONG_ENV: 'prod',
|
||||
const env = { CHONGCHONG_ENV: 'gray',
|
||||
CHONGCHONG_ADMIN_API_BASE_URL: 'https://acceptance.invalid/api',
|
||||
CHONGCHONG_ADMIN_OVERSEAS_API_BASE_URL: 'https://acceptance.invalid/overseas-api',
|
||||
CHONGCHONG_MERCHANT_API_BASE_URL: 'https://acceptance.invalid/api',
|
||||
CHONGCHONG_ACCEPTANCE_CUSTOMER_ID: '9007199254740993',
|
||||
CHONGCHONG_ACCEPTANCE_CUSTOMER_CODE: 'fixture', CHONGCHONG_ACCEPTANCE_CUSTOMER_NAME: 'fixture',
|
||||
@@ -25,8 +24,8 @@ test('single order scope does not claim implemented or full coverage', () => {
|
||||
assert.deepEqual(result.scope.origins, [...DOMESTIC_WAREHOUSE_CODES])
|
||||
assert.equal(result.scope.receiving, 'US-LAX-01')
|
||||
assert.equal(result.fullFlowVerified, false)
|
||||
assert.equal(result.stages.filter(s => s.status === 'IMPLEMENTED_NOT_HTTP_VERIFIED').length, 2)
|
||||
assert.equal(result.stages.filter(s => s.status === 'NOT_IMPLEMENTED').length, 12)
|
||||
assert.equal(result.stages.filter(s => s.status === 'IMPLEMENTED_NOT_HTTP_VERIFIED').length, 14)
|
||||
assert.equal(result.stages.filter(s => s.status === 'NOT_IMPLEMENTED').length, 0)
|
||||
})
|
||||
test('configuration has no development/test fallback', () => {
|
||||
assert.throws(() => config({ ADMIN_TEST_GATEWAY: 'https://acceptance.invalid' }))
|
||||
@@ -85,7 +84,7 @@ function fakeHttp(bindingId = '3') {
|
||||
return { requests: 0, async request(region, method, path) {
|
||||
this.requests++
|
||||
assert.equal(allowedRequest(method, path, region), true)
|
||||
if (method === 'POST') return { accessToken: 'fixture-token', overseasAccessToken: 'fixture-overseas-token' }
|
||||
if (method === 'POST') return { accessToken: 'fixture-token' }
|
||||
if (path.includes('/iam/')) return profile
|
||||
if (path.includes('/warehouse-profile')) return { warehouseId: bindingId, warehouseCode: 'US-LAX-01' }
|
||||
if (path.endsWith('/pda-loading/warehouses')) return [{ id: '2', warehouseCode: 'CN-YIWU-01' }, { id: '4', warehouseCode: 'CN-DONGGUAN-01' }]
|
||||
@@ -110,6 +109,39 @@ test('PDA warehouse mismatch blocks preflight', async () => {
|
||||
})
|
||||
test('execute, resume and unrecognized arguments fail closed', async () => {
|
||||
for (const args of [['execute'], ['resume'], ['preflight', '--execute'], ['plan', '--count', '2']]) {
|
||||
await assert.rejects(main(args, {}), /尚未开放/)
|
||||
await assert.rejects(main(args, {}), /完整链使用/)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
test('explicit gray/test mode shares one API base and rejects retired environment keys', () => {
|
||||
for (const mode of ['gray', 'test']) {
|
||||
const settings = config({ ...environment(), CHONGCHONG_ENV: mode })
|
||||
assert.equal(settings.environment, mode)
|
||||
assert.equal(settings.apiBase, 'https://acceptance.invalid/api')
|
||||
assert.equal(settings.overseas, undefined)
|
||||
}
|
||||
for (const mode of ['prod', 'dev', '', undefined]) {
|
||||
assert.throws(() => config({ ...environment(), CHONGCHONG_ENV: mode }), /显式配置/)
|
||||
}
|
||||
for (const key of ['CHONGCHONG_ADMIN_OVERSEAS_API_BASE_URL', 'CHONGCHONG_MERCHANT_OVERSEAS_API_BASE_URL']) {
|
||||
assert.throws(() => config({ ...environment(), [key]: 'https://acceptance.invalid/api' }), /旧海外网关/)
|
||||
}
|
||||
})
|
||||
|
||||
test('overseas PDA calls the unified gateway using its ordinary access token', async () => {
|
||||
const calls = []
|
||||
const http = client(config(environment()), async (url, options) => {
|
||||
calls.push({ url, token: options.headers.Authorization })
|
||||
return { ok: true, status: 200, json: async () => ({ code: '200', data: {} }) }
|
||||
})
|
||||
await http.request('overseas', 'GET', '/pda/v1/last-leg/receiving-containers/warehouse-profile', 'ordinary-access')
|
||||
assert.deepEqual(calls, [{ url: 'https://acceptance.invalid/api/pda/v1/last-leg/receiving-containers/warehouse-profile', token: 'Bearer ordinary-access' }])
|
||||
})
|
||||
|
||||
test('unapproved customer blocks preflight before any business stage', async () => {
|
||||
const http = fakeHttp(), original = http.request.bind(http)
|
||||
http.request = async (...args) => args[2].includes('/iam/')
|
||||
? { ...profile, status: 'PROFILE_REQUIRED' } : original(...args)
|
||||
await assert.rejects(preflight(config(environment()), http), /审核状态/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user