63 lines
3.1 KiB
JavaScript
63 lines
3.1 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
const source = await readFile(new URL('../api/pda-loading.js', import.meta.url), 'utf8')
|
|
const page = await readFile(new URL('../pages/picking/picking.vue', import.meta.url), 'utf8')
|
|
|
|
test('PDA loading adapter keeps C04 read and write paths', () => {
|
|
for (const path of [
|
|
'/orders?',
|
|
'/loading/picking?tenantId=',
|
|
'/loading/picking/start?tenantId=',
|
|
'/loading/picking/complete?tenantId=',
|
|
'/loading/evidence?tenantId=',
|
|
'/loading/complete?tenantId='
|
|
]) assert.match(source, new RegExp(path.replace(/[?]/g, '\\?')))
|
|
assert.match(source, /'Idempotency-Key'/)
|
|
assert.match(source, /PHOTO_STEP_1[\s\S]*PHOTO_STEP_4[\s\S]*SEAL/)
|
|
for (const label of ['空仓照片', '半仓照片', '满仓照片', '锁仓照片', '带锁码照']) assert.match(source, new RegExp(label))
|
|
assert.match(source, /uni\.uploadFile/)
|
|
assert.match(source, /\/files\/loading-evidence\//)
|
|
})
|
|
|
|
test('PDA adapter does not treat non-200 response bodies or network failures as success', () => {
|
|
assert.match(source, /if \(code !== '200'\)/)
|
|
assert.match(source, /next\.network = true/)
|
|
assert.match(source, /throw new Error\('缺少客户隔离标识 tenantId/)
|
|
})
|
|
|
|
test('C02 identifiers and separate picking/inbound versions are normalized explicitly', () => {
|
|
assert.match(source, /inboundId: row\.inboundId/)
|
|
assert.match(source, /inboundVersion: row\.inboundVersion/)
|
|
assert.match(source, /pickingVersion: row\.pickingVersion \?\? row\.loading\?\.pickingVersion/)
|
|
assert.match(source, /pickingVersion: task\.pickingVersion \?\? task\.version/)
|
|
assert.match(page, /expectedVersion: Number\(this\.pickingVersion\)/)
|
|
assert.match(page, /this\.loadingVersion = this\.currentBox\.inboundVersion/)
|
|
assert.match(page, /缺少拣货版本号 pickingVersion/)
|
|
})
|
|
|
|
test('picking page exposes five evidence slots, retry and remote completion states', () => {
|
|
for (const text of ['PHOTO_STEP_1', 'PHOTO_STEP_4', 'SEAL', '网络失败', '确认装柜完成', 'loadingVersion']) {
|
|
assert.match(`${source}\n${page}`, new RegExp(text))
|
|
}
|
|
assert.match(page, /createEvidenceUploadQueue/)
|
|
assert.match(page, /retryEvidence/)
|
|
assert.match(page, /uploadEvidenceFile/)
|
|
assert.match(page, /submitting \|\| completedBoxes\[currentBoxIndex\]/)
|
|
assert.match(page, /completePicking\(/)
|
|
})
|
|
|
|
test('PDA cabinet picking adapter exposes online claim and item action contracts', () => {
|
|
assert.match(source, /\/first-leg\/pda-loading\/tasks\?/)
|
|
assert.match(source, /tasks\/\$\{encodeURIComponent\(taskId\)\}\/claim/)
|
|
assert.match(source, /items\/\$\{encodeURIComponent\(itemId\)\}\/pick/)
|
|
assert.match(source, /items\/\$\{encodeURIComponent\(itemId\)\}\/partial/)
|
|
assert.match(source, /items\/\$\{encodeURIComponent\(itemId\)\}\/skip/)
|
|
assert.match(source, /submitContainerPickingBatch/)
|
|
assert.match(source, /stableIdempotencyKey/)
|
|
assert.match(page, /claimContainerPickingTask\(/)
|
|
assert.match(page, /submitContainerPickingBatch\(/)
|
|
assert.match(page, /任务版本已变化,请刷新后重试/)
|
|
})
|