diff --git a/App/tests/unit/history-filters.test.tsx b/App/tests/unit/history-filters.test.tsx new file mode 100644 index 0000000..141e003 --- /dev/null +++ b/App/tests/unit/history-filters.test.tsx @@ -0,0 +1,36 @@ +import { describe, it, expect, vi } from "vitest"; +import { render, screen } from "@testing-library/react"; + +// HistoryFilters reads the URL via next/navigation; mock both hooks it uses. +vi.mock("next/navigation", () => ({ + useRouter: () => ({ push: vi.fn(), refresh: vi.fn() }), + useSearchParams: () => new URLSearchParams(""), +})); + +import { HistoryFilters } from "@/app/(portal)/history/history-filters"; + +const props = { + vessels: [{ id: "v1", name: "Vessel One" }], + accounts: [], + perPageOptions: [25, 50, 100], + defaultPerPage: 25, +}; + +describe("HistoryFilters", () => { + // Regression guard for issue #136: the "Approved From" / "Approved To" date + // filters were removed from PO History. They must not reappear. + it("does not render the Approved From / Approved To filters", () => { + render(); + expect(screen.queryByText("Approved From")).toBeNull(); + expect(screen.queryByText("Approved To")).toBeNull(); + }); + + it("still renders the remaining filters (created-date range, cost centre, accounting code, status)", () => { + render(); + expect(screen.getByText("From")).toBeInTheDocument(); + expect(screen.getByText("To")).toBeInTheDocument(); + expect(screen.getByText("Cost Centre")).toBeInTheDocument(); + expect(screen.getByText("Accounting Code")).toBeInTheDocument(); + expect(screen.getByText("Status")).toBeInTheDocument(); + }); +});