Skip to content

Commit

Permalink
[20-10207] Several content updates and fixes pre-release (#29272)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ndsprinkle committed Apr 19, 2024
1 parent 5f7e671 commit d796fbe
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/applications/simple-forms/20-10207/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
27 changes: 27 additions & 0 deletions src/applications/simple-forms/20-10207/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -19,13 +22,23 @@ export default {
errorMessages: {
required: 'Provide the start date of confinement',
},
updateUiSchema: formData =>
evidenceConfinementHintUpdateUiSchema({
formData,
beganEndedString: 'began',
}),
}),
powConfinementEndDate: currentOrPastDateUI({
title: 'End of confinement',
hint: 'Tell us the dates your confinement ended as a prisoner of war.',
errorMessages: {
required: 'Provide the end date of confinement',
},
updateUiSchema: formData =>
evidenceConfinementHintUpdateUiSchema({
formData,
beganEndedString: 'ended',
}),
}),
powMultipleConfinements: yesNoUI({
title: 'Were you confined more than once?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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',
Expand All @@ -25,6 +33,11 @@ export default {
errorMessages: {
required: 'Provide the end date of confinement',
},
updateUiSchema: formData =>
evidenceConfinementHintUpdateUiSchema({
formData,
beganEndedString: 'ended',
}),
}),
'ui:validations': [powConfinement2DateRangeValidation],
},
Expand Down
13 changes: 11 additions & 2 deletions src/applications/simple-forms/20-10207/pages/medicalTreatment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ 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,
},
},
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',
},
}),
},
},
},
Expand All @@ -48,7 +57,7 @@ export default {
medicalTreatments: {
type: 'array',
minItems: 1,
maxItems: 5,
maxItems: 4,
items: {
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ 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,
},
},
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',
},
}),
},
},
},
Expand All @@ -48,7 +57,7 @@ export default {
medicalTreatments: {
type: 'array',
minItems: 1,
maxItems: 5,
maxItems: 4,
items: {
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ 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,
},
},
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',
},
}),
},
},
},
Expand All @@ -48,7 +57,7 @@ export default {
medicalTreatments: {
type: 'array',
minItems: 1,
maxItems: 5,
maxItems: 4,
items: {
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
powConfinement2DateRangeValidation,
statementOfTruthFullNamePath,
getSubmitterName,
evidenceConfinementHintUpdateUiSchema,
} from '../../helpers';

describe('getMockData', () => {
Expand Down Expand Up @@ -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.`,
);
});
});

0 comments on commit d796fbe

Please sign in to comment.