Files
pda-uniapp/tests/pda-loading-api.test.mjs
T
2026-08-06 13:56:01 +08:00

44 lines
2.0 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/)
})
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 evidence, retry and remote completion states', () => {
for (const text of ['PHOTO_STEP_1', 'PHOTO_STEP_4', 'SEAL', '网络失败', '确认装柜完成', 'loadingVersion']) {
assert.match(page, new RegExp(text))
}
assert.match(page, /submitting \|\| completedBoxes\[currentBoxIndex\]/)
assert.match(page, /completePicking\(/)
})