Files
pda-uniapp/tests/dropship-palletization.test.mjs
T
2026-09-11 11:19:47 +08:00

45 lines
2.4 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('domestic workbench exposes a real one-click dropship palletization entry', async () => {
const [data, home, modulePage, pages] = await Promise.all([
read('../data/demo-data.js'), read('../pages/home/home.vue'), read('../pages/module/module.vue'), read('../pages.json')
])
assert.match(data, /key: 'inbound'[\s\S]*?name: '一件代发合托'[\s\S]*?available: true, visible: true/)
assert.match(home, /'一件代发合托': '\/pages\/dropship-tasks\/dropship-tasks'/)
assert.match(modulePage, /'一件代发合托': '\/pages\/dropship-tasks\/dropship-tasks'/)
assert.match(pages, /pages\/dropship-tasks\/dropship-tasks/)
assert.match(pages, /pages\/dropship-palletization\/dropship-palletization/)
})
test('dropship palletization adapter uses only the dedicated production PDA contract', async () => {
const api = await read('../api/pda-dropship.js')
for (const route of [
'/tasks/pending', '/cartons/resolve', '/cartons/count', '/pallets/bind-pending',
'/pallets/create-and-bind', '/seal'
]) assert.match(api, new RegExp(route.replaceAll('/', '\\/')))
assert.match(api, /expectedVersion: pallet\.version/)
assert.match(api, /operationId\('count'/)
assert.match(api, /operationId\('bind'/)
assert.match(api, /operationId\('create-bind'/)
assert.match(api, /operationId\('seal'/)
assert.doesNotMatch(api, /customerId|tenantId|inboundId/)
})
test('palletization UI supports scan, count, existing or generated pallet, and seal', async () => {
const [tasks, work] = await Promise.all([
read('../pages/dropship-tasks/dropship-tasks.vue'),
read('../pages/dropship-palletization/dropship-palletization.vue')
])
for (const text of ['待合托任务', '入仓码', '进入作业']) assert.match(tasks, new RegExp(text))
for (const text of ['领取并开始合托', '扫箱清点', '差异说明', '绑定到扫描托盘', '生成 DP 托盘并绑定', '确认封托']) assert.match(work, new RegExp(text))
assert.match(work, /startScanBroadcast/)
assert.match(work, /quantityDiffers[\s\S]*?ACCEPT_VARIANCE/)
assert.match(work, /canSeal\(\)[\s\S]*?countedCartons[\s\S]*?totalCartons[\s\S]*?unboundCartons/)
assert.match(work, /formatApiError/)
assert.doesNotMatch(work, /taskId\s*\}\}|warehouseId\s*\}\}|inboundId\s*\}\}/)
})