From 0dfa380a07be113cdb691eaaa5b245a54f91afc2 Mon Sep 17 00:00:00 2001 From: Melissa Hart <48496458+MelissaDTH@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:05:12 +0200 Subject: [PATCH] fix(project): improve form validation on account page --- .../src/components/Form/FormSection.tsx | 2 +- .../PersonalDetailsForm.test.tsx.snap | 18 +++++++++--------- .../src/components/TextField/TextField.tsx | 2 +- .../DemoConfigDialog.test.tsx.snap | 2 +- platforms/web/test-e2e/tests/register_test.ts | 8 +++++++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/ui-react/src/components/Form/FormSection.tsx b/packages/ui-react/src/components/Form/FormSection.tsx index eb4daf399..bd6737589 100644 --- a/packages/ui-react/src/components/Form/FormSection.tsx +++ b/packages/ui-react/src/components/Form/FormSection.tsx @@ -94,7 +94,7 @@ export function FormSection({ try { setFormState((s) => { - return { ...s, isBusy: true }; + return { ...s, isBusy: true, errors: [] }; }); response = await onSubmit(values); } catch (error: unknown) { diff --git a/packages/ui-react/src/components/PersonalDetailsForm/__snapshots__/PersonalDetailsForm.test.tsx.snap b/packages/ui-react/src/components/PersonalDetailsForm/__snapshots__/PersonalDetailsForm.test.tsx.snap index fe029a7ed..e05b7b349 100644 --- a/packages/ui-react/src/components/PersonalDetailsForm/__snapshots__/PersonalDetailsForm.test.tsx.snap +++ b/packages/ui-react/src/components/PersonalDetailsForm/__snapshots__/PersonalDetailsForm.test.tsx.snap @@ -31,7 +31,7 @@ exports[` > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > > Renders with errors 1`] = ` > = ({ const inputType = 'type' in otherInputProps ? otherInputProps.type : 'text'; const ariaAttributes = { - 'aria-invalid': Boolean(error && !value), + 'aria-invalid': Boolean(error && !!value), 'aria-describedby': helperTextId, } as const; diff --git a/platforms/web/src/components/DemoConfigDialog/__snapshots__/DemoConfigDialog.test.tsx.snap b/platforms/web/src/components/DemoConfigDialog/__snapshots__/DemoConfigDialog.test.tsx.snap index 01b11132f..b2103ad89 100644 --- a/platforms/web/src/components/DemoConfigDialog/__snapshots__/DemoConfigDialog.test.tsx.snap +++ b/platforms/web/src/components/DemoConfigDialog/__snapshots__/DemoConfigDialog.test.tsx.snap @@ -65,7 +65,7 @@ exports[` > renders and matches snapshot error dialog 1`] = ` > { + Scenario(`The Sign up modal will invalidate upon submit only if a value is inputted - ${providerName}`, async ({ I }) => { I.click('Continue'); I.seeElementInDOM('div[class*=formFeedback]'); // This element can be visually hidden through CSS + I.seeAttributesOnElements('input[name="email"]', { 'aria-invalid': 'false' }); + I.seeAttributesOnElements('input[name="password"]', { 'aria-invalid': 'false' }); + + I.fillField('Email', 'test'); + I.fillField('Password', 'test'); + I.click('Continue'); I.seeAttributesOnElements('input[name="email"]', { 'aria-invalid': 'true' }); I.seeAttributesOnElements('input[name="password"]', { 'aria-invalid': 'true' }); });