fix(orders): retain nullable palletizing facts in customer summaries

This commit is contained in:
2026-10-07 19:44:44 +08:00
parent a853b1e0c2
commit 47385d46f2
2 changed files with 19 additions and 1 deletions
@@ -79,7 +79,7 @@ export interface TransportSummary {
orderNo: string
transportType: string
transportMode?: string
palletRequired?: string
palletRequired?: string | null
origin: string
destination: string
containerType: string | null
@@ -1,11 +1,29 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { runInNewContext } from 'node:vm'
import ts from 'typescript'
const api = readFileSync(new URL('./api/businessOrders.ts', import.meta.url), 'utf8')
const routes = readFileSync(new URL('./routes.ts', import.meta.url), 'utf8')
const view = readFileSync(new URL('./components/BusinessOrdersView.vue', import.meta.url), 'utf8')
test('renders unknown pallet service and container type as dashes while preserving explicit values', () => {
const helpers = view.slice(view.indexOf('function read('), view.indexOf('function idempotencyKey('))
const compiled = ts.transpileModule(helpers, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText
const { displayCell, yesNo, text } = runInNewContext(`${compiled}\n({ displayCell, yesNo, text })`)
assert.equal(displayCell({ palletRequired: null }, 'palletRequired'), '—')
assert.equal(displayCell({ palletRequired: 'NO' }, 'palletRequired'), '否')
assert.equal(displayCell({ palletRequired: 'YES' }, 'palletRequired'), '是')
assert.equal(displayCell({ containerType: null }, 'containerType'), '—')
assert.equal(displayCell({ containerType: '40HQ' }, 'containerType'), '40HQ')
assert.equal(yesNo(null), '—')
assert.equal(text(null), '—')
assert.match(api, /palletRequired\?: string \| null/)
const create = api.slice(api.indexOf('export interface TransportCreate'), api.indexOf('export interface TransportUpdate'))
assert.doesNotMatch(create, /palletRequired\?: string \| null/)
})
test('shows merchant-owned arrangement facts without a pool request or editable status control', () => {
assert.match(api, /fleetArrangement: import\('\.\.\/fleetArrangement'\)\.FleetArrangement \| null/)
assert.match(view, /aria-label="承运安排"/)