完成单机TEST统一入口与可靠投递回归收尾
This commit is contained in:
@@ -31,7 +31,7 @@ test('dropship original counted cartons must resolve exactly before any receivin
|
||||
for (const fault of [null, 'missing-carton', 'wrong-carton', 'wrong-inbound', 'wrong-destination']) {
|
||||
const calls = []; const checks = []
|
||||
const context = {
|
||||
async requestOverseas(method, requestPath, body) {
|
||||
async request(method,requestPath,body) {
|
||||
calls.push({ method, requestPath, body })
|
||||
const data = { cartonMark: body.cartonMark, inboundCode: 'REAL-INBOUND', destinationType: 'OVERSEAS' }
|
||||
if (fault === 'wrong-carton') data.cartonMark = 'ANOTHER-CARTON'
|
||||
@@ -60,7 +60,7 @@ test('dropship original counted cartons must resolve exactly before any receivin
|
||||
for (const sealedCartonMarks of [undefined, [], ['REAL-INBOUND#2-1'], ['REAL-INBOUND#2-1', 'REAL-INBOUND#2-1']]) {
|
||||
const checks = []
|
||||
const result = await resolveCartonFixtures({ assert(m,n,r,passed) { checks.push(passed) },
|
||||
async requestOverseas() { assert.fail('incomplete physical fixture must not issue HTTP') } },
|
||||
async request() { assert.fail('incomplete physical fixture must not issue HTTP') } },
|
||||
'token', inbounds, producer.sealedCartonMarks, { ...producer, sealedCartonMarks })
|
||||
assert.equal(result, null)
|
||||
assert.deepEqual(checks, [false])
|
||||
@@ -91,8 +91,8 @@ test('current loading event binds each pallet carton group to an explicit source
|
||||
|
||||
test('PDA module is injected, token-scoped, traceable, and contains no direct network or secret source', () => {
|
||||
assert.match(source, /export async function run\(context\)/)
|
||||
assert.match(source, /requestOverseas\(/)
|
||||
assert.match(source, /requestOverseasMultipart\(/)
|
||||
assert.match(source, /request\(/)
|
||||
assert.match(source, /requestMultipart\(/)
|
||||
assert.match(source, /requestId=/)
|
||||
assert.match(source, /traceId=/)
|
||||
assert.doesNotMatch(source, /https?:\/\//)
|
||||
@@ -140,8 +140,8 @@ test('PDA module covers the container-number receiving contract and excludes out
|
||||
assert.match(source, /安全扫描返回A0400/)
|
||||
assert.match(source, /warehouse-admin\?tenantId=0&.*capabilityCode=RECEIVING&warehouseType=OVERSEAS&status=ACTIVE/)
|
||||
assert.match(source, /193000000000200003.*193000000000200004/)
|
||||
assert.doesNotMatch(source, /requestOverseas\('POST', '\/api\/platform\/v1\/warehouse-admin'/)
|
||||
assert.doesNotMatch(source, /requestOverseas\('GET', '\/api\/platform\/v1\/warehouse-admin'/)
|
||||
assert.doesNotMatch(source, /request\('POST', '\/api\/platform\/v1\/warehouse-admin'/)
|
||||
assert.doesNotMatch(source, /request\('GET', '\/api\/platform\/v1\/warehouse-admin'/)
|
||||
assert.match(source, /receiving-containers\/current\/pallets\/resolve/)
|
||||
assert.match(source, /overseasWarehouseId, password/)
|
||||
assert.match(source, /inbound\?\.overseasWarehouseId/)
|
||||
@@ -280,13 +280,17 @@ test('missing OVERSEAS_WAREHOUSE_PDA_OPERATOR overseas authority is a deployment
|
||||
const calls = []; const gaps = []; const steps = []
|
||||
const context = {
|
||||
marker: 'PDA-CONTRACT', context: {}, createdResources: {},
|
||||
async request(method, requestPath) {
|
||||
async request(...args) {
|
||||
const route = /\/(?:last-leg|overseas-warehouse-resources)(?:\/|\?|$)/.test(String(args[1]));
|
||||
const handler = route ? async function(...args) { calls.push(args); throw new Error('must not request without credentials') } : async function(method,requestPath) {
|
||||
calls.push({ method, requestPath })
|
||||
return { method, path: requestPath, http: 200, body: { code: '200', data: [] },
|
||||
requestId: 'request-contract-1', traceId: 'trace-contract-0001' }
|
||||
},
|
||||
async requestOverseas(...args) { calls.push(args); throw new Error('must not request without credentials') },
|
||||
async requestOverseasMultipart(...args) { calls.push(args); throw new Error('must not request without credentials') },
|
||||
};
|
||||
return handler.apply(this,args);
|
||||
},
|
||||
|
||||
async requestMultipart(...args) { calls.push(args); throw new Error('must not request without credentials') },
|
||||
apiSuccess(module, name, response) { return response.body.data },
|
||||
addStep(...args) { steps.push(args) },
|
||||
assert(module, name, response, passed, evidence, options) { steps.push({ module, name, passed, evidence, options }) },
|
||||
@@ -306,9 +310,16 @@ test('empty candidate response cannot become a zero-business-request pass', asyn
|
||||
let userSequence = 0
|
||||
const roleId = '4000005'; const permissionId = '5107015'
|
||||
const context = {
|
||||
marker: 'PDA-CONTRACT', overseasToken: '', createdResources: {}, context: {},
|
||||
marker: 'PDA-CONTRACT', token: '', createdResources: {}, context: {},
|
||||
async findAvailablePhone() { userSequence += 1; return `1750000000${userSequence}` },
|
||||
async request(method, requestPath, body) {
|
||||
async request(...args) {
|
||||
const route = /\/(?:last-leg|overseas-warehouse-resources)(?:\/|\?|$)/.test(String(args[1]));
|
||||
const handler = route ? async function(method,requestPath,body,token,headers) {
|
||||
calls.push({ channel: 'overseas', method, requestPath })
|
||||
if (requestPath.endsWith('/current')) return { method, path: requestPath, http: 200,
|
||||
body: { code: 'A0404', message: 'not found' }, requestId: 'req-current', traceId: 'trace-current' }
|
||||
return response([], requestPath, method)
|
||||
} : async function(method,requestPath,body) {
|
||||
calls.push({ channel: 'domestic', method, requestPath })
|
||||
if (method === 'GET' && requestPath.endsWith('/roles')) return response([
|
||||
{ id: roleId, roleCode: 'OVERSEAS_WAREHOUSE_PDA_OPERATOR', status: 'ACTIVE', permissionIds: [permissionId] },
|
||||
@@ -324,16 +335,13 @@ test('empty candidate response cannot become a zero-business-request pass', asyn
|
||||
membershipId: String(9000 + userSequence), username: body.username, tenantId: '0', roleIds: [roleId],
|
||||
overseasWarehouseId: String(body.overseasWarehouseId), status: 'ACTIVE',
|
||||
}, requestPath, method)
|
||||
if (method === 'POST' && requestPath === '/api/auth/login') return response({ overseasAccessToken: `pda-token-${userSequence}` }, requestPath, method)
|
||||
if (method === 'POST' && requestPath === '/api/auth/login') return response({ accessToken: `pda-token-${userSequence}` }, requestPath, method)
|
||||
if (method === 'PUT' && /\/users\/\d+\/status$/.test(requestPath)) return response({ status: 'DISABLED' }, requestPath, method)
|
||||
throw new Error(`unexpected domestic request ${method} ${requestPath}`)
|
||||
},
|
||||
async requestOverseas(method, requestPath, body, headers, token) {
|
||||
calls.push({ channel: 'overseas', method, requestPath })
|
||||
if (requestPath.endsWith('/current')) return { method, path: requestPath, http: 200,
|
||||
body: { code: 'A0404', message: 'not found' }, requestId: 'req-current', traceId: 'trace-current' }
|
||||
return response([], requestPath, method)
|
||||
},
|
||||
};
|
||||
return handler.apply(this,args);
|
||||
},
|
||||
|
||||
apiSuccess(module, name, result) { return result.body.data },
|
||||
addStep(module, name, result, passed, evidence, options) { steps.push({ module, name, result, passed, evidence, options }) },
|
||||
assert(module, name, result, passed, evidence, options) { steps.push({ module, name, result, passed, evidence, options }) },
|
||||
|
||||
Reference in New Issue
Block a user