完成单机TEST统一入口与可靠投递回归收尾

This commit is contained in:
2026-09-29 19:48:34 +08:00
parent 64a70c9f28
commit 6c0a026cc4
89 changed files with 968 additions and 983 deletions
@@ -42,28 +42,11 @@ function fixture() {
},
phase4OverseasPda: { customerId: '2001', overseasWarehouseId: '9001' },
},
async request(method, path, body) {
calls.push({ region: 'CN', method, path, body })
if (path === '/api/platform/v1/iam/tenants?page=1&size=200&status=ACTIVE') {
return response({ records: [{ id: '1001', tenantName: '客户一' }, { id: '1002', tenantName: '客户二' }] })
}
if (path === '/internal/event-bridge/status') return response(null, '200', 200, 'CN')
if (path.startsWith('/api/platform/finance/v1/fee-sources?')) {
const query = new URLSearchParams(path.split('?')[1])
const customerId = query.get('customerId')
const keyword = query.get('keyword')
const rows = [...fees.values()].filter((fee) => fee.customerId === customerId
&& (fee.inboundCode || fee.businessNo) === keyword)
.filter((fee) => fee.reviewStatus === 'APPROVED')
.map((fee) => ({ feeSourceId: String(Number(fee.sourceFeeId) + 10000), sourceSystem: 'LASTLEG',
sourceType: fee.sourceType, sourceFeeId: fee.sourceFeeId, customerId: fee.customerId }))
return response(rows)
}
throw new Error(`unexpected CN request ${method} ${path}`)
},
async requestOverseas(method, path, body, headers = {}) {
async request(...args) {
const route = /\/(?:last-leg|overseas-warehouse-resources)(?:\/|\?|$)/.test(String(args[1]));
const handler = route ? async function(method,path,body,_token,headers = {}) {
calls.push({ region: 'OVERSEAS', method, path, body, headers })
if (path === '/internal/event-bridge/status') return response(null, '200', 200, 'OVERSEAS')
if (path === '/internal/finance/event-operations/outbox') return response(null, '404', 404, 'OVERSEAS')
for (const [base, row] of Object.entries(businessRows)) {
if (method === 'GET' && path.startsWith(`${base}?`)) return response({ records: [row] })
}
@@ -101,7 +84,28 @@ function fixture() {
return response(fee)
}
throw new Error(`unexpected OVERSEAS request ${method} ${path}`)
},
} : async function(method,path,body) {
calls.push({ region: 'CN', method, path, body })
if (path === '/api/platform/v1/iam/tenants?page=1&size=200&status=ACTIVE') {
return response({ records: [{ id: '1001', tenantName: '客户一' }, { id: '1002', tenantName: '客户二' }] })
}
if (path === '/internal/finance/event-operations/outbox') return response(null, '404', 404, 'CN')
if (path.startsWith('/api/platform/finance/v1/fee-sources?')) {
const query = new URLSearchParams(path.split('?')[1])
const customerId = query.get('customerId')
const keyword = query.get('keyword')
const rows = [...fees.values()].filter((fee) => fee.customerId === customerId
&& (fee.inboundCode || fee.businessNo) === keyword)
.filter((fee) => fee.reviewStatus === 'APPROVED')
.map((fee) => ({ feeSourceId: String(Number(fee.sourceFeeId) + 10000), sourceSystem: 'LASTLEG',
sourceType: fee.sourceType, sourceFeeId: fee.sourceFeeId, customerId: fee.customerId }))
return response(rows)
}
throw new Error(`unexpected CN request ${method} ${path}`)
};
return handler.apply(this,args);
},
apiSuccess(module, name, result, evidence, options) {
const passed = result.http === 200 && String(result.body?.code) === '200'
this.addStep(module, name, result, passed, evidence, options)
@@ -126,7 +130,7 @@ test('module uses only injected real HTTP clients and never fabricates database/
'OVERSEAS_INBOUND_FEE', 'OVERSEAS_PROCUREMENT_FEE', 'OVERSEAS_TRUCK_FEE',
'OVERSEAS_LOOSEBOARD_FEE', 'OVERSEAS_WAREHOUSE_FEE',
'/api/platform/v1/last-leg/finance-fee-sources', '/api/platform/finance/v1/fee-sources',
'/internal/event-bridge/status',
'/internal/finance/event-operations/outbox',
]) assert.ok(source.includes(token), token)
})
@@ -163,10 +167,9 @@ test('five fee types traverse Lastleg lifecycle and reach Finance through real H
assert.ok(context.steps.find((step) => step.name === '费用创建同键异载荷冲突')?.passed)
assert.ok(context.steps.find((step) => step.name === '海外费用列表不会泄露其他客户来源')?.passed)
assert.ok(context.steps.find((step) => step.name === '其他客户不能关联本客户业务创建费用')?.passed)
assert.equal(context.steps.filter((step) => step.name.endsWith('费用经跨区链进入 Finance')).length, 5)
assert.ok(context.steps.filter((step) => step.name.endsWith('费用经跨区链进入 Finance')).every((step) => step.passed))
assert.ok(context.steps.find((step) => step.name === '国内 Event Bridge HTTP 能力状态可观察')?.passed)
assert.ok(context.steps.find((step) => step.name === '海外 Event Bridge HTTP 能力状态可观察')?.passed)
assert.equal(context.steps.filter((step) => step.name.endsWith('费用经业务Outbox直接投递进入 Finance')).length, 5)
assert.ok(context.steps.filter((step) => step.name.endsWith('费用经业务Outbox直接投递进入 Finance')).every((step) => step.passed))
assert.ok(context.steps.find((step) => step.name === '统一Gateway不公开内部事件运维接口')?.passed)
assert.deepEqual(context.steps.filter((step) => !step.passed), [])
assert.equal(context.scenarios[0].deploymentBlocked, false)