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

60 lines
3.5 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/create-and-bind', '/print'
]) assert.match(api, new RegExp(route.replaceAll('/', '\\/')))
assert.match(api, /apiDownload/)
assert.match(api, /application\\\/pdf/)
assert.match(api, /session\.apiBase \|\| '\/api\/platform\/v1'/)
assert.match(api, /tasks\/pending\?\$\{params\.join\('&'\)\}/)
assert.match(api, /warehouseId=\$\{encodeURIComponent\(warehouseId\)\}/)
assert.match(api, /operationId\('count'/)
assert.match(api, /operationId\('create-bind'/)
assert.match(api, /function stableId\(value\)[\s\S]*?String\(value \?\? ''\)\.trim\(\)/)
assert.match(api, /warehouseId: stableId\(warehouseId\)/)
assert.match(api, /warehouseId: stableId\(payload\.warehouseId\)/)
assert.doesNotMatch(api, /customerId|tenantId|inboundId/)
})
test('palletization UI generates and prints the final pallet number only after inbound work is complete', 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))
assert.match(tasks, /\.search-card\s*\{[^}]*display:\s*flex;[^}]*box-shadow:\s*none;/)
assert.match(tasks, /\.task-list\s*\{[^}]*overflow:\s*hidden;[^}]*border-radius:\s*7px;/)
assert.match(tasks, /\.task-card\s*\{[^}]*margin:\s*0;[^}]*border-radius:\s*0;[^}]*box-shadow:\s*none;/)
for (const text of ['一件代发入库', '领取并开始入库', '扫箱清点', '差异说明', '完成入库并生成托盘码', '托盘码与打印', '打印托盘码']) assert.match(work, new RegExp(text))
for (const text of ['绑定到扫描托盘', '生成 DP 托盘并绑定', '确认封托']) assert.doesNotMatch(work, new RegExp(text))
assert.match(work, /class="task-summary-card"/)
assert.match(work, /\.task-summary-card\s*\{\s*display:\s*block;/)
assert.doesNotMatch(work, /class="summary-card"/)
assert.match(work, /startScanBroadcast/)
assert.match(work, /quantityDiffers[\s\S]*?ACCEPT_VARIANCE/)
assert.match(work, /allCartonsCounted\(\)[\s\S]*?countedCartons[\s\S]*?totalCartons/)
assert.match(work, /pallet\.status !== 'SEALED'/)
assert.match(work, /downloadDropshipPalletLabel/)
assert.match(work, /formatApiError/)
assert.doesNotMatch(work, /Number\(this\.warehouseId\)/)
assert.doesNotMatch(work, /taskId\s*\}\}|warehouseId\s*\}\}|inboundId\s*\}\}/)
})