From fef7e5cc001c5079d0f6064c068a5ca28246a9d7 Mon Sep 17 00:00:00 2001 From: FleetAdmiralJakob Date: Tue, 2 Jan 2024 13:07:24 +0100 Subject: [PATCH] refactor: Improved the accessibility of the contact page and a contact page test --- e2e-tests/email.spec.ts | 9 ++++----- src/pages/contact/index.tsx | 14 ++++++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/e2e-tests/email.spec.ts b/e2e-tests/email.spec.ts index 251e383b..bb60dd3c 100644 --- a/e2e-tests/email.spec.ts +++ b/e2e-tests/email.spec.ts @@ -1,4 +1,5 @@ import { expect, type Page, test } from "@playwright/test"; +import contactTranslations from "../public/locales/en/contact.json"; const goToContactAndFillForm = async ( page: Page, @@ -42,9 +43,7 @@ test("invalid email", async ({ page }) => { await page.click("button[type=submit]"); // Check the error element - expect( - ( - await page.waitForSelector('p[data-testId="email error message"]') - ).isVisible(), - ).toBeTruthy(); + await expect( + page.getByText(contactTranslations["invalid email"]), + ).toBeVisible(); }); diff --git a/src/pages/contact/index.tsx b/src/pages/contact/index.tsx index 81fc54dd..3b36acde 100644 --- a/src/pages/contact/index.tsx +++ b/src/pages/contact/index.tsx @@ -80,7 +80,9 @@ const ContactUs = () => {
{errors.firstName && ( -

{errors.firstName.message}

+

+ {errors.firstName.message} +

)}
{errors.lastName && ( -

{errors.lastName.message}

+

+ {errors.lastName.message} +

)}
{errors.email && ( -

+

{errors.email.message}

)} @@ -124,7 +128,9 @@ const ContactUs = () => {
{errors.message && ( -

{errors.message.message}

+

+ {errors.message.message} +

)}