35 lines
2.0 KiB
TypeScript
35 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { loadSmartLoadingPlanCoLoadGroups } from './smartLoadingPlanGroups'
|
|
import type { SmartLoadingPlan } from './types'
|
|
|
|
const item = {
|
|
id: '701', loadingPlanId: '99', accountId: '1', inboundId: '201', inboundDetailId: '801', orderId: '301',
|
|
orderNo: 'ORD-1', inboundCode: 'IN-201', customerName: '客户一', destinationWarehouseId: '9', destinationWarehouseCode: 'LAX9', destinationWarehouseName: 'LAX9',
|
|
skuCode: 'SKU-1', productNameZh: '货物一', unitType: 'PACKAGE' as const, palletId: null, palletNo: null, indivisible: false, packageCount: 5, productQuantity: 50, grossWeightKg: 50, volumeCbm: 1,
|
|
loadSequence: 1, version: 1, pickedPackageCount: 0, minPackageCount: 1, canAdjust: true, canRemove: true,
|
|
}
|
|
|
|
const plan = {
|
|
id: '99', planNo: 'LP-99', status: 'EDITING', bookingId: '88', containerNo: null, voyageNo: null, version: 2,
|
|
canAssign: true, canEdit: true, blockedReason: null, finalCompletionStatus: 'NOT_STARTED', pdaTaskId: null,
|
|
pdaTaskStatus: null, pdaTaskVersion: null,
|
|
coLoadGroups: [{ groupId: '9001', groupNo: 'CLG-9001', lockedPlanId: '99', memberOrderCount: 2,
|
|
inboundFragmentCount: 2, fullPackageCount: 12, memberInboundIds: ['201', '202'] }],
|
|
items: [item, { ...item, id: '702', inboundId: '202', inboundDetailId: '802', orderId: '302', orderNo: 'ORD-2', inboundCode: 'IN-202', packageCount: 7 }],
|
|
} satisfies SmartLoadingPlan
|
|
|
|
describe('smart loading plan co-load groups', () => {
|
|
it('uses the group snapshot already returned with the plan without per-inbound requests', () => {
|
|
const result = loadSmartLoadingPlanCoLoadGroups(plan)
|
|
expect(result.get('201')).toEqual({
|
|
groupId: '9001', groupNo: 'CLG-9001', lockedPlanId: '99', memberOrderCount: 2, inboundFragmentCount: 2, fullPackageCount: 12,
|
|
})
|
|
expect(result.get('202')).toBe(result.get('201'))
|
|
})
|
|
|
|
it('leaves ordinary plan items ungrouped', () => {
|
|
const result = loadSmartLoadingPlanCoLoadGroups({ ...plan, coLoadGroups: [] })
|
|
expect(result.size).toBe(0)
|
|
})
|
|
})
|