fix(overseas-pda): localize workflow errors
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
pickDispatchItem, pickOutboundTask, resolveOutboundTask
|
||||
} from '../src/api/fulfillment.js'
|
||||
import { session } from '../src/stores/session.js'
|
||||
import { toDispatchError } from '../src/utils/dispatch-error.js'
|
||||
|
||||
const read = (path) => readFile(new URL(path, import.meta.url), 'utf8')
|
||||
|
||||
@@ -126,13 +127,13 @@ test('pages expose loading empty error offline and permission diagnostics with g
|
||||
assert.match(page, /暂无/)
|
||||
assert.match(page, /requestId[\s\S]*traceId/)
|
||||
assert.match(page, /error\.network[\s\S]*幂等键/)
|
||||
assert.match(page, /A0403[\s\S]*没有海外仓 PDA 作业权限/)
|
||||
assert.match(page, /fulfillmentIdempotencyKey/)
|
||||
assert.match(page, /releaseFulfillmentKey/)
|
||||
assert.match(page, /if \(!this\.can/)
|
||||
assert.doesNotMatch(page, /模拟成功|静默成功|customerId:|warehouseId:|locationId:/)
|
||||
}
|
||||
assert.match(dispatch, /completeDispatchPicking/)
|
||||
assert.match(dispatch, /toDispatchError/)
|
||||
assert.match(dispatch, /this\.remainingPackages === 0/)
|
||||
assert.doesNotMatch(dispatch, /partialReason|reason \}/)
|
||||
assert.match(dispatch, /this\.pickingCompleted && this\.allPicked && this\.current\?\.canDepart === true && !this\.departed/)
|
||||
@@ -153,6 +154,27 @@ test('pages expose loading empty error offline and permission diagnostics with g
|
||||
assert.doesNotMatch(dispatch + outbound, /DeliveryOrder|deliveryStatus|customerVisit|\/deliveries/)
|
||||
})
|
||||
|
||||
test('dispatch vehicle-plate conflict uses actionable Chinese copy and preserves diagnostics', () => {
|
||||
const error = toDispatchError({
|
||||
code: 'A0409',
|
||||
message: 'Vehicle plate is required before PDA push or picking',
|
||||
requestId: 'faccb2ee-5e05-4904-9bef-bc983638b47b',
|
||||
traceId: '43ca73abd84fab3e2992aa50e48fb48f'
|
||||
}, '提交排车拣货失败')
|
||||
assert.deepEqual(error, {
|
||||
message: '请先在平台维护车牌信息后再拣货',
|
||||
code: 'A0409',
|
||||
requestId: 'faccb2ee-5e05-4904-9bef-bc983638b47b',
|
||||
traceId: '43ca73abd84fab3e2992aa50e48fb48f',
|
||||
network: false
|
||||
})
|
||||
|
||||
const unknown = toDispatchError({ code: 'A0409', message: 'Another dispatch conflict', requestId: 'request-2' }, '失败')
|
||||
assert.equal(unknown.message, 'Another dispatch conflict')
|
||||
assert.equal(unknown.requestId, 'request-2')
|
||||
assert.equal(toDispatchError({ code: 'A0403', message: 'Forbidden' }).message, '当前账号没有海外仓 PDA 作业权限,请联系管理员授权')
|
||||
})
|
||||
|
||||
test('receiving conflict recovery keeps request and trace evidence visible on narrow screens', async () => {
|
||||
const operation = await read('../src/pages/operation/operation.vue')
|
||||
assert.match(operation, /openContainer\(candidate\)[\s\S]*recoverCurrentAfterConflict\(error, true\)/)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { isNoCurrentReceiving, isReceivingConflict, normalizeReceivingCandidate, normalizeReceivingSession, RECEIVING_PHOTO_ROLES } from '../src/api/receiving-adapter.js'
|
||||
import { isNoCurrentReceiving, isReceivingConflict, normalizeReceivingCandidate, normalizeReceivingSession, RECEIVING_PHOTO_ROLES, toReceivingError } from '../src/api/receiving-adapter.js'
|
||||
|
||||
test('receiving adapter preserves the three signed photo roles in workflow order', () => {
|
||||
const snowflakeFileId = '2092476334483931138'
|
||||
@@ -27,3 +27,29 @@ test('receiving adapter exposes calculable candidate facts and workflow errors',
|
||||
assert.equal(isNoCurrentReceiving({ code: 404 }), true)
|
||||
assert.equal(isReceivingConflict({ code: 'B0409' }), true)
|
||||
})
|
||||
|
||||
test('unusable warehouse pallet error is actionable Chinese and retains diagnostics', () => {
|
||||
const mapped = toReceivingError({
|
||||
code: 'S0503',
|
||||
message: 'Warehouse pallet service returned no usable response',
|
||||
requestId: '4dd3028c-9112-429d-a9d2-4f71233c5c64',
|
||||
traceId: 'c01eeddb77afc5c018828c3cb8ccc1ec'
|
||||
}, '校验托盘失败')
|
||||
assert.equal(mapped.message, '该托盘当前不可用于收货,请更换可用托盘或联系管理员检查托盘状态')
|
||||
assert.equal(mapped.code, 'S0503')
|
||||
assert.equal(mapped.requestId, '4dd3028c-9112-429d-a9d2-4f71233c5c64')
|
||||
assert.equal(mapped.traceId, 'c01eeddb77afc5c018828c3cb8ccc1ec')
|
||||
|
||||
const occupied = toReceivingError({
|
||||
code: 'A0409',
|
||||
message: 'Pallet is not idle',
|
||||
requestId: 'occupied-request',
|
||||
traceId: 'occupied-trace'
|
||||
})
|
||||
assert.equal(occupied.message, '该托盘已被占用,当前不可用于收货,请更换可用托盘')
|
||||
assert.equal(occupied.requestId, 'occupied-request')
|
||||
assert.equal(occupied.traceId, 'occupied-trace')
|
||||
|
||||
const unknown = toReceivingError({ code: 'S0503', message: 'Another warehouse failure' }, '校验托盘失败')
|
||||
assert.equal(unknown.message, 'Another warehouse failure')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user