优化
This commit is contained in:
@@ -13,16 +13,16 @@ test('packing preview keeps customer scope internal and exposes stable order ref
|
||||
|
||||
test('return packing API uses exact PDA inventory routes without submitting customer or warehouse scope', async () => {
|
||||
const calls = []
|
||||
session.apiBase = '/overseas-api'; session.token = 'packing-token'
|
||||
session.apiBase = '/api'; session.token = 'packing-token'
|
||||
globalThis.uni = { request(options) { calls.push({ method: options.method, url: options.url, data: options.data, authorization: options.header.Authorization }); let data = {}; if (options.url.includes('/packing/orders')) data = { customerId: '100', orders: [], skus: [] }; else if (options.url.endsWith('/cartons/merge')) data = { cartonMark: 'RC-1', skuCode: 'SKU-1', totalQuantity: 2, label: { cartonMark: 'RC-1', items: [] } }; else data = { cartonMark: 'RC/1', totalQuantity: 2, items: [] }; options.success({ statusCode: 200, data: { code: '200', data }, header: {} }) } }
|
||||
await findPackingOrders('RT/1')
|
||||
const request = { returnNos: ['RT/1'], items: [{ skuCode: 'SKU-1', quantity: 2 }], length: 10, width: 20, height: 30, weight: 4, idempotencyKey: 'merge-key' }
|
||||
await mergeReturnCartons(request)
|
||||
await getReturnCartonLabel('RC/1')
|
||||
assert.deepEqual(calls.map((item) => item.url), [
|
||||
'/overseas-api/pda/v1/last-leg/return-inventory/packing/orders?returnNo=RT%2F1',
|
||||
'/overseas-api/pda/v1/last-leg/return-inventory/cartons/merge',
|
||||
'/overseas-api/pda/v1/last-leg/return-inventory/cartons/RC%2F1/label'
|
||||
'/api/pda/v1/last-leg/return-inventory/packing/orders?returnNo=RT%2F1',
|
||||
'/api/pda/v1/last-leg/return-inventory/cartons/merge',
|
||||
'/api/pda/v1/last-leg/return-inventory/cartons/RC%2F1/label'
|
||||
])
|
||||
assert.deepEqual(calls[1].data, request)
|
||||
assert.ok(calls.every((item) => item.authorization === 'Bearer packing-token'))
|
||||
@@ -30,13 +30,13 @@ test('return packing API uses exact PDA inventory routes without submitting cust
|
||||
})
|
||||
|
||||
test('return packing lookup treats not found as an empty preview', async () => {
|
||||
session.apiBase = '/overseas-api'; session.token = 'packing-token'
|
||||
session.apiBase = '/api'; session.token = 'packing-token'
|
||||
globalThis.uni = { request(options) { options.success({ statusCode: 404, data: { code: 'A0404', message: '没有匹配的可合箱库存' }, header: {} }) } }
|
||||
assert.deepEqual(await findPackingOrders('MISSING-RETURN'), { customerKey: '', orders: [], skus: [] })
|
||||
})
|
||||
|
||||
test('return packing lookup still rejects real service errors', async () => {
|
||||
session.apiBase = '/overseas-api'; session.token = 'packing-token'
|
||||
session.apiBase = '/api'; session.token = 'packing-token'
|
||||
globalThis.uni = { request(options) { options.success({ statusCode: 500, data: { code: 'B0500', message: '服务暂不可用' }, header: {} }) } }
|
||||
await assert.rejects(() => findPackingOrders('RT-1'), (error) => error.code === 'B0500')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user