From d3b5e0f31ea6115abc55ea1938b7e827471b676b Mon Sep 17 00:00:00 2001 From: Jo Humphrey <31373245+jamdelion@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:07:25 +0000 Subject: [PATCH 1/2] Add tests for accessibility and no error on render [skip pizza] --- .../VerifyEmail/tests/VerifyEmail.test.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx b/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx index d2f322a8ba..c380304199 100644 --- a/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx +++ b/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx @@ -1,17 +1,29 @@ import { screen } from "@testing-library/react"; import React from "react"; import { setup } from "testUtils"; +import { axe } from "vitest-axe"; import { VerifyEmail } from "../VerifyEmail"; describe("when the VerifyEmail component renders", () => { - it("displays the email address input", () => { + beforeEach(() => { setup(); - + }); + it("displays the email address input", () => { expect(screen.queryByText("Verify your email address")).toBeInTheDocument(); expect(screen.queryByLabelText("Email address")).toBeInTheDocument(); }); - it.todo("should not display an error message"); + it("should not display an error message", () => { + expect( + screen.queryByText("Sorry, something went wrong. Please try again."), + ).not.toBeInTheDocument(); + }); + it("should not have any accessibility violations", async () => { + const { container } = setup(); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); }); describe("when the user submits a correct email address to the verifyEmail component", () => { From 9729bb6730c90bd300e2db85dacef486e0a5586b Mon Sep 17 00:00:00 2001 From: Jo Humphrey <31373245+jamdelion@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:37:25 +0000 Subject: [PATCH 2/2] Readd after merge conflict --- .../tests/VerifySubmissionEmail.test.tsx | 21 +++++++++- .../VerifyEmail/tests/VerifyEmail.test.tsx | 40 ------------------- 2 files changed, 19 insertions(+), 42 deletions(-) delete mode 100644 editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx diff --git a/editor.planx.uk/src/pages/SubmissionDownload/tests/VerifySubmissionEmail.test.tsx b/editor.planx.uk/src/pages/SubmissionDownload/tests/VerifySubmissionEmail.test.tsx index 793713f518..b087559f4b 100644 --- a/editor.planx.uk/src/pages/SubmissionDownload/tests/VerifySubmissionEmail.test.tsx +++ b/editor.planx.uk/src/pages/SubmissionDownload/tests/VerifySubmissionEmail.test.tsx @@ -1,19 +1,36 @@ import { screen } from "@testing-library/react"; import React from "react"; import { setup } from "testUtils"; +import { axe } from "vitest-axe"; import { VerifySubmissionEmail } from "../VerifySubmissionEmail"; describe("when the VerifySubmissionEmail component renders", () => { - it("displays the email address input", () => { + beforeEach(() => { setup(); + }); + it("displays the email address input", () => { expect( screen.queryByText("Verify your submission email address"), ).toBeInTheDocument(); expect(screen.queryByLabelText("Email address")).toBeInTheDocument(); }); - it.todo("should not display an error message"); + + it("should not display an error message", () => { + expect( + screen.queryByText("Sorry, something went wrong. Please try again."), + ).not.toBeInTheDocument(); + + it("should not have any accessibility violations", async () => { + const { container } = setup( + , + ); + + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); + }); }); describe("when the user submits a correct email address", () => { diff --git a/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx b/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx deleted file mode 100644 index c380304199..0000000000 --- a/editor.planx.uk/src/pages/VerifyEmail/tests/VerifyEmail.test.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { screen } from "@testing-library/react"; -import React from "react"; -import { setup } from "testUtils"; -import { axe } from "vitest-axe"; - -import { VerifyEmail } from "../VerifyEmail"; - -describe("when the VerifyEmail component renders", () => { - beforeEach(() => { - setup(); - }); - it("displays the email address input", () => { - expect(screen.queryByText("Verify your email address")).toBeInTheDocument(); - expect(screen.queryByLabelText("Email address")).toBeInTheDocument(); - }); - it("should not display an error message", () => { - expect( - screen.queryByText("Sorry, something went wrong. Please try again."), - ).not.toBeInTheDocument(); - }); - it("should not have any accessibility violations", async () => { - const { container } = setup(); - - const results = await axe(container); - expect(results).toHaveNoViolations(); - }); -}); - -describe("when the user submits a correct email address to the verifyEmail component", () => { - it.todo("displays visual feedback to the user"); - it.todo("downloads the application file"); -}); - -describe("when the user submits an incorrect email address to the verifyEmail component", () => { - it.todo("displays a suitable error message"); -}); - -describe("when user submits an email address to the verifyEmail component and there is a server-side issue", () => { - it.todo("displays a suitable error message"); -});