test(history): cover removal of Approved From/To filters (#136)
All checks were successful
PR checks / checks (pull_request) Successful in 51s
PR checks / integration (pull_request) Successful in 32s

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 <noreply@anthropic.com>
This commit is contained in:
Hardik 2026-06-26 03:46:03 +05:30
parent 5218eb3717
commit efa9d90ddb

View file

@ -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(<HistoryFilters {...props} />);
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(<HistoryFilters {...props} />);
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();
});
});