From efa9d90ddbf7ffcb5fd00eb793f9003f2fedeb80 Mon Sep 17 00:00:00 2001 From: Hardik Date: Fri, 26 Jun 2026 03:46:03 +0530 Subject: [PATCH] test(history): cover removal of Approved From/To filters (#136) Adds a unit test for HistoryFilters asserting the Approved From / Approved To date filters no longer render (the issue #136 change) while the remaining filters (created-date range, cost centre, accounting code, status) stay. Satisfies the test-presence policy that PR #137 was missing. Co-Authored-By: Claude Opus 4.8 --- App/tests/unit/history-filters.test.tsx | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 App/tests/unit/history-filters.test.tsx 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(); + }); +});