diff --git a/editor.planx.uk/src/components/Feedback/FeedbackPhaseBanner.test.tsx b/editor.planx.uk/src/components/Feedback/FeedbackPhaseBanner.test.tsx new file mode 100644 index 0000000000..fd4d20216a --- /dev/null +++ b/editor.planx.uk/src/components/Feedback/FeedbackPhaseBanner.test.tsx @@ -0,0 +1,64 @@ +import React from "react"; +import { axe, setup } from "testUtils"; + +import FeedbackPhaseBanner from "./FeedbackPhaseBanner"; + +describe("FeedbackPhaseBanner presentation and functionality", () => { + const handleFeedbackClick = jest.fn(); + const handleReportAnIssueClick = jest.fn(); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + test("renders PUBLIC BETA flag and buttons correctly", () => { + const { getByText } = setup( + , + ); + + expect(getByText("PUBLIC BETA")).toBeInTheDocument(); + expect(getByText("Report an issue with this page")).toBeInTheDocument(); + expect(getByText("feedback")).toBeInTheDocument(); + }); + + test("clicking on feedback link calls handleFeedbackClick", async () => { + const { getByText, user } = setup( + , + ); + + await user.click(getByText("feedback")); + expect(handleFeedbackClick).toHaveBeenCalledTimes(1); + }); + + test("clicking on 'Report an issue with this page' button calls handleReportAnIssueClick", async () => { + const { getByText, user } = setup( + , + ); + + await user.click(getByText("Report an issue with this page")); + expect(handleReportAnIssueClick).toHaveBeenCalledTimes(1); + }); +}); + +describe("FeedbackPhaseBanner accessibility", () => { + test("should have no accessibility violations", async () => { + const { container } = setup( + {}} + handleReportAnIssueClick={() => {}} + />, + ); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); +});