This commit is contained in:
2026-11-03 11:43:56 +08:00
parent 5a1cde6c0f
commit 95fb17c5aa
11 changed files with 102 additions and 16 deletions
@@ -13,6 +13,19 @@ const demandHelpers = runInNewContext(`${demandLogic}\n({ createTransportDemandF
const procurementApi = readFileSync(new URL('./api/procurement.ts', import.meta.url), 'utf8')
const procurementView = readFileSync(new URL('./views/ProcurementView.vue', import.meta.url), 'utf8')
test('all current truck statuses display Chinese labels in lists and details', () => {
const labelsCode = ts.transpileModule(readFileSync(new URL('./fleetArrangement.ts', import.meta.url), 'utf8'), { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext } }).outputText.replace(/^export /gm, '')
const { poolOrderStatusLabels } = runInNewContext(`${labelsCode}\n({ poolOrderStatusLabels })`)
const helpers = view.slice(view.indexOf('function read('), view.indexOf('function idempotencyKey('))
const compiled = ts.transpileModule(helpers, { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText
const { statusLabel, displayCell } = runInNewContext(`${compiled}\n({ statusLabel, displayCell })`, { poolOrderStatusLabels })
for (const status of ['PENDING_REVIEW', 'FUNDING_PENDING', 'FUNDING_FAILED', 'WAITING_INBOUND', 'RECEIVING', 'WAITING_CONSOLIDATION', 'PALLET_OVERAGE_REVIEW', 'PARTIALLY_ALLOCATED', 'ALLOCATED', 'PENDING_DISPATCH', 'DISPATCHED', 'IN_TRANSIT', 'COMPLETED', 'REJECTED', 'CANCELLED']) {
assert.match(statusLabel(status), /[\u4e00-\u9fff]/, status)
assert.equal(displayCell({ status }, 'status'), statusLabel(status))
}
assert.equal(statusLabel('DISPATCHED'), '待取货')
})
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
@@ -136,6 +149,7 @@ function transportHarness(kind = 'trucking', failFirst = false, budgetCheck = as
ElMessage: { success: () => {}, error: () => {} },
createTransport: async (business, payload) => { calls.push({ business, payload: { ...payload } }); if (failFirst && calls.length === 1) throw new Error('retry'); },
})
Object.assign(harness.form, { deliveryMode: 'WAREHOUSE_PICKUP', operatingWarehouseId: '9', destinationType: 'FBA', originAddress: '123 Pickup Road', destinationAddress: '456 Delivery Road' })
harness.formRef.value = { validate: async () => true, clearValidate: () => {} }
return { ...harness, calls, rules: { get value() { return demandHelpers.transportDemandRules(kind === 'trucking' ? 'truck' : 'looseboard', harness.form) } } }
}
@@ -230,3 +244,17 @@ test('truck creation does not block on a separate budget reservation', async ()
await current.submit()
assert.equal(current.calls.length, 1)
})
test('customer truck cancellation uses encoded order identity and current version without client scope', async () => {
const compiled = ts.transpileModule(api.replace(/^import .*$/gm, ''), { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext } }).outputText.replace(/^export /gm, '')
let sent
const { cancelTruckOrder } = runInNewContext(compiled + '\n({ cancelTruckOrder })', { apiRequest: input => { sent = input; return Promise.resolve({}) } })
const payload = { version: 3, status: 'CANCELLED', idempotencyKey: 'cancel-1', remark: '客户取消' }
await cancelTruckOrder('TR/1', payload)
assert.equal(sent.method, 'PATCH')
assert.equal(sent.url, '/merchant/v1/last-leg/us-truck-orders/TR%2F1/status')
assert.equal(sent.data, payload)
assert.match(view, /summary.status === 'PENDING_REVIEW'/)
assert.match(view, /merchant:cross-border:domestic-trucking:edit/)
})