mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 11:08:12 +00:00
auto allocation and batch managemnt, tracking the train
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
autoFillPlacements,
|
||||
findMissingContainerNumberIssues,
|
||||
type ContainerUnitForPlacement,
|
||||
} from './container-placement.util';
|
||||
|
||||
describe('container-placement.util', () => {
|
||||
const units: ContainerUnitForPlacement[] = [
|
||||
{
|
||||
bookingId: 'b1',
|
||||
bookingContainerId: 'c1',
|
||||
unitIndex: 0,
|
||||
label: 'REF · 1/1 · 20GP',
|
||||
teuSlots: 1,
|
||||
sizeFt: 20,
|
||||
containerNumber: 'ABCD1234567',
|
||||
},
|
||||
{
|
||||
bookingId: 'b2',
|
||||
bookingContainerId: 'c2',
|
||||
unitIndex: 0,
|
||||
label: 'REF2 · 1/1 · 40GP',
|
||||
teuSlots: 2,
|
||||
sizeFt: 40,
|
||||
containerNumber: null,
|
||||
},
|
||||
];
|
||||
|
||||
it('auto-fills placements across slots', () => {
|
||||
const placements = autoFillPlacements(units, [1, 2]);
|
||||
expect(placements).toHaveLength(2);
|
||||
expect(placements[0].sequenceNo).toBe(1);
|
||||
expect(placements[1].sequenceNo).toBe(2);
|
||||
});
|
||||
|
||||
it('reports missing container numbers only when placement is empty', () => {
|
||||
const placements = autoFillPlacements(units, [1, 2]);
|
||||
const issues = findMissingContainerNumberIssues(units, placements);
|
||||
expect(issues).toHaveLength(0);
|
||||
expect(placements[1].containerNumber).toMatch(/^TBD-/);
|
||||
});
|
||||
|
||||
it('generates TBD placeholder for missing container numbers', () => {
|
||||
const single: ContainerUnitForPlacement[] = [
|
||||
{
|
||||
bookingId: 'b2',
|
||||
bookingReference: 'BK-2026-000033',
|
||||
bookingContainerId: 'c2',
|
||||
unitIndex: 0,
|
||||
label: 'REF2 · 1/1 · 40GP',
|
||||
teuSlots: 2,
|
||||
sizeFt: 40,
|
||||
containerNumber: null,
|
||||
},
|
||||
];
|
||||
const placements = autoFillPlacements(single, [1]);
|
||||
expect(placements[0].containerNumber).toBe('TBD-BK-2026-000033-1');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user