This commit is contained in:
2026-08-07 18:15:59 +08:00
parent 8575df0793
commit dd7aa0e4cf
7 changed files with 92 additions and 8 deletions
@@ -2,12 +2,14 @@ import assert from 'node:assert/strict'
import test from 'node:test'
import { createFirstLegPartySnapshot } from '../data/firstLegParties.ts'
import {
applyCargoBoxSize,
canClientCancelFirstLegOrder,
canClientEditFirstLegOrder,
createEmptyCargoItem,
getFirstLegStatusLabel,
getFirstLegTransportModeLabel,
summarizeFirstLegCargo,
updateCargoBoxVolume,
validateFirstLegOrderDraft,
} from './firstLegOrder.ts'
@@ -52,10 +54,24 @@ function validDraft() {
destinationType: 'FBA',
amazonWarehouseCode: 'ONT8',
shipmentId: 'FBA-001',
items: [{ ...createEmptyCargoItem('cargo-1'), sku: 'SKU-001', upc: '012345678905', cargoNameCn: '家居用品', pieces: 100, grossWeightKg: 1200, volumeCbm: 3.5, containerType: '40HQ', containerCount: 1 }],
items: [{ ...createEmptyCargoItem('cargo-1'), sku: 'SKU-001', upc: '012345678905', cargoNameCn: '家居用品', pieces: 100, grossWeightKg: 1200, volumeCbm: 3.5, boxSizeType: 'SMALL', lengthCm: 34, widthCm: 24, heightCm: 24, containerType: '40HQ', containerCount: 1 }],
}
}
test('applies the four fixed box sizes and recalculates total CBM from package count', () => {
const item = createEmptyCargoItem('cargo-box')
item.packageCount = 2
applyCargoBoxSize(item, 'SMALL')
assert.deepEqual([item.lengthCm, item.widthCm, item.heightCm, item.volumeCbm], [34, 24, 24, 0.039])
item.packageCount = 3
updateCargoBoxVolume(item)
assert.equal(item.volumeCbm, 0.059)
applyCargoBoxSize(item, '')
assert.deepEqual([item.lengthCm, item.widthCm, item.heightCm, item.volumeCbm], [0, 0, 0, 0])
})
test('uses the confirmed status and transport labels', () => {
assert.equal(getFirstLegStatusLabel('WAIT_MEASURE'), '待测量数据')
assert.equal(getFirstLegStatusLabel('INBOUNDED'), '已入库')