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 <noreply@anthropic.com>
This commit is contained in:
parent
5218eb3717
commit
efa9d90ddb
1 changed files with 36 additions and 0 deletions
36
App/tests/unit/history-filters.test.tsx
Normal file
36
App/tests/unit/history-filters.test.tsx
Normal 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();
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Reference in a new issue