From e3e92a07a5ce1ab12736ad8253a69eb48ca4b59c Mon Sep 17 00:00:00 2001 From: Michael Clement <18408628+michaelclement@users.noreply.github.com> Date: Fri, 27 Dec 2024 16:12:17 -0600 Subject: [PATCH 1/3] 99306 Copy changes and conditional updates - form 10-7959c (#33738) * updated missingfileoverview to properly catch name field * updated e2e tests * added updateSchema for applicantEmail * copy changes --- .../10-7959C/chapters/applicantInformation.js | 17 +++++++++++++++++ .../10-7959C/chapters/medicareInformation.js | 8 ++------ .../ivc-champva/10-7959C/config/constants.js | 2 ++ .../tests/e2e/fixtures/data/maximal-test.json | 1 + .../tests/e2e/fixtures/data/minimal-test.json | 1 + .../e2e/fixtures/data/no-medicare-yes-ohi.json | 1 + .../fixtures/data/no-medicare-yes-primary.json | 1 + .../tests/e2e/fixtures/data/single-upload.json | 1 + .../tests/e2e/fixtures/data/test-data.json | 1 + .../e2e/fixtures/data/yes-medicare-no-ohi.json | 1 + .../fixtures/data/yes-medicare-yes-primary.json | 1 + .../fileUploads/MissingFileOverview.jsx | 2 +- 12 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/applications/ivc-champva/10-7959C/chapters/applicantInformation.js b/src/applications/ivc-champva/10-7959C/chapters/applicantInformation.js index e30972998461..e273271bf763 100644 --- a/src/applications/ivc-champva/10-7959C/chapters/applicantInformation.js +++ b/src/applications/ivc-champva/10-7959C/chapters/applicantInformation.js @@ -123,6 +123,23 @@ export const applicantContactInfoSchema = { ), applicantPhone: phoneUI(), applicantEmail: emailUI(), + 'ui:options': { + updateSchema: (formData, formSchema) => { + const fs = JSON.parse(JSON.stringify(formSchema)); // Deep copy + // If user is the applicant, they have already given us an email + // previously in signer section, so remove the field on this page: + if (formData.certifierRole === 'applicant') { + delete fs.properties.applicantEmail; + // Just in case we require this email field in future, be sure to un-require it: + fs.required = fs.required.filter(f => f !== 'applicantEmail'); + } else if (fs.properties.applicantEmail === undefined) { + // Replace email field if we previously dropped it and + // user is not the applicant: + fs.properties.applicantEmail = emailSchema; + } + return fs; + }, + }, }, schema: { type: 'object', diff --git a/src/applications/ivc-champva/10-7959C/chapters/medicareInformation.js b/src/applications/ivc-champva/10-7959C/chapters/medicareInformation.js index 6dd6a8a3c180..c33bf171b042 100644 --- a/src/applications/ivc-champva/10-7959C/chapters/medicareInformation.js +++ b/src/applications/ivc-champva/10-7959C/chapters/medicareInformation.js @@ -225,12 +225,8 @@ export const applicantMedicareABUploadSchema = {
Upload a copy of one of these documents: If you don’t have a copy to upload now, you can send it by mail or diff --git a/src/applications/ivc-champva/10-7959C/config/constants.js b/src/applications/ivc-champva/10-7959C/config/constants.js index 4201de6eecdb..8c25d958810b 100644 --- a/src/applications/ivc-champva/10-7959C/config/constants.js +++ b/src/applications/ivc-champva/10-7959C/config/constants.js @@ -25,6 +25,8 @@ export const officeAddress = ( P.O. Box 469063
Denver, CO 80246-9063 +
+ United States of America ); export const officeFaxNum = '3033317808'; diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/maximal-test.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/maximal-test.json index 499f531550f3..9257ae801a23 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/maximal-test.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/maximal-test.json @@ -73,6 +73,7 @@ ], "consentToMailMissingRequiredFiles": true, "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones" } } diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/minimal-test.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/minimal-test.json index 998e60d99ed3..ebc635c6f755 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/minimal-test.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/minimal-test.json @@ -21,6 +21,7 @@ "suffix": "III" }, "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones" } } diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-ohi.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-ohi.json index 9fa29264598d..6271739f09fe 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-ohi.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-ohi.json @@ -60,6 +60,7 @@ ], "consentToMailMissingRequiredFiles": true, "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones" } } diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-primary.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-primary.json index 3edc10d0b600..21d9fb554377 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-primary.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/no-medicare-yes-primary.json @@ -38,6 +38,7 @@ ], "consentToMailMissingRequiredFiles": true, "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones" } } diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/single-upload.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/single-upload.json index 6392a266a235..1cd42df304ed 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/single-upload.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/single-upload.json @@ -1,5 +1,6 @@ { "certifierRole": "applicant", + "certifierEmail": "certifier@email.gov", "primaryInsuranceCard": [ { "name": "example_upload.png", diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/test-data.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/test-data.json index c46b6a24620a..d332ce4213d1 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/test-data.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/test-data.json @@ -48,6 +48,7 @@ "secondaryMedigapPlan": "M", "secondaryAdditionalComments": "Additional secondary comment", "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones", "consentToMailMissingRequiredFiles": true } diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-no-ohi.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-no-ohi.json index 1c1ac760cda8..570c68b1b7a4 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-no-ohi.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-no-ohi.json @@ -30,6 +30,7 @@ }, "consentToMailMissingRequiredFiles": true, "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones" } } diff --git a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-yes-primary.json b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-yes-primary.json index a43de61c1eb7..7e87c7c97753 100644 --- a/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-yes-primary.json +++ b/src/applications/ivc-champva/10-7959C/tests/e2e/fixtures/data/yes-medicare-yes-primary.json @@ -39,6 +39,7 @@ "primaryAdditionalComments": "Additional primary comment", "consentToMailMissingRequiredFiles": true, "certifierRole": "other", + "certifierEmail": "certifier@email.gov", "signature": "Certifier Jones" } } diff --git a/src/applications/ivc-champva/shared/components/fileUploads/MissingFileOverview.jsx b/src/applications/ivc-champva/shared/components/fileUploads/MissingFileOverview.jsx index b5a51e334f5d..c7c12ab13f9b 100644 --- a/src/applications/ivc-champva/shared/components/fileUploads/MissingFileOverview.jsx +++ b/src/applications/ivc-champva/shared/components/fileUploads/MissingFileOverview.jsx @@ -259,7 +259,7 @@ export default function MissingFileOverview({ // Update sponsor to identify missing uploads const sponsorConditionalPages = getConditionalPages(pages, data); const sponsorMiss = { - name: data?.[nonListNameKey || 'veteransFullName'], + [nonListNameKey ?? 'name']: data?.[nonListNameKey || 'veteransFullName'], missingUploads: checkFlags( sponsorConditionalPages, data, From 9730f6c5f2e0ccef1ae717d67916b9bf07c37c6f Mon Sep 17 00:00:00 2001 From: Michael Clement <18408628+michaelclement@users.noreply.github.com> Date: Fri, 27 Dec 2024 16:12:27 -0600 Subject: [PATCH 2/3] updated hint text on contact page (#33743) --- src/applications/ivc-champva/10-7959f-1/config/form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/ivc-champva/10-7959f-1/config/form.js b/src/applications/ivc-champva/10-7959f-1/config/form.js index 9a04057f8185..a8ed27261b84 100644 --- a/src/applications/ivc-champva/10-7959f-1/config/form.js +++ b/src/applications/ivc-champva/10-7959f-1/config/form.js @@ -229,7 +229,7 @@ const formConfig = { uiSchema: { ...titleUI( 'Phone and email address', - 'For foreign numbers, add the country code so we can reach you if there are questions about this form.', + 'Include a country code for foreign phone numbers', ), messageAriaDescribedby: 'Please include this information so that we can contact you with questions or updates.', From 31b591d4f61cac4ac844b1f33a998a4ca39686cb Mon Sep 17 00:00:00 2001 From: Michael Clement <18408628+michaelclement@users.noreply.github.com> Date: Fri, 27 Dec 2024 16:12:36 -0600 Subject: [PATCH 3/3] updated address transform to use full country name (#33745) --- .../10-7959f-1/config/submitTransformer.js | 24 +++++++ .../config/submitTransformer.unit.spec.js | 66 ++++++++++++------- 2 files changed, 66 insertions(+), 24 deletions(-) diff --git a/src/applications/ivc-champva/10-7959f-1/config/submitTransformer.js b/src/applications/ivc-champva/10-7959f-1/config/submitTransformer.js index d2ff32cc6be5..d7197497a723 100644 --- a/src/applications/ivc-champva/10-7959f-1/config/submitTransformer.js +++ b/src/applications/ivc-champva/10-7959f-1/config/submitTransformer.js @@ -1,4 +1,5 @@ /* eslint-disable camelcase */ +import CONSTANTS from 'vets-json-schema/dist/constants.json'; // For countries import { formatDateShort } from 'platform/utilities/date'; import { transformForSubmit as formsSystemTransformForSubmit } from 'platform/forms-system/src/js/helpers'; import { concatStreets } from '../../shared/utilities'; @@ -12,6 +13,21 @@ function stringifyAddress(addr) { : ''; } +/** + * Converts country codes to full country names and returns updated address. + * e.g., {country: 'USA'} => {country: 'United States'} + * @param {object} addr Standard address object provided by the addressUI component. + * @returns Updated address object with country value replaced or left alone depending on presence of matching country label in the CONSTANTS file. + */ +function getCountryLabel(addr) { + const tmpAdr = addr; + // Find country label that matches country code in `addr` + tmpAdr.country = + CONSTANTS.countries.filter(c => c.value === tmpAdr.country)[0]?.label ?? + tmpAdr.country; // leave untouched if no match found + return tmpAdr; +} + export default function transformForSubmit(formConfig, form) { const transformedData = JSON.parse( formsSystemTransformForSubmit(formConfig, form), @@ -62,6 +78,14 @@ export default function transformForSubmit(formConfig, form) { dataPostTransform.veteran.mailing_address, ); + // Replace country code with full name: + dataPostTransform.veteran.physical_address = getCountryLabel( + dataPostTransform.veteran.physical_address, + ); + dataPostTransform.veteran.mailing_address = getCountryLabel( + dataPostTransform.veteran.mailing_address, + ); + return JSON.stringify({ ...dataPostTransform, form_number: formConfig.formId, diff --git a/src/applications/ivc-champva/10-7959f-1/tests/unit/config/submitTransformer.unit.spec.js b/src/applications/ivc-champva/10-7959f-1/tests/unit/config/submitTransformer.unit.spec.js index 5b51e9670aca..7009a01ab8d6 100644 --- a/src/applications/ivc-champva/10-7959f-1/tests/unit/config/submitTransformer.unit.spec.js +++ b/src/applications/ivc-champva/10-7959f-1/tests/unit/config/submitTransformer.unit.spec.js @@ -4,35 +4,53 @@ import formConfig from '../../../config/form'; import transformForSubmit from '../../../config/submitTransformer'; describe('submit transformer', () => { - it('should return expected data', () => { - const formData = { - data: { - veteranDateOfBirth: '2004-02-19', - fullName: 'John Smith', - physical_address: { - street: '1 Main st', - city: 'Canton', - state: 'NY', - postalCode: '13625', - country: 'US', - }, - mailing_address: { - street: '21 Jump St', - city: 'Prattville', - state: 'WA', - postalCode: '12569', - country: 'US', - }, - ssn: '963879632', - va_claim_number: '5236978', - phone_number: '2056321459', - email_address: 'john@gmail.com0', + const formData = { + data: { + veteranDateOfBirth: '2004-02-19', + fullName: 'John Smith', + veteranAddress: { + street: '1 Main st', + city: 'Canton', + state: 'NY', + postalCode: '13625', + country: 'AFG', + }, + physicalAddress: { + street: '21 Jump St', + city: 'Prattville', + state: 'WA', + postalCode: '12569', + country: 'USA', }, - }; + ssn: '963879632', + va_claim_number: '5236978', + phone_number: '2056321459', + email_address: 'john@gmail.com0', + }, + }; + it('should return expected data', () => { const newTransformData = JSON.parse( transformForSubmit(formConfig, formData), ); // eslint-disable-next-line no-console expect(newTransformData.veteran.date_of_birth).to.equal('02/19/2004'); }); + it('should replace country code with full country name', () => { + const data = JSON.parse( + transformForSubmit(formConfig, { + data: { + veteranDateOfBirth: '2004-02-19', + sameMailingAddress: true, + veteranAddress: { + street: '1 Main st', + city: 'Canton', + state: 'NY', + postalCode: '13625', + country: 'USA', + }, + }, + }), + ); + expect(data.veteran.physical_address.country).to.equal('United States'); + }); });