43 lines
2.2 KiB
JavaScript
43 lines
2.2 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
const read = (path) => readFile(new URL(path, import.meta.url), 'utf8')
|
|
|
|
test('pallet management is enabled through its dedicated real PDA route', async () => {
|
|
const [workbench, pages, home, module] = await Promise.all([
|
|
read('../src/data/overseas-workbench.js'), read('../src/pages.json'),
|
|
read('../src/pages/home/home.vue'), read('../src/pages/module/module.vue')
|
|
])
|
|
assert.match(workbench, /key: 'pallet'[\s\S]*available: true[\s\S]*route: '\/pages\/pallet\/pallet'/)
|
|
assert.match(pages, /pages\/pallet\/pallet/)
|
|
assert.match(home, /operation\.route \|\|/)
|
|
assert.match(module, /operation\.route \|\|/)
|
|
})
|
|
|
|
test('pallet API maps only the frozen overseas PDA operation endpoints', async () => {
|
|
const api = await read('../src/api/pallet.js')
|
|
for (const path of ['pallets/resolve', 'assemble', 'disassemble', 'swap', 'unbind']) {
|
|
assert.match(api, new RegExp(path.replace('/', '\\/')))
|
|
}
|
|
assert.match(api, /overseasRequest/)
|
|
assert.match(api, /const BASE = '\/pda\/v1\/last-leg\/pallet-operations'/)
|
|
assert.doesNotMatch(api, /const BASE = '\/api\/pda/)
|
|
for (const forbidden of ['customerId', 'warehouseId', 'locationId']) assert.doesNotMatch(api, new RegExp(forbidden))
|
|
})
|
|
|
|
test('pallet page preserves versions, idempotency and scan diagnostics for real writes', async () => {
|
|
const page = await read('../src/pages/pallet/pallet.vue')
|
|
for (const action of ['assemblePallet', 'disassemblePallet', 'swapPallet', 'unbindPallet', 'resolvePallet']) assert.match(page, new RegExp(action))
|
|
assert.match(page, /startScanBroadcast/)
|
|
assert.match(page, /activeTarget === 'source'/)
|
|
assert.match(page, /activeTarget === 'target'/)
|
|
assert.match(page, /expectedVersion: pallet\.palletVersion/)
|
|
assert.match(page, /expectedPositionVersion: String\(line\.positionVersion/)
|
|
assert.match(page, /idempotencyKey: this\.pendingKey/)
|
|
assert.match(page, /requestId[\s\S]*traceId/)
|
|
assert.match(page, /isConflict\(error\)[\s\S]*请重新扫描相关托盘[\s\S]*this\.sources = \[\]; this\.target = null/)
|
|
assert.match(page, /不同目的仓不能合托/)
|
|
assert.doesNotMatch(page, /模拟成功|customerId:|warehouseId:|locationId:/)
|
|
})
|