import { describe, expect, it } from "vitest"; import type { BookingListRow } from "@/types/booking"; import { groupBookingsForOperationsQueue } from "./groupBookingsForOperationsQueue"; function row( id: string, opts: Partial = {}, ): 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"); }); });