test: freeze client receiving warehouse contract
This commit is contained in:
@@ -17,8 +17,8 @@ export interface InboundPlanSummary {
|
|||||||
planNo: string
|
planNo: string
|
||||||
inboundCode: string
|
inboundCode: string
|
||||||
orderType: string | null
|
orderType: string | null
|
||||||
overseasWarehouseCode: string | null
|
overseasWarehouseCode?: string | null
|
||||||
overseasWarehouseName: string | null
|
overseasWarehouseName?: string | null
|
||||||
fbaWarehouseCode: string | null
|
fbaWarehouseCode: string | null
|
||||||
packageCount: number
|
packageCount: number
|
||||||
pickedPackageCount: number
|
pickedPackageCount: number
|
||||||
@@ -52,8 +52,8 @@ export interface InboundPlanPallet {
|
|||||||
export interface InboundPlanDetail {
|
export interface InboundPlanDetail {
|
||||||
planNo: string
|
planNo: string
|
||||||
containerNo: string | null
|
containerNo: string | null
|
||||||
overseasWarehouseCode: string | null
|
overseasWarehouseCode?: string | null
|
||||||
overseasWarehouseName: string | null
|
overseasWarehouseName?: string | null
|
||||||
status: string
|
status: string
|
||||||
lineCount: number
|
lineCount: number
|
||||||
palletCount: number
|
palletCount: number
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { readFileSync } from 'node:fs'
|
import { readFileSync } from 'node:fs'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
|
import { overseasWarehouseLabel } from './inboundPlanDisplay.ts'
|
||||||
|
|
||||||
const api = readFileSync(new URL('./api/inboundPlans.ts', import.meta.url), 'utf8')
|
const api = readFileSync(new URL('./api/inboundPlans.ts', import.meta.url), 'utf8')
|
||||||
const routes = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8')
|
const routes = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8')
|
||||||
@@ -12,6 +13,7 @@ test('activates the customer-scoped overseas inbound list and detail', () => {
|
|||||||
assert.match(api, /\/merchant\/v1\/last-leg\/inbound-plans/)
|
assert.match(api, /\/merchant\/v1\/last-leg\/inbound-plans/)
|
||||||
assert.match(api, /encodeURIComponent\(planNo\)/)
|
assert.match(api, /encodeURIComponent\(planNo\)/)
|
||||||
assert.doesNotMatch(api, /\/platform\/|\/internal\/|customerId|tenantId/)
|
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', () => {
|
test('keeps actions first and exposes filters loading errors empty state pagination and business identifiers', () => {
|
||||||
@@ -26,16 +28,24 @@ test('keeps actions first and exposes filters loading errors empty state paginat
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('shows only the server-provided overseas receiving warehouse code and name', () => {
|
test('shows only the server-provided overseas receiving warehouse code and name', () => {
|
||||||
assert.match(api, /overseasWarehouseCode: string \| null/)
|
assert.equal((api.match(/overseasWarehouseCode\?: string \| null/g) || []).length, 2)
|
||||||
assert.match(api, /overseasWarehouseName: string \| null/)
|
assert.equal((api.match(/overseasWarehouseName\?: string \| null/g) || []).length, 2)
|
||||||
assert.doesNotMatch(api, /overseasWarehouseId/)
|
assert.doesNotMatch(api, /overseasWarehouseId/)
|
||||||
assert.match(view, /label="海外接柜仓"/)
|
assert.match(view, /label="海外接柜仓"/)
|
||||||
assert.match(view, /overseasWarehouseLabel\(scope\.row\.overseasWarehouseCode, scope\.row\.overseasWarehouseName\)/)
|
assert.match(view, /overseasWarehouseLabel\(scope\.row\.overseasWarehouseCode, scope\.row\.overseasWarehouseName\)/)
|
||||||
assert.match(view, /overseasWarehouseLabel\(detail\.overseasWarehouseCode, detail\.overseasWarehouseName\)/)
|
assert.match(view, /overseasWarehouseLabel\(detail\.overseasWarehouseCode, detail\.overseasWarehouseName\)/)
|
||||||
assert.match(view, /if \(typeof code !== 'string' \|\| !code\.trim\(\) \|\| typeof name !== 'string' \|\| !name\.trim\(\)\) return '—'/)
|
|
||||||
assert.doesNotMatch(view, /warehouseName \|\| warehouseCode|destinationWarehouse(?:Id|Code|Name).*overseasWarehouse/i)
|
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]), '—')
|
||||||
|
})
|
||||||
|
|
||||||
test('preserves overseas API diagnostic metadata without rendering it as a business identifier', () => {
|
test('preserves overseas API diagnostic metadata without rendering it as a business identifier', () => {
|
||||||
assert.match(overseasHttp, /response\.data\.traceId/)
|
assert.match(overseasHttp, /response\.data\.traceId/)
|
||||||
assert.match(overseasHttp, /response\.data\.requestId/)
|
assert.match(overseasHttp, /response\.data\.requestId/)
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export function overseasWarehouseLabel(code: unknown, name: unknown) {
|
||||||
|
if (typeof code !== 'string' || !code.trim() || typeof name !== 'string' || !name.trim()) return '—'
|
||||||
|
return `${code.trim()} · ${name.trim()}`
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { getInboundPlan, listInboundPlans, type InboundPlanDetail, type InboundPlanSummary } from '../api/inboundPlans'
|
import { getInboundPlan, listInboundPlans, type InboundPlanDetail, type InboundPlanSummary } from '../api/inboundPlans'
|
||||||
|
import { overseasWarehouseLabel } from '../inboundPlanDisplay'
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
@@ -23,10 +24,6 @@ const query = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function text(value: unknown) { return value === null || value === undefined || value === '' ? '—' : String(value) }
|
function text(value: unknown) { return value === null || value === undefined || value === '' ? '—' : String(value) }
|
||||||
function overseasWarehouseLabel(code: unknown, name: unknown) {
|
|
||||||
if (typeof code !== 'string' || !code.trim() || typeof name !== 'string' || !name.trim()) return '—'
|
|
||||||
return `${code.trim()} · ${name.trim()}`
|
|
||||||
}
|
|
||||||
function destinationWarehouseLabel(...values: unknown[]) {
|
function destinationWarehouseLabel(...values: unknown[]) {
|
||||||
const parts = values
|
const parts = values
|
||||||
.filter((value): value is string => typeof value === 'string' && Boolean(value.trim()))
|
.filter((value): value is string => typeof value === 'string' && Boolean(value.trim()))
|
||||||
|
|||||||
Reference in New Issue
Block a user