Skip to content

Commit

Permalink
test: Add tests for inaccuracy, add missing test for comment
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Mar 27, 2024
1 parent ffa8c48 commit 76040f8
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions editor.planx.uk/src/components/Feedback/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,46 @@ describe("Feedback component triage journey", () => {
await user.click(getByText("feedback"));
await user.click(getByRole("button", { name: "Comment" }));

await waitFor(() => {});
expect(getByText("Share a comment")).toBeInTheDocument();

await user.type(getByTestId("userCommentTextarea"), "What about 3D maps");

await user.click(getByText("Send feedback"));

await waitFor(() => {
expect(getByText("Share a comment")).toBeInTheDocument();
expect(getInternalFeedbackMetadata).toBeCalledTimes(1);
expect(insertFeedbackMutation).toBeCalledTimes(1);
expect(getByText("Thank you for your feedback.")).toBeInTheDocument();
});
});

test("Selecting 'Inaccuracy' from triage scrolls the comment form into view", async () => {
const { getByText, getByRole, user } = setup(<Feedback />);

await user.click(getByText("feedback"));
await user.click(getByRole("button", { name: "Inaccuracy" }));

await user.type(getByTestId("userCommentTextarea"), "This page is great");
expect(scrollIntoViewMock).toBeCalledTimes(2);

await waitFor(() => {
expect(getByText("Report an inaccuracy")).toBeInTheDocument();
});
});

test("Submitting 'Inaccuracy' form changes view to thank you message", async () => {
const { getByText, getByTestId, getByRole, user } = setup(<Feedback />);

await user.click(getByText("feedback"));
await user.click(getByRole("button", { name: "Inaccuracy" }));

await waitFor(() => {});
expect(getByText("Report an inaccuracy")).toBeInTheDocument();

await user.type(
getByTestId("userCommentTextarea"),
"This information is wrong",
);

await user.click(getByText("Send feedback"));

Expand Down

0 comments on commit 76040f8

Please sign in to comment.