Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: FeedbackPhaseBanner component functionality and accessibility #2815

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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(
<FeedbackPhaseBanner
handleFeedbackClick={handleFeedbackClick}
handleReportAnIssueClick={handleReportAnIssueClick}
/>,
);

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(
<FeedbackPhaseBanner
handleFeedbackClick={handleFeedbackClick}
handleReportAnIssueClick={handleReportAnIssueClick}
/>,
);

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(
<FeedbackPhaseBanner
handleFeedbackClick={handleFeedbackClick}
handleReportAnIssueClick={handleReportAnIssueClick}
/>,
);

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(
<FeedbackPhaseBanner
handleFeedbackClick={() => {}}
handleReportAnIssueClick={() => {}}
/>,
);

const results = await axe(container);
expect(results).toHaveNoViolations();
});
});
Loading