From fb59971b5cd8e1ca38cbacc21c3cc0a8e8a9af73 Mon Sep 17 00:00:00 2001 From: Robert Hasselle <123402053+rhasselle-oddball@users.noreply.github.com> Date: Tue, 10 Dec 2024 11:47:09 -0600 Subject: [PATCH] add required email for 0845 (#33425) --- .../simple-forms/21-0845/config/form.js | 17 +++++++ .../21-0845/containers/IntroductionPage.jsx | 3 ++ .../21-0845/pages/authorizerContactInfo.js | 31 ++++-------- .../21-0845/pages/veteranContactInfo.js | 22 ++++++++ .../e2e/fixtures/data/authTypeNonVet.json | 1 + .../tests/e2e/fixtures/data/authTypeVet.json | 2 + .../tests/e2e/fixtures/data/noAuthType.json | 3 ++ .../pages/authorizerContactInfo.unit.spec.jsx | 24 ++++++++- .../pages/veteranContactInfo.unit.spec.jsx | 50 +++++++++++++++++++ 9 files changed, 131 insertions(+), 22 deletions(-) create mode 100644 src/applications/simple-forms/21-0845/pages/veteranContactInfo.js create mode 100644 src/applications/simple-forms/21-0845/tests/pages/veteranContactInfo.unit.spec.jsx diff --git a/src/applications/simple-forms/21-0845/config/form.js b/src/applications/simple-forms/21-0845/config/form.js index 46141a0adca5..8a21f6be3ed9 100644 --- a/src/applications/simple-forms/21-0845/config/form.js +++ b/src/applications/simple-forms/21-0845/config/form.js @@ -14,6 +14,7 @@ import { AUTHORIZER_TYPES, INFORMATION_SCOPES } from '../definitions/constants'; import authorizerTypePg from '../pages/authorizerType'; import veteranPersonalInfoPg from '../pages/veteranPersonalInfo'; import veteranIdInfoPg from '../pages/veteranIdInfo'; +import veteranContactInfoPg from '../pages/veteranContactInfo'; import thirdPartyTypePg from '../pages/thirdPartyType'; import personNamePg from '../pages/personName'; import personAddressPg from '../pages/personAddress'; @@ -60,6 +61,7 @@ const formConfig = { formId: '21-0845', dev: { showNavLinks: !window.Cypress, + collapsibleNavLinks: true, }, saveInProgress: { messages: { @@ -172,6 +174,21 @@ const formConfig = { }, }, }, + veteranContactInfoChapter: { + title: 'Your contact information', + pages: { + vetContactInfoPage: { + path: 'veteran-contact-information', + title: 'Your contact information', + depends: { + authorizerType: AUTHORIZER_TYPES.VETERAN, + }, + uiSchema: veteranContactInfoPg.uiSchema, + schema: veteranContactInfoPg.schema, + scrollAndFocusTarget: pageFocusScroll(), + }, + }, + }, veteranIdentificationInfoChapter: { title: ({ formData }) => formData?.authorizerType === AUTHORIZER_TYPES.VETERAN diff --git a/src/applications/simple-forms/21-0845/containers/IntroductionPage.jsx b/src/applications/simple-forms/21-0845/containers/IntroductionPage.jsx index d173fb0b597a..1b3397cb1d5d 100644 --- a/src/applications/simple-forms/21-0845/containers/IntroductionPage.jsx +++ b/src/applications/simple-forms/21-0845/containers/IntroductionPage.jsx @@ -126,6 +126,9 @@ class IntroductionPage extends React.Component { prefillEnabled={formConfig.prefillEnabled} messages={formConfig.savedFormMessages} pageList={pageList} + devOnly={{ + forceShowFormControls: true, + }} startText="Start your authorization" unauthStartText="Sign in to start your authorization" verifiedPrefillAlert={ diff --git a/src/applications/simple-forms/21-0845/pages/authorizerContactInfo.js b/src/applications/simple-forms/21-0845/pages/authorizerContactInfo.js index 5b3374198855..e475a1e990d8 100644 --- a/src/applications/simple-forms/21-0845/pages/authorizerContactInfo.js +++ b/src/applications/simple-forms/21-0845/pages/authorizerContactInfo.js @@ -1,31 +1,22 @@ -import definitions from 'vets-json-schema/dist/definitions.json'; +import { + emailToSendNotificationsSchema, + emailToSendNotificationsUI, + phoneSchema, + phoneUI, +} from 'platform/forms-system/src/js/web-component-patterns'; /** @type {PageSchema} */ export default { uiSchema: { - authorizerPhone: { - 'ui:title': 'Phone number', - 'ui:errorMessages': { - required: 'Please enter a phone number.', - pattern: - 'Please enter a 10-digit phone number (with or without dashes).', - }, - }, - authorizerEmail: { - 'ui:title': 'Email address', - 'ui:widget': 'email', - 'ui:errorMessages': { - format: - 'Enter a valid email address using the format email@domain.com. Your email address can only have letters, numbers, the @ symbol and a period, with no spaces.', - }, - }, + authorizerPhone: phoneUI(), + authorizerEmail: emailToSendNotificationsUI(), }, schema: { type: 'object', - required: ['authorizerPhone'], + required: ['authorizerPhone', 'authorizerEmail'], properties: { - authorizerPhone: definitions.phone, - authorizerEmail: definitions.email, + authorizerPhone: phoneSchema, + authorizerEmail: emailToSendNotificationsSchema, }, }, }; diff --git a/src/applications/simple-forms/21-0845/pages/veteranContactInfo.js b/src/applications/simple-forms/21-0845/pages/veteranContactInfo.js new file mode 100644 index 000000000000..42804bbc7c84 --- /dev/null +++ b/src/applications/simple-forms/21-0845/pages/veteranContactInfo.js @@ -0,0 +1,22 @@ +import { + emailToSendNotificationsSchema, + emailToSendNotificationsUI, + phoneSchema, + phoneUI, +} from 'platform/forms-system/src/js/web-component-patterns'; + +/** @type {PageSchema} */ +export default { + uiSchema: { + veteranPhone: phoneUI(), + veteranEmail: emailToSendNotificationsUI(), + }, + schema: { + type: 'object', + required: ['veteranEmail'], + properties: { + veteranPhone: phoneSchema, + veteranEmail: emailToSendNotificationsSchema, + }, + }, +}; diff --git a/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeNonVet.json b/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeNonVet.json index 35cca1873026..6de86234c528 100644 --- a/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeNonVet.json +++ b/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeNonVet.json @@ -14,6 +14,7 @@ "postalCode": "12345" }, "authorizerPhone": "5555555555", + "authorizerEmail": "jack@authorizer.com", "veteranFullName": { "first": "John", "middle": "", diff --git a/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeVet.json b/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeVet.json index b6943379ade6..d95ec01366c9 100644 --- a/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeVet.json +++ b/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/authTypeVet.json @@ -6,6 +6,8 @@ "middle": "", "last": "Veteran" }, + "veteranEmail": "john@veteran.com", + "veteranPhone": "5555555555", "veteranDateOfBirth": "2000-01-01", "veteranSSN": "111223333", "thirdPartyType": "person", diff --git a/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/noAuthType.json b/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/noAuthType.json index e2565db27a3d..bf4120e4fb0b 100644 --- a/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/noAuthType.json +++ b/src/applications/simple-forms/21-0845/tests/e2e/fixtures/data/noAuthType.json @@ -13,11 +13,14 @@ "postalCode": "12345" }, "authorizerPhone": "5555555555", + "authorizerEmail": "jack@authorizer.com", "veteranFullName": { "first": "John", "middle": "", "last": "Veteran" }, + "veteranEmail": "john@veteran.com", + "veteranPhone": "5555555555", "veteranDateOfBirth": "2000-01-01", "veteranSSN": "111223333", "thirdPartyType": "organization", diff --git a/src/applications/simple-forms/21-0845/tests/pages/authorizerContactInfo.unit.spec.jsx b/src/applications/simple-forms/21-0845/tests/pages/authorizerContactInfo.unit.spec.jsx index 4e129a500a94..b31b611b98d0 100644 --- a/src/applications/simple-forms/21-0845/tests/pages/authorizerContactInfo.unit.spec.jsx +++ b/src/applications/simple-forms/21-0845/tests/pages/authorizerContactInfo.unit.spec.jsx @@ -1,6 +1,8 @@ import { testNumberOfErrorsOnSubmit, + testNumberOfErrorsOnSubmitForWebComponents, testNumberOfFields, + testNumberOfWebComponentFields, } from '../../../shared/tests/pages/pageTests.spec'; import formConfig from '../../config/form'; @@ -11,7 +13,7 @@ const { const pageTitle = 'Your contact information'; -const expectedNumberOfFields = 2; +const expectedNumberOfFields = 0; testNumberOfFields( formConfig, schema, @@ -20,7 +22,7 @@ testNumberOfFields( pageTitle, ); -const expectedNumberOfErrors = 1; +const expectedNumberOfErrors = 0; testNumberOfErrorsOnSubmit( formConfig, schema, @@ -28,3 +30,21 @@ testNumberOfErrorsOnSubmit( expectedNumberOfErrors, pageTitle, ); + +const expectedNumberOfWebComponentFields = 2; +testNumberOfWebComponentFields( + formConfig, + schema, + uiSchema, + expectedNumberOfWebComponentFields, + pageTitle, +); + +const expectedNumberOfWebComponentErrors = 2; +testNumberOfErrorsOnSubmitForWebComponents( + formConfig, + schema, + uiSchema, + expectedNumberOfWebComponentErrors, + pageTitle, +); diff --git a/src/applications/simple-forms/21-0845/tests/pages/veteranContactInfo.unit.spec.jsx b/src/applications/simple-forms/21-0845/tests/pages/veteranContactInfo.unit.spec.jsx new file mode 100644 index 000000000000..8a465200bd09 --- /dev/null +++ b/src/applications/simple-forms/21-0845/tests/pages/veteranContactInfo.unit.spec.jsx @@ -0,0 +1,50 @@ +import { + testNumberOfErrorsOnSubmit, + testNumberOfErrorsOnSubmitForWebComponents, + testNumberOfFields, + testNumberOfWebComponentFields, +} from '../../../shared/tests/pages/pageTests.spec'; +import formConfig from '../../config/form'; + +const { + schema, + uiSchema, +} = formConfig.chapters.veteranContactInfoChapter.pages.vetContactInfoPage; + +const pageTitle = 'Your contact information'; + +const expectedNumberOfFields = 0; +testNumberOfFields( + formConfig, + schema, + uiSchema, + expectedNumberOfFields, + pageTitle, +); + +const expectedNumberOfErrors = 0; +testNumberOfErrorsOnSubmit( + formConfig, + schema, + uiSchema, + expectedNumberOfErrors, + pageTitle, +); + +const expectedNumberOfWebComponentFields = 2; +testNumberOfWebComponentFields( + formConfig, + schema, + uiSchema, + expectedNumberOfWebComponentFields, + pageTitle, +); + +const expectedNumberOfWebComponentErrors = 1; +testNumberOfErrorsOnSubmitForWebComponents( + formConfig, + schema, + uiSchema, + expectedNumberOfWebComponentErrors, + pageTitle, +);