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

Conversation

Mike-Heneghan
Copy link
Contributor

What

  • Add tests for the FeedbackPhaseBanner component functionality and accessibility

Why

  • Improving test coverage

@Mike-Heneghan Mike-Heneghan self-assigned this Feb 26, 2024
Copy link

github-actions bot commented Feb 26, 2024

Removed vultr server and associated DNS entries

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change required!

@@ -0,0 +1,67 @@
import "@testing-library/jest-dom/extend-expect";

import { fireEvent } from "@testing-library/react";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't something we're currently enforcing (maybe we should?) but fireEvent is rarely needed and we can rely on user for an experience which is closer to the real DOM.

Instead of importing this we can can use the user returned from setup() like so -

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);
});

The notable change here is that this is now an async function - I think the test will just fail without the await before user.click().

Docs: https://testing-library.com/docs/dom-testing-library/api-events/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: 2035632

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fixes here! ✅

Mike-Heneghan added a commit that referenced this pull request Feb 26, 2024
@Mike-Heneghan Mike-Heneghan merged commit e750146 into main Feb 26, 2024
12 checks passed
@Mike-Heneghan Mike-Heneghan deleted the mh/feedback-phase-banner-testing branch February 26, 2024 15:23
@Mike-Heneghan
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants