From d796fbeaa5683b8f394cd09fb732b5a353811581 Mon Sep 17 00:00:00 2001 From: Nick Sprinkle <53942725+ndsprinkle@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:02:08 -0400 Subject: [PATCH] [20-10207] Several content updates and fixes pre-release (#29272) * Limit medical treatments to 4 items * Update POW hint test to dynamically change based on preparer type * Update the medical treatment pages to have proper error messages * Update other reasons logic to only display one page per flow * Update unit tests --- .../simple-forms/20-10207/config/form.js | 6 +-- .../simple-forms/20-10207/helpers.js | 27 +++++++++++ .../20-10207/pages/evidenceConfinement.js | 15 ++++++- .../20-10207/pages/evidenceConfinement2.js | 15 ++++++- .../20-10207/pages/medicalTreatment.js | 13 +++++- .../medicalTreatmentThirdPartyNonVeteran.js | 13 +++++- .../medicalTreatmentThirdPartyVeteran.js | 13 +++++- .../tests/unit/config/form.unit.spec.js | 14 +++--- .../20-10207/tests/unit/helpers.unit.spec.js | 45 +++++++++++++++++++ 9 files changed, 143 insertions(+), 18 deletions(-) diff --git a/src/applications/simple-forms/20-10207/config/form.js b/src/applications/simple-forms/20-10207/config/form.js index 33e9533d1a88..978c1984bd56 100644 --- a/src/applications/simple-forms/20-10207/config/form.js +++ b/src/applications/simple-forms/20-10207/config/form.js @@ -418,7 +418,7 @@ const formConfig = { depends: formData => (formData.preparerType === PREPARER_TYPES.VETERAN || formData.preparerType === PREPARER_TYPES.NON_VETERAN) && - formData.livingSituation.OTHER_RISK, + formData.livingSituation.NONE, path: 'other-reasons', title: 'Other reasons for request', uiSchema: otherReasonsPg.uiSchema, @@ -428,7 +428,7 @@ const formConfig = { otherReasonsThirdPartyVeteranPage: { depends: formData => formData.preparerType === PREPARER_TYPES.THIRD_PARTY_VETERAN && - formData.livingSituation.OTHER_RISK, + formData.livingSituation.NONE, path: 'other-reasons-third-party-veteran', title: 'Other reasons for request', uiSchema: otherReasons3rdPtyVetPg.uiSchema, @@ -438,7 +438,7 @@ const formConfig = { otherReasonsThirdPartyNonVeteranPage: { depends: formData => formData.preparerType === PREPARER_TYPES.THIRD_PARTY_NON_VETERAN && - formData.livingSituation.OTHER_RISK, + formData.livingSituation.NONE, path: 'other-reasons-third-party-non-veteran', title: 'Other reasons for request', uiSchema: otherReasons3rdPtyNonVetPg.uiSchema, diff --git a/src/applications/simple-forms/20-10207/helpers.js b/src/applications/simple-forms/20-10207/helpers.js index 6486c8a13b95..a4b69061a58b 100644 --- a/src/applications/simple-forms/20-10207/helpers.js +++ b/src/applications/simple-forms/20-10207/helpers.js @@ -218,3 +218,30 @@ export const getSubmitterName = formData => { return formData.thirdPartyFullName; } }; + +export const evidenceConfinementHintUpdateUiSchema = ({ + formData, + beganEndedString, +}) => { + if (formData?.preparerType === PREPARER_TYPES.THIRD_PARTY_VETERAN) { + return { + 'ui:options': { + hint: `Tell us the dates the Veteran’s confinement ${beganEndedString} as a prisoner of war.`, + }, + }; + } + + if (formData?.preparerType === PREPARER_TYPES.THIRD_PARTY_NON_VETERAN) { + return { + 'ui:options': { + hint: `Tell us the dates the claimant’s confinement ${beganEndedString} as a prisoner of war.`, + }, + }; + } + + return { + 'ui:options': { + hint: `Tell us the dates your confinement ${beganEndedString} as a prisoner of war.`, + }, + }; +}; diff --git a/src/applications/simple-forms/20-10207/pages/evidenceConfinement.js b/src/applications/simple-forms/20-10207/pages/evidenceConfinement.js index 542ffd4b46ce..b7df3e433e96 100644 --- a/src/applications/simple-forms/20-10207/pages/evidenceConfinement.js +++ b/src/applications/simple-forms/20-10207/pages/evidenceConfinement.js @@ -7,7 +7,10 @@ import { } from 'platform/forms-system/src/js/web-component-patterns'; import { POW_MULTIPLE_CONFINEMENTS_LABELS } from '../config/constants'; -import { powConfinementDateRangeValidation } from '../helpers'; +import { + evidenceConfinementHintUpdateUiSchema, + powConfinementDateRangeValidation, +} from '../helpers'; /** @type {PageSchema} */ export default { @@ -19,6 +22,11 @@ export default { errorMessages: { required: 'Provide the start date of confinement', }, + updateUiSchema: formData => + evidenceConfinementHintUpdateUiSchema({ + formData, + beganEndedString: 'began', + }), }), powConfinementEndDate: currentOrPastDateUI({ title: 'End of confinement', @@ -26,6 +34,11 @@ export default { errorMessages: { required: 'Provide the end date of confinement', }, + updateUiSchema: formData => + evidenceConfinementHintUpdateUiSchema({ + formData, + beganEndedString: 'ended', + }), }), powMultipleConfinements: yesNoUI({ title: 'Were you confined more than once?', diff --git a/src/applications/simple-forms/20-10207/pages/evidenceConfinement2.js b/src/applications/simple-forms/20-10207/pages/evidenceConfinement2.js index e5780bf18415..6f98880841c6 100644 --- a/src/applications/simple-forms/20-10207/pages/evidenceConfinement2.js +++ b/src/applications/simple-forms/20-10207/pages/evidenceConfinement2.js @@ -4,7 +4,10 @@ import { titleUI, } from 'platform/forms-system/src/js/web-component-patterns'; -import { powConfinement2DateRangeValidation } from '../helpers'; +import { + evidenceConfinementHintUpdateUiSchema, + powConfinement2DateRangeValidation, +} from '../helpers'; /** @type {PageSchema} */ export default { @@ -17,6 +20,11 @@ export default { errorMessages: { required: 'Provide the start date of confinement', }, + updateUiSchema: formData => + evidenceConfinementHintUpdateUiSchema({ + formData, + beganEndedString: 'began', + }), }), powConfinement2EndDate: currentOrPastDateUI({ title: 'End of confinement', @@ -25,6 +33,11 @@ export default { errorMessages: { required: 'Provide the end date of confinement', }, + updateUiSchema: formData => + evidenceConfinementHintUpdateUiSchema({ + formData, + beganEndedString: 'ended', + }), }), 'ui:validations': [powConfinement2DateRangeValidation], }, diff --git a/src/applications/simple-forms/20-10207/pages/medicalTreatment.js b/src/applications/simple-forms/20-10207/pages/medicalTreatment.js index 919ceabd2073..3e090226bc51 100644 --- a/src/applications/simple-forms/20-10207/pages/medicalTreatment.js +++ b/src/applications/simple-forms/20-10207/pages/medicalTreatment.js @@ -31,6 +31,10 @@ export default { facilityName: { 'ui:title': 'Name of treatment facility', 'ui:webComponentField': VaTextInputField, + 'ui:errorMessages': { + required: + 'Enter the name of the facility where you received treatment', + }, 'ui:options': { charcount: 40, }, @@ -38,7 +42,12 @@ export default { facilityAddress: addressNoMilitaryUI({ omit: ['street2', 'street3'], }), - startDate: currentOrPastDateUI('Approximate start date of treatment'), + startDate: currentOrPastDateUI({ + title: 'Approximate start date of treatment', + errorMessages: { + required: 'Enter the approximate date of when treatment began', + }, + }), }, }, }, @@ -48,7 +57,7 @@ export default { medicalTreatments: { type: 'array', minItems: 1, - maxItems: 5, + maxItems: 4, items: { type: 'object', properties: { diff --git a/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyNonVeteran.js b/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyNonVeteran.js index 1fd663944754..2779f400730f 100644 --- a/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyNonVeteran.js +++ b/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyNonVeteran.js @@ -31,6 +31,10 @@ export default { facilityName: { 'ui:title': 'Name of treatment facility', 'ui:webComponentField': VaTextInputField, + 'ui:errorMessages': { + required: + 'Enter the name of the facility where the claimant received treatment', + }, 'ui:options': { charcount: 40, }, @@ -38,7 +42,12 @@ export default { facilityAddress: addressNoMilitaryUI({ omit: ['street2', 'street3'], }), - startDate: currentOrPastDateUI('Approximate start date of treatment'), + startDate: currentOrPastDateUI({ + title: 'Approximate start date of treatment', + errorMessages: { + required: 'Enter the approximate date of when treatment began', + }, + }), }, }, }, @@ -48,7 +57,7 @@ export default { medicalTreatments: { type: 'array', minItems: 1, - maxItems: 5, + maxItems: 4, items: { type: 'object', properties: { diff --git a/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyVeteran.js b/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyVeteran.js index 429c5e9ec80d..c203f3ab30a2 100644 --- a/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyVeteran.js +++ b/src/applications/simple-forms/20-10207/pages/medicalTreatmentThirdPartyVeteran.js @@ -31,6 +31,10 @@ export default { facilityName: { 'ui:title': 'Name of treatment facility', 'ui:webComponentField': VaTextInputField, + 'ui:errorMessages': { + required: + 'Enter the name of the facility where the Veteran received treatment', + }, 'ui:options': { charcount: 40, }, @@ -38,7 +42,12 @@ export default { facilityAddress: addressNoMilitaryUI({ omit: ['street2', 'street3'], }), - startDate: currentOrPastDateUI('Approximate start date of treatment'), + startDate: currentOrPastDateUI({ + title: 'Approximate start date of treatment', + errorMessages: { + required: 'Enter the approximate date of when treatment began', + }, + }), }, }, }, @@ -48,7 +57,7 @@ export default { medicalTreatments: { type: 'array', minItems: 1, - maxItems: 5, + maxItems: 4, items: { type: 'object', properties: { diff --git a/src/applications/simple-forms/20-10207/tests/unit/config/form.unit.spec.js b/src/applications/simple-forms/20-10207/tests/unit/config/form.unit.spec.js index 62c77c06468f..4d6123fe7de0 100644 --- a/src/applications/simple-forms/20-10207/tests/unit/config/form.unit.spec.js +++ b/src/applications/simple-forms/20-10207/tests/unit/config/form.unit.spec.js @@ -1010,16 +1010,16 @@ describe('formConfig', () => { ).to.be.false; }); - it('returns TRUE if livingSituation.OTHER_RISK is TRUE and preparerType is veteran or non-veteran', () => { + it('returns TRUE if livingSituation.NONE is TRUE and preparerType is veteran or non-veteran', () => { expect( depends({ - livingSituation: { OTHER_RISK: true }, + livingSituation: { NONE: true }, preparerType: PREPARER_TYPES.VETERAN, }), ).to.be.true; expect( depends({ - livingSituation: { OTHER_RISK: true }, + livingSituation: { NONE: true }, preparerType: PREPARER_TYPES.NON_VETERAN, }), ).to.be.true; @@ -1075,10 +1075,10 @@ describe('formConfig', () => { ).to.be.false; }); - it('returns TRUE if livingSituation.OTHER_RISK is TRUE and preparerType is third-party-veteran', () => { + it('returns TRUE if livingSituation.NONE is TRUE and preparerType is third-party-veteran', () => { expect( depends({ - livingSituation: { OTHER_RISK: true }, + livingSituation: { NONE: true }, preparerType: PREPARER_TYPES.THIRD_PARTY_VETERAN, }), ).to.be.true; @@ -1119,10 +1119,10 @@ describe('formConfig', () => { ).to.be.false; }); - it('returns TRUE if livingSituation.OTHER_RISK is TRUE and preparerType is third-party-non-veteran', () => { + it('returns TRUE if livingSituation.NONE is TRUE and preparerType is third-party-non-veteran', () => { expect( depends({ - livingSituation: { OTHER_RISK: true }, + livingSituation: { NONE: true }, preparerType: PREPARER_TYPES.THIRD_PARTY_NON_VETERAN, }), ).to.be.true; diff --git a/src/applications/simple-forms/20-10207/tests/unit/helpers.unit.spec.js b/src/applications/simple-forms/20-10207/tests/unit/helpers.unit.spec.js index 3d8c2e29e413..67e1459bc80e 100644 --- a/src/applications/simple-forms/20-10207/tests/unit/helpers.unit.spec.js +++ b/src/applications/simple-forms/20-10207/tests/unit/helpers.unit.spec.js @@ -23,6 +23,7 @@ import { powConfinement2DateRangeValidation, statementOfTruthFullNamePath, getSubmitterName, + evidenceConfinementHintUpdateUiSchema, } from '../../helpers'; describe('getMockData', () => { @@ -639,3 +640,47 @@ describe('getSubmitterName()', () => { ).to.equal('thirdPartyName'); }); }); + +describe('evidenceConfinementHintUpdateUiSchema', () => { + it('returns the correct hint string depending on preparer type', () => { + const beganEndedString = 'began'; + const formData = { + preparerType: PREPARER_TYPES.VETERAN, + }; + + expect( + evidenceConfinementHintUpdateUiSchema({ formData, beganEndedString })[ + 'ui:options' + ].hint, + ).to.equal( + `Tell us the dates your confinement ${beganEndedString} as a prisoner of war.`, + ); + + formData.preparerType = PREPARER_TYPES.NON_VETERAN; + expect( + evidenceConfinementHintUpdateUiSchema({ formData, beganEndedString })[ + 'ui:options' + ].hint, + ).to.equal( + `Tell us the dates your confinement ${beganEndedString} as a prisoner of war.`, + ); + + formData.preparerType = PREPARER_TYPES.THIRD_PARTY_VETERAN; + expect( + evidenceConfinementHintUpdateUiSchema({ formData, beganEndedString })[ + 'ui:options' + ].hint, + ).to.equal( + `Tell us the dates the Veteran’s confinement ${beganEndedString} as a prisoner of war.`, + ); + + formData.preparerType = PREPARER_TYPES.THIRD_PARTY_NON_VETERAN; + expect( + evidenceConfinementHintUpdateUiSchema({ formData, beganEndedString })[ + 'ui:options' + ].hint, + ).to.equal( + `Tell us the dates the claimant’s confinement ${beganEndedString} as a prisoner of war.`, + ); + }); +});