mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 04:20:55 +00:00
booking operations and trains scheduling also allocations
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { BookingListRow } from "@/types/booking";
|
||||
import { groupBookingsForOperationsQueue } from "./groupBookingsForOperationsQueue";
|
||||
|
||||
function row(
|
||||
id: string,
|
||||
opts: Partial<BookingListRow> = {},
|
||||
): BookingListRow {
|
||||
return {
|
||||
id,
|
||||
reference: id,
|
||||
customerLabel: "Customer",
|
||||
status: "PAID",
|
||||
scheduledDate: opts.scheduledDate ?? "2026-06-20T08:00:00.000Z",
|
||||
totalAmount: 1000,
|
||||
paymentCurrency: "ETB",
|
||||
paymentStatus: "PAID",
|
||||
tradeDirection: "IMPORT",
|
||||
freightType: "CONTAINER",
|
||||
originLabel: "A",
|
||||
destinationLabel: "B",
|
||||
priorityScore: opts.priorityScore ?? 10,
|
||||
createdAt: "2026-06-01T00:00:00.000Z",
|
||||
...opts,
|
||||
};
|
||||
}
|
||||
|
||||
describe("groupBookingsForOperationsQueue", () => {
|
||||
it("separates government from commercial 3-hour buckets", () => {
|
||||
const result = groupBookingsForOperationsQueue([
|
||||
row("c1", { isGovernment: false }),
|
||||
row("g1", { isGovernment: true, governmentInstitution: "Ministry" }),
|
||||
]);
|
||||
expect(result.government).toHaveLength(1);
|
||||
expect(result.government[0]?.id).toBe("g1");
|
||||
expect(result.commercial).toHaveLength(1);
|
||||
expect(result.commercial[0]?.bookings[0]?.id).toBe("c1");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user