This commit is contained in:
2026-08-31 17:10:46 +08:00
parent 410802870d
commit e686e13772
8 changed files with 39 additions and 47 deletions
+11 -7
View File
@@ -1,15 +1,18 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { businessReference, displayBusinessValue, formatApiError, sanitizeUserMessage } from '../utils/user-facing.js'
import { containerReference, displayBusinessValue, formatApiError, sanitizeUserMessage } from '../utils/user-facing.js'
const read = (path) => readFile(new URL(path, import.meta.url), 'utf8')
test('business identifiers never fall back to an internal id', () => {
test('PDA task labels prefer the container number and only fall back to the cabinet number', () => {
assert.equal(displayBusinessValue(null), '—')
assert.equal(displayBusinessValue('', '未关联'), '未关联')
assert.equal(businessReference({ orderNo: 'SO-2026-001', inboundCode: 'RK-2026-002', taskId: '2092889048731414530' }), '订单号 SO-2026-001 · 入仓码 RK-2026-002')
assert.equal(businessReference({ taskId: '2092889048731414530', inboundId: '2092889048731414531' }), '业务编号未关联')
assert.equal(containerReference({ currentContainerNo: 'TSTU0000760', cabinetNo: 'CAB-260830-0008', orderNo: 'FL-1' }), '集装箱号 TSTU0000760')
assert.equal(containerReference({ currentContainerNo: '', boxNo: 'TSTU0000708', cabinetNo: 'CAB-260829-0037' }), '集装箱号 TSTU0000708')
assert.equal(containerReference({ cabinetNo: 'CAB-260830-0008', taskId: '2092889048731414530' }), '柜次号 CAB-260830-0008')
assert.equal(containerReference({ boxNo: '同步中', cabinetNo: 'CAB-260830-0008' }), '柜次号 CAB-260830-0008')
assert.equal(containerReference({ taskId: '2092889048731414530', orderId: '2092889048731414531' }), '集装箱号 —')
})
test('operator errors hide internal ids but retain request and trace evidence', () => {
@@ -37,9 +40,10 @@ test('priority PDA templates do not interpolate internal ids', async () => {
for (const page of pages) {
const template = page.match(/<template>[\s\S]*?<\/template>/)?.[0] || ''
assert.doesNotMatch(template, /\{\{[^}\n]*(?:taskId|inboundId|orderId|loadingPlanId|containerBookingId)[^}\n]*\}\}/)
assert.doesNotMatch(template, /订单号|入仓码|业务编号未关联/)
}
assert.match(pages[0], /formatApiError\(error, '登录失败'\)/)
assert.match(pages[1], /businessReference\(task\)/)
assert.match(pages[2], /businessReference\(currentBox\)/)
assert.match(pages[3], /businessReference\(entry\.box\)/)
assert.match(pages[1], /containerReference\(task\)/)
assert.match(pages[2], /containerReference\(currentBox\)/)
assert.match(pages[3], /containerReference\(entry\.box\)/)
})