Skip to content

Commit

Permalink
refactor: update to remove userEvent and access via setup()
Browse files Browse the repository at this point in the history
- As per: #2813 (comment)
  • Loading branch information
Mike-Heneghan committed Feb 26, 2024
1 parent d8d9e0f commit 7a484a5
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions editor.planx.uk/src/components/Feedback/MoreInfoFeedback.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@testing-library/jest-dom/extend-expect";

import { fireEvent, waitFor } from "@testing-library/react";
// eslint-disable-next-line no-restricted-imports
import userEvent from "@testing-library/user-event";
import {
getInternalFeedbackMetadata,
insertFeedbackMutation,
Expand Down Expand Up @@ -64,17 +60,16 @@ describe("MoreInfoFeedbackComponent presentation and functionality", () => {

// Form submission
test("Submitting feedback changes view to thank you message", async () => {
const { getByText, getByTestId } = setup(<MoreInfoFeedbackComponent />);
const { getByText, getByTestId, user } = setup(
<MoreInfoFeedbackComponent />,
);

fireEvent.click(getByText("Yes"));
await waitFor(() => {
expect(getByTestId("userCommentTextarea")).toBeInTheDocument();
});

await userEvent.type(
getByTestId("userCommentTextarea"),
"Great help, thanks!",
);
await user.type(getByTestId("userCommentTextarea"), "Great help, thanks!");

fireEvent.click(getByText("Send feedback"));
await waitFor(() => {
Expand Down Expand Up @@ -129,7 +124,7 @@ describe("MoreInfoFeedbackComponent accessibility", () => {
});

test("Thank you view should have no accessibility violations", async () => {
const { container, getByText, getByTestId } = setup(
const { container, getByText, getByTestId, user } = setup(
<MoreInfoFeedbackComponent />,
);

Expand All @@ -138,10 +133,7 @@ describe("MoreInfoFeedbackComponent accessibility", () => {
expect(getByTestId("userCommentTextarea")).toBeInTheDocument();
});

await userEvent.type(
getByTestId("userCommentTextarea"),
"Great help, thanks!",
);
await user.type(getByTestId("userCommentTextarea"), "Great help, thanks!");

fireEvent.click(getByText("Send feedback"));

Expand Down

0 comments on commit 7a484a5

Please sign in to comment.