Files
client-web/src/modules/order-management/inboundOrders.test.mjs
T

75 lines
4.6 KiB
JavaScript
Raw Normal View History

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { overseasWarehouseLabel } from './inboundPlanDisplay.ts'
const api = readFileSync(new URL('./api/inboundPlans.ts', import.meta.url), 'utf8')
const routes = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8')
const view = readFileSync(new URL('./views/InboundOrdersView.vue', import.meta.url), 'utf8')
2026-09-07 15:07:49 +08:00
const overseasHttp = readFileSync(new URL('../../api/overseasHttp.ts', import.meta.url), 'utf8')
test('activates the customer-scoped overseas inbound list and detail', () => {
assert.match(routes, /path: 'orders\/inbound'[\s\S]*?release: 'active'[\s\S]*?permission: 'merchant:warehouse:inbound:list'/)
assert.match(api, /\/merchant\/v1\/last-leg\/inbound-plans/)
assert.match(api, /encodeURIComponent\(planNo\)/)
assert.doesNotMatch(api, /\/platform\/|\/internal\/|customerId|tenantId/)
assert.doesNotMatch(view, /customerId|tenantId/)
})
test('keeps actions first and exposes filters loading errors empty state pagination and business identifiers', () => {
assert.match(view, /<el-table-column label="操作"[^>]*fixed="left"/)
for (const token of ['planNo', 'inboundCode', 'destinationWarehouseCode', 'appointmentStatus', 'dispatchStatus', 'createdDates']) assert.match(view, new RegExp(token))
assert.match(view, /v-loading="loading"/)
assert.match(view, /type="error"/)
assert.match(view, /empty-text="暂无入库订单"/)
assert.match(view, /<el-pagination/)
assert.match(view, /detail\.planNo/)
assert.doesNotMatch(view, /planId|orderId|warehouseId|customerId/)
})
2026-09-07 15:07:49 +08:00
test('shows only the server-provided overseas receiving warehouse code and name', () => {
assert.equal((api.match(/overseasWarehouseCode\?: string \| null/g) || []).length, 2)
assert.equal((api.match(/overseasWarehouseName\?: string \| null/g) || []).length, 2)
2026-09-07 15:07:49 +08:00
assert.doesNotMatch(api, /overseasWarehouseId/)
assert.match(view, /label="海外接柜仓"/)
assert.match(view, /overseasWarehouseLabel\(scope\.row\.overseasWarehouseCode, scope\.row\.overseasWarehouseName\)/)
assert.match(view, /overseasWarehouseLabel\(detail\.overseasWarehouseCode, detail\.overseasWarehouseName\)/)
assert.doesNotMatch(view, /warehouseName \|\| warehouseCode|destinationWarehouse(?:Id|Code|Name).*overseasWarehouse/i)
})
test('renders a dash when either formal receiving warehouse field is absent', () => {
assert.equal(overseasWarehouseLabel('US-LAX-01', '洛杉矶仓'), 'US-LAX-01 · 洛杉矶仓')
assert.equal(overseasWarehouseLabel(' US-LAX-01 ', ' 洛杉矶仓 '), 'US-LAX-01 · 洛杉矶仓')
for (const pair of [
[undefined, undefined], [null, null], ['', '洛杉矶仓'], ['US-LAX-01', ''],
[undefined, '洛杉矶仓'], ['US-LAX-01', undefined], [' ', '洛杉矶仓'], ['US-LAX-01', ' '],
]) assert.equal(overseasWarehouseLabel(pair[0], pair[1]), '—')
})
2026-09-07 15:07:49 +08:00
test('preserves overseas API diagnostic metadata without rendering it as a business identifier', () => {
assert.match(overseasHttp, /response\.data\.traceId/)
assert.match(overseasHttp, /response\.data\.requestId/)
assert.match(overseasHttp, /body\.traceId, body\.requestId/)
assert.doesNotMatch(view, /requestId|traceId/)
})
2026-09-07 20:27:35 +08:00
test('renders inbound workflow statuses in Chinese and keeps desktop values on one line', () => {
for (const [status, label] of [
['PENDING_ASSIGNMENT', '待分配'], ['PDA_PENDING', '待收货'], ['ASSIGNED', '已分配'],
['SIGNED', '已签收'], ['PICKING', '拣货中'], ['PARTIAL_INBOUND', '部分入库'],
]) assert.match(view, new RegExp(`${status}: '${label}'`))
assert.match(view, /label="状态" width="120" show-overflow-tooltip/)
assert.match(view, /\.detail-grid div \{ min-width: 0;/)
assert.match(view, /\.detail-grid dd \{[^}]*overflow: hidden;[^}]*text-overflow: ellipsis;[^}]*white-space: nowrap;/)
})
test('uses the formal inbound status selector and presents destination fields without mixing receiving warehouses', () => {
assert.match(view, /const inboundStatusOptions = \[/)
assert.match(view, /label="作业状态"><el-select v-model="query\.status"/)
assert.doesNotMatch(view, /label="作业状态"><el-input/)
assert.match(view, /destinationWarehouseLabel\(scope\.row\.fbaWarehouseCode, scope\.row\.destinationWarehouseCode, scope\.row\.destinationWarehouseName\)/)
assert.match(view, /destinationWarehouseLabel\(scope\.row\.destinationWarehouseCode, scope\.row\.destinationWarehouseName\)/)
assert.doesNotMatch(view, /label="目的仓代码"|label="目的仓名称"/)
assert.doesNotMatch(view, /destinationWarehouseLabel\([^)]*overseasWarehouse/)
})