fix(pda): preserve packing plan retry keys and surface missing API

This commit is contained in:
2026-09-29 22:41:05 +08:00
parent 4e14721cb7
commit 19268b38d1
5 changed files with 81 additions and 8 deletions
+9 -1
View File
@@ -1,6 +1,6 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { findPackingOrders, getReturnCartonLabel, mergeReturnCartons, normalizePackingPreview } from '../src/api/return-packing.js'
import { findPackingOrders, getReturnCartonLabel, listReturnPackingPlans, mergeReturnCartons, normalizePackingPreview } from '../src/api/return-packing.js'
import { session } from '../src/stores/session.js'
test('packing preview keeps customer scope internal and exposes stable order references', () => {
@@ -40,3 +40,11 @@ test('return packing lookup still rejects real service errors', async () => {
globalThis.uni = { request(options) { options.success({ statusCode: 500, data: { code: 'B0500', message: '服务暂不可用' }, header: {} }) } }
await assert.rejects(() => findPackingOrders('RT-1'), (error) => error.code === 'B0500')
})
test('plan list distinguishes an empty success from a missing API and preserves diagnostics', async () => {
session.apiBase = '/api'; session.token = 'packing-token'
globalThis.uni = { request(options) { options.success({ statusCode: 200, data: { code: '200', data: [] }, header: {} }) } }
assert.deepEqual(await listReturnPackingPlans(), [])
globalThis.uni = { request(options) { options.success({ statusCode: 404, data: { code: 'A0404', message: '计划接口不存在', requestId: 'missing-plan-api' }, header: {} }) } }
await assert.rejects(() => listReturnPackingPlans(), error => error.code === 'A0404' && error.requestId === 'missing-plan-api')
})