完成单机TEST统一入口与可靠投递回归收尾
This commit is contained in:
@@ -22,7 +22,7 @@ function context(resources = {}) {
|
||||
const gaps = []
|
||||
const calls = []
|
||||
return {
|
||||
marker: 'MARKER-1', token: 'domestic-token', overseasToken: 'overseas-token',
|
||||
marker: 'MARKER-1', token: 'platform-token',
|
||||
createdResources: resources, steps, gaps, calls,
|
||||
addCoverageGap(module, scenario, name, reason, category, metadata) {
|
||||
gaps.push({ module, scenario, name, reason, category, ...metadata })
|
||||
@@ -34,24 +34,28 @@ function context(resources = {}) {
|
||||
assert(module, name, value, passed, evidence, options) {
|
||||
return this.addStep(module, name, value, passed, evidence, options)
|
||||
},
|
||||
async requestOverseas(method, path, body, headers, token) {
|
||||
calls.push({ region: 'OVERSEAS', method, path, token: token || this.overseasToken })
|
||||
if (token === this.token) return response(path, null, 403, 'A0403')
|
||||
|
||||
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, token: token || this.token })
|
||||
if (token === '') return response(path, null, 401, 'A0401')
|
||||
if (path.includes('/last-leg/orders/9001')) {
|
||||
return response(path, { order: { id: '9001', containerNo: 'MSCU1234567' } })
|
||||
}
|
||||
return response(path, { records: [{ id: '7001', containerNo: 'MSCU1234567' }] })
|
||||
},
|
||||
async request(method, path, body, token) {
|
||||
} : async function(method,path,body,token) {
|
||||
calls.push({ region: 'CN', method, path, token: token || this.token })
|
||||
if (token === this.overseasToken) return response(path, null, 403, 'A0403')
|
||||
if (token === '') return response(path, null, 401, 'A0401')
|
||||
if (path.includes('/overview')) return response(path, { container: {
|
||||
id: '3001', containerNo: 'MSCU1234567', unloadingCompletedAt: '2026-08-24T10:00:00Z',
|
||||
unloadingPhotoUploadedAt: '2026-08-24T09:00:00Z', estimatedEmptyReportedAt: '2026-08-27T10:00:00Z',
|
||||
actualEmptyReportedAt: null, emptyReportSourceVersion: 7,
|
||||
} })
|
||||
return response(path, { records: [{ container: { id: '3001', containerNo: 'MSCU1234567' } }] })
|
||||
},
|
||||
};
|
||||
return handler.apply(this,args);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +114,11 @@ test('tail controls receive their own completed producer matrix before they cons
|
||||
assert.match(entry, /await this\.ensurePhase4PdaProducerMatrix\(\)/)
|
||||
})
|
||||
|
||||
test('contract covers dual audience, canonical 403, both event directions and diagnostics', () => {
|
||||
test('contract covers unified session, canonical 403, both event directions and diagnostics', () => {
|
||||
for (const token of [
|
||||
'context.token)', 'context.overseasToken)', 'cn-overseas-event-not-delivered',
|
||||
'无会话不得访问Lastleg', '同一平台会话可访问国内授权详情', 'cn-overseas-event-not-delivered',
|
||||
'overseas-cn-event-not-delivered', 'requestId=', 'traceId=', 'pollRequests=',
|
||||
'装柜完成事件重试保持建单幂等', '海外柜完成事件重试保持回写幂等',
|
||||
'非事件重放证据', 'missing-direct-delivery-replay-evidence',
|
||||
]) assert.ok(source.includes(token), token)
|
||||
assert.match(system, /缺少canonical海外订单权限必须403/)
|
||||
assert.match(system, /restrictedOverseasToken/)
|
||||
@@ -127,13 +131,14 @@ test('full observable cross-region flow performs requests and passes', async ()
|
||||
phase4OverseasPda: { marker: 'MARKER-1', finalStatus: 'COMPLETED', customerId: '100', orderId: '9001' },
|
||||
})
|
||||
|
||||
await run(ctx)
|
||||
await assert.rejects(() => run(ctx), /missing|真实投递重试与同事件幂等证据/)
|
||||
|
||||
assert.ok(ctx.calls.length >= 8)
|
||||
assert.equal(ctx.steps.every((step) => step.passed), true)
|
||||
assert.equal(ctx.gaps.length, 0)
|
||||
assert.ok(ctx.calls.some((call) => call.region === 'CN' && call.token === 'overseas-token'))
|
||||
assert.ok(ctx.calls.some((call) => call.region === 'OVERSEAS' && call.token === 'domestic-token'))
|
||||
assert.equal(ctx.steps.filter((step) => !step.name.includes('真实投递')).every((step) => step.passed), true)
|
||||
assert.equal(ctx.gaps.length, 1)
|
||||
assert.equal(ctx.gaps[0].category, 'missing-direct-delivery-replay-evidence')
|
||||
assert.ok(ctx.calls.some((call) => call.region === 'CN' && call.token === 'platform-token'))
|
||||
assert.ok(ctx.calls.some((call) => call.region === 'OVERSEAS' && call.token === 'platform-token'))
|
||||
})
|
||||
|
||||
test('missing marker fixture is a blocking coverage gap after real security request', async () => {
|
||||
|
||||
Reference in New Issue
Block a user