完成单机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
@@ -56,46 +56,9 @@ function fakeContext({ softAssertions = false, refreshEmpty = false } = {}) {
addCoverageGap(module, scenario, name, reason, category, metadata = {}) {
coverageGaps.push({ module, scenario, name, reason, category, ...metadata })
},
async request(method, path, body) {
calls.push({ gateway: 'domestic', method, path, body })
assert.notEqual(method, 'DELETE')
if (method === 'POST' && path === DOMESTIC_BASE) {
state.warehouse = { ...body, id: '910000000000000001' }
return ok(state.warehouse.id)
}
if (method === 'GET' && path === `${DOMESTIC_BASE}/910000000000000001?tenantId=0`) {
return ok({ warehouse: { ...state.warehouse }, addresses: [state.warehouse.address], capabilities: state.warehouse.capabilities })
}
if (method === 'PUT' && path === `${DOMESTIC_BASE}/910000000000000001?tenantId=0`) {
state.warehouse = { ...body, id: state.warehouse.id }
return ok(null)
}
if (method === 'PATCH' && path === `${DOMESTIC_BASE}/910000000000000001/status?tenantId=0&status=INACTIVE`) {
state.warehouse.status = 'INACTIVE'
return ok(null)
}
if (method === 'POST' && path === '/api/platform/v1/iam/roles') {
state.role = { id: '940000000000000001', ...body, status: 'ACTIVE' }
return ok({ ...state.role })
}
if (method === 'POST' && path === '/api/platform/v1/iam/users') {
state.user = { membershipId: '950000000000000001', ...body, status: 'ACTIVE' }
return ok({ ...state.user })
}
if (method === 'POST' && path === '/api/auth/login') {
return ok({ accessToken: 'deny-domestic-token', overseasAccessToken: 'deny-overseas-token', overseasExpiresIn: 900 })
}
if (method === 'PUT' && path === '/api/platform/v1/iam/users/950000000000000001/status') {
state.user.status = body.status
return ok(null)
}
if (method === 'PUT' && path === '/api/platform/v1/iam/roles/940000000000000001/status') {
state.role.status = body.status
return ok(null)
}
assert.fail(`unexpected domestic call ${method} ${path}`)
},
async requestOverseas(method, path, body, extraHeaders = {}, token = 'admin-overseas-token') {
async request(...args) {
const route = /\/(?:last-leg|overseas-warehouse-resources)(?:\/|\?|$)/.test(String(args[1]));
const handler = route ? async function(method,path,body,token = 'admin-overseas-token',extraHeaders = {}) {
calls.push({ gateway: 'overseas', method, path, body, extraHeaders, tokenKind: token === 'deny-overseas-token' ? 'denied' : 'admin' })
assert.notEqual(method, 'DELETE')
if (token === 'deny-overseas-token') return forbidden()
@@ -189,8 +152,49 @@ function fakeContext({ softAssertions = false, refreshEmpty = false } = {}) {
total: state.vehicle ? 1 : 0, pages: state.vehicle ? 1 : 0 })
}
assert.fail(`unexpected overseas call ${method} ${path}`)
},
async requestOverseasBinary(method, path) {
} : async function(method,path,body) {
calls.push({ gateway: 'domestic', method, path, body })
assert.notEqual(method, 'DELETE')
if (method === 'POST' && path === DOMESTIC_BASE) {
state.warehouse = { ...body, id: '910000000000000001' }
return ok(state.warehouse.id)
}
if (method === 'GET' && path === `${DOMESTIC_BASE}/910000000000000001?tenantId=0`) {
return ok({ warehouse: { ...state.warehouse }, addresses: [state.warehouse.address], capabilities: state.warehouse.capabilities })
}
if (method === 'PUT' && path === `${DOMESTIC_BASE}/910000000000000001?tenantId=0`) {
state.warehouse = { ...body, id: state.warehouse.id }
return ok(null)
}
if (method === 'PATCH' && path === `${DOMESTIC_BASE}/910000000000000001/status?tenantId=0&status=INACTIVE`) {
state.warehouse.status = 'INACTIVE'
return ok(null)
}
if (method === 'POST' && path === '/api/platform/v1/iam/roles') {
state.role = { id: '940000000000000001', ...body, status: 'ACTIVE' }
return ok({ ...state.role })
}
if (method === 'POST' && path === '/api/platform/v1/iam/users') {
state.user = { membershipId: '950000000000000001', ...body, status: 'ACTIVE' }
return ok({ ...state.user })
}
if (method === 'POST' && path === '/api/auth/login') {
return ok({ accessToken: 'deny-overseas-token', expiresIn: 900 })
}
if (method === 'PUT' && path === '/api/platform/v1/iam/users/950000000000000001/status') {
state.user.status = body.status
return ok(null)
}
if (method === 'PUT' && path === '/api/platform/v1/iam/roles/940000000000000001/status') {
state.role.status = body.status
return ok(null)
}
assert.fail(`unexpected domestic call ${method} ${path}`)
};
return handler.apply(this,args);
},
async requestBinary(method, path) {
calls.push({ gateway: 'overseas-binary', method, path })
assert.equal(method, 'GET')
assert.match(path, /\/(?:overseas-quotes|exchange-rates|vehicles)\/export\?/)
@@ -208,10 +212,10 @@ function fakeContext({ softAssertions = false, refreshEmpty = false } = {}) {
test('静态锁定真实双Gateway生命周期、CSV与安全边界', () => {
assert.match(source, /context\.request\('POST', DOMESTIC_BASE/)
assert.match(source, /warehouseType: 'OVERSEAS_PARTNER'/)
assert.match(source, /context\.requestOverseas\('POST'/)
assert.match(source, /context\.requestOverseas\('PUT'/)
assert.match(source, /context\.requestOverseas\('PATCH'/)
assert.match(source, /context\.requestOverseasBinary\('GET'/)
assert.match(source, /context\.request\('POST'/)
assert.match(source, /context\.request\('PUT'/)
assert.match(source, /context\.request\('PATCH'/)
assert.match(source, /context\.requestBinary\('GET'/)
assert.match(source, /context\.expectConflict/)
assert.match(source, /warehouse-options\?refresh=true/)
assert.match(source, /空候选不负缓存30分钟/)