Skip to content

Commit

Permalink
vebt-179 added Rudisill question to 1995 (#33742)
Browse files Browse the repository at this point in the history
* vebt-179 added Rudisill question to 1995

* updated radio-widget to radioUi

* update featured toggle and fixed unit tests

* added required to benefitAppliedFor

* Deleted cypress
  • Loading branch information
fatmakhan0395 authored Dec 26, 2024
1 parent d56bb41 commit e066f08
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 109 deletions.
4 changes: 2 additions & 2 deletions src/applications/edu-benefits/1995/Form1995App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { useSetToggleParam } from '../hooks/useSetToggleParam';
export default function Form1995Entry({ location, children }) {
const { useToggleValue, TOGGLE_NAMES } = useFeatureToggle();
const toggleValue = useToggleValue(TOGGLE_NAMES.merge1995And5490);
const showRudisill1995 = useToggleValue(TOGGLE_NAMES.showRudisill1995);

useSetToggleParam(toggleValue);

useSetToggleParam(toggleValue, showRudisill1995);
return (
<RoutedSavableApp formConfig={formConfig} currentLocation={location}>
{children}
Expand Down
8 changes: 8 additions & 0 deletions src/applications/edu-benefits/1995/config/chapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
servicePeriodsUpdate,
tourOfDuty,
sponsorInfo,
changeAnotherBenefitPage,
} from '../pages';

import { isProductionOfTestProdEnv, sponsorInformationTitle } from '../helpers';
Expand Down Expand Up @@ -184,6 +185,13 @@ export const chapters = {
uiSchema: benefitSelectionUiSchema(),
schema: benefitSelectionSchema(),
},
changeAnotherBenefit: {
title: 'Education benefit selection',
path: 'benefits/education-benefit',
uiSchema: changeAnotherBenefitPage.uiSchema,
schema: changeAnotherBenefitPage.schema,
depends: formData => formData?.rudisillReview === 'No',
},
},
},
sponsorInformation: {
Expand Down
3 changes: 3 additions & 0 deletions src/applications/edu-benefits/1995/helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ export const isEighteenOrOlder = (birthday, automatedTest = false) => {
? eighteenOrOver(birthday)
: eighteenOrOverUpdate(birthday);
};
export const showRudisill1995 = () => {
return sessionStorage.getItem('isRudisill1995') === 'true';
};
62 changes: 40 additions & 22 deletions src/applications/edu-benefits/1995/pages/benefitSelectionUpdate.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import fullSchema from 'vets-json-schema/dist/22-1995-schema.json';
import {
radioSchema,
radioUI,
} from 'platform/forms-system/src/js/web-component-patterns';
import React from 'react';
import { benefitsLabelsUpdate } from '../../utils/labels';
import { showRudisill1995 } from '../helpers';

const {
benefitUpdate,
changeAnotherBenefit,
benefitAppliedFor,
} = fullSchema.properties;
const { benefitUpdate, benefitAppliedFor } = fullSchema.properties;

const displayBenefit = {
...benefitUpdate,
enum: [...benefitUpdate.enum],
enum: [...(benefitUpdate?.enum || [])],
};

const displayNewBenefit = {
Expand Down Expand Up @@ -52,28 +53,45 @@ export const uiSchema = {
labels: benefitsLabelsUpdate,
},
},
changeAnotherBenefit: {
'ui:title': 'Do you want to change to another benefit?',
'ui:description': changeAnotherBenefitDescription,
'ui:widget': 'radio',
},
benefitAppliedFor: {
'ui:widget': 'radio',
'ui:title': 'Which benefit do you want to change to?',
'ui:required': formData => formData.changeAnotherBenefit === 'Yes',
'ui:options': {
labels: benefitsLabelsUpdate,
hideIf: formData => formData.changeAnotherBenefit !== 'Yes',
},
},
...(showRudisill1995()
? {
rudisillReview: {
...radioUI({
title: 'Do you wish to request a Rudisill review?',
}),
},
}
: {
changeAnotherBenefit: {
...radioUI({
title: 'Do you want to change to another benefit?',
description: changeAnotherBenefitDescription,
}),
},
benefitAppliedFor: {
'ui:title': 'Which benefit do you want to change to?',
'ui:widget': 'radio',
'ui:required': formData => formData.changeAnotherBenefit === 'Yes',
'ui:options': {
labels: benefitsLabelsUpdate,
hideIf: formData => formData.changeAnotherBenefit !== 'Yes',
},
},
}),
};

export const schema = {
type: 'object',
required: ['benefitUpdate'],
properties: {
benefitUpdate: displayBenefit,
changeAnotherBenefit,
benefitAppliedFor: displayNewBenefit,
...(!showRudisill1995()
? {
changeAnotherBenefit: radioSchema(['Yes', 'No']),
benefitAppliedFor: displayNewBenefit,
}
: {
rudisillReview: radioSchema(['Yes', 'No']),
}),
},
};
42 changes: 42 additions & 0 deletions src/applications/edu-benefits/1995/pages/changeAnotherBenefit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import fullSchema from 'vets-json-schema/dist/22-1995-schema.json';
import React from 'react';
import { benefitsLabelsUpdate } from '../../utils/labels';

const { changeAnotherBenefit, benefitAppliedFor } = fullSchema.properties;

const displayNewBenefit = {
...benefitAppliedFor,
enum: [...(benefitAppliedFor?.enum || [])],
};
const changeAnotherBenefitDescription = (
<p className="vads-u-color--gray-medium">
Note: if you select yes, this change will be applied with your next
enrollment certification if you are eligible for the benefit selected.
</p>
);
displayNewBenefit.enum.splice(0, 1, 'chapter33');
displayNewBenefit.enum.splice(1, 1, 'fryScholarship');
export const uiSchema = {
changeAnotherBenefit: {
'ui:title': 'Do you want to change to another benefit?',
'ui:description': changeAnotherBenefitDescription,
'ui:widget': 'radio',
},
benefitAppliedFor: {
'ui:widget': 'radio',
'ui:title': 'Which benefit do you want to change to?',
'ui:required': formData => formData.changeAnotherBenefit === 'Yes',
'ui:options': {
labels: benefitsLabelsUpdate,
hideIf: formData => formData.changeAnotherBenefit !== 'Yes',
},
},
};

export const schema = {
type: 'object',
properties: {
changeAnotherBenefit,
benefitAppliedFor: displayNewBenefit,
},
};
2 changes: 2 additions & 0 deletions src/applications/edu-benefits/1995/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as servicePeriodsUpdate from './servicePeriodsUpdate';
import * as tourOfDuty from './tourOfDuty';
import * as applicantInformationUpdate from './applicantInformationUpdate';
import { sponsorInfo } from './sponsorInfomartion';
import * as changeAnotherBenefitPage from './changeAnotherBenefit';

export {
applicantInformationUpdate,
Expand All @@ -22,4 +23,5 @@ export {
servicePeriodsUpdate,
tourOfDuty,
sponsorInfo,
changeAnotherBenefitPage,
};

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Edu 1995 benefitSelection', () => {
/>,
);
await waitFor(() => {
expect(form.find('input').length).to.equal(8);
expect(form.find('input').length).to.equal(6);
form.unmount();
});
});
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('Delete Environment Variables Edu 1995 benefitSelection', () => {
/>,
);
await waitFor(() => {
expect(form.find('input').length).to.equal(8);
expect(form.find('input').length).to.equal(6);
form.unmount();
});
});
Expand Down
8 changes: 6 additions & 2 deletions src/applications/edu-benefits/hooks/useSetToggleParam.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useEffect } from 'react';

export const useSetToggleParam = toggleValue => {
export const useSetToggleParam = (toggleValue, showRudisill1995) => {
useEffect(
() => {
const urlParams = new URLSearchParams(window.location.search);
if (toggleValue != null && toggleValue !== 'undefined') {
urlParams.set('toggle', toggleValue);
sessionStorage.setItem(
'isRudisill1995',
JSON.stringify(showRudisill1995),
);
const newUrl = `${window.location.origin}${
window.location.pathname
}?${urlParams.toString()}`;
Expand All @@ -14,6 +18,6 @@ export const useSetToggleParam = toggleValue => {
}
}
},
[toggleValue],
[toggleValue, showRudisill1995],
);
};
3 changes: 2 additions & 1 deletion src/platform/utilities/feature-toggles/featureFlagNames.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,6 @@
"showLcInComparisonTool": "show_lc_in_comparison_tool",
"giComparisonToolShowRatings": "gi_comparison_tool_show_ratings",
"fsrWizard": "fsr_wizard",
"isDGIBEndpoint": "is_DGIB_endpoint"
"isDGIBEndpoint": "is_DGIB_endpoint",
"showRudisill1995": "show_rudisill_1995"
}

0 comments on commit e066f08

Please sign in to comment.