From e066f085ccf5f20d302c73707a51db48e7f0a4af Mon Sep 17 00:00:00 2001 From: fatmakhan0395 <145523589+fatmakhan0395@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:00:33 -0800 Subject: [PATCH] vebt-179 added Rudisill question to 1995 (#33742) * 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 --- .../edu-benefits/1995/Form1995App.jsx | 4 +- .../edu-benefits/1995/config/chapters.js | 8 +++ .../edu-benefits/1995/helpers.jsx | 3 + .../1995/pages/benefitSelectionUpdate.js | 62 +++++++++++------- .../1995/pages/changeAnotherBenefit.js | 42 ++++++++++++ .../edu-benefits/1995/pages/index.js | 2 + ...du-1995-application-status.cypress.spec.js | 15 ----- .../1995/tests/e2e/edu-1995.cypress.spec.js | 65 ------------------- .../pages/benefitSelection.unit.spec.jsx | 4 +- .../edu-benefits/hooks/useSetToggleParam.js | 8 ++- .../feature-toggles/featureFlagNames.json | 3 +- 11 files changed, 107 insertions(+), 109 deletions(-) create mode 100644 src/applications/edu-benefits/1995/pages/changeAnotherBenefit.js delete mode 100644 src/applications/edu-benefits/1995/tests/e2e/edu-1995-application-status.cypress.spec.js delete mode 100644 src/applications/edu-benefits/1995/tests/e2e/edu-1995.cypress.spec.js diff --git a/src/applications/edu-benefits/1995/Form1995App.jsx b/src/applications/edu-benefits/1995/Form1995App.jsx index eead916a6dc5..75e71b16b79b 100644 --- a/src/applications/edu-benefits/1995/Form1995App.jsx +++ b/src/applications/edu-benefits/1995/Form1995App.jsx @@ -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 ( {children} diff --git a/src/applications/edu-benefits/1995/config/chapters.js b/src/applications/edu-benefits/1995/config/chapters.js index 9e599255bb54..ca6da433c9fd 100644 --- a/src/applications/edu-benefits/1995/config/chapters.js +++ b/src/applications/edu-benefits/1995/config/chapters.js @@ -18,6 +18,7 @@ import { servicePeriodsUpdate, tourOfDuty, sponsorInfo, + changeAnotherBenefitPage, } from '../pages'; import { isProductionOfTestProdEnv, sponsorInformationTitle } from '../helpers'; @@ -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: { diff --git a/src/applications/edu-benefits/1995/helpers.jsx b/src/applications/edu-benefits/1995/helpers.jsx index ea7b5b79e340..48dd4196e0b6 100644 --- a/src/applications/edu-benefits/1995/helpers.jsx +++ b/src/applications/edu-benefits/1995/helpers.jsx @@ -116,3 +116,6 @@ export const isEighteenOrOlder = (birthday, automatedTest = false) => { ? eighteenOrOver(birthday) : eighteenOrOverUpdate(birthday); }; +export const showRudisill1995 = () => { + return sessionStorage.getItem('isRudisill1995') === 'true'; +}; diff --git a/src/applications/edu-benefits/1995/pages/benefitSelectionUpdate.js b/src/applications/edu-benefits/1995/pages/benefitSelectionUpdate.js index d5e5b196766e..22218fae7212 100644 --- a/src/applications/edu-benefits/1995/pages/benefitSelectionUpdate.js +++ b/src/applications/edu-benefits/1995/pages/benefitSelectionUpdate.js @@ -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 = { @@ -52,20 +53,31 @@ 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 = { @@ -73,7 +85,13 @@ export const schema = { required: ['benefitUpdate'], properties: { benefitUpdate: displayBenefit, - changeAnotherBenefit, - benefitAppliedFor: displayNewBenefit, + ...(!showRudisill1995() + ? { + changeAnotherBenefit: radioSchema(['Yes', 'No']), + benefitAppliedFor: displayNewBenefit, + } + : { + rudisillReview: radioSchema(['Yes', 'No']), + }), }, }; diff --git a/src/applications/edu-benefits/1995/pages/changeAnotherBenefit.js b/src/applications/edu-benefits/1995/pages/changeAnotherBenefit.js new file mode 100644 index 000000000000..1a03bc1a0a70 --- /dev/null +++ b/src/applications/edu-benefits/1995/pages/changeAnotherBenefit.js @@ -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 = ( +

+ Note: if you select yes, this change will be applied with your next + enrollment certification if you are eligible for the benefit selected. +

+); +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, + }, +}; diff --git a/src/applications/edu-benefits/1995/pages/index.js b/src/applications/edu-benefits/1995/pages/index.js index f672c5401aaa..5333601030e8 100644 --- a/src/applications/edu-benefits/1995/pages/index.js +++ b/src/applications/edu-benefits/1995/pages/index.js @@ -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, @@ -22,4 +23,5 @@ export { servicePeriodsUpdate, tourOfDuty, sponsorInfo, + changeAnotherBenefitPage, }; diff --git a/src/applications/edu-benefits/1995/tests/e2e/edu-1995-application-status.cypress.spec.js b/src/applications/edu-benefits/1995/tests/e2e/edu-1995-application-status.cypress.spec.js deleted file mode 100644 index 988033b68f6d..000000000000 --- a/src/applications/edu-benefits/1995/tests/e2e/edu-1995-application-status.cypress.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -import mockUser from './fixtures/mocks/mockUser'; - -describe('Application Status Test: edu-benefits', () => { - it('Achieves the correct result per URL', () => { - cy.login(mockUser); - cy.testStatus( - '/education/how-to-apply/', - '/education/apply-for-education-benefits/application/1995/resume', - ); - cy.testStatus( - '/education/eligibility', - '/education/apply-for-education-benefits/application/1995/resume', - ); - }); -}); diff --git a/src/applications/edu-benefits/1995/tests/e2e/edu-1995.cypress.spec.js b/src/applications/edu-benefits/1995/tests/e2e/edu-1995.cypress.spec.js deleted file mode 100644 index a840ad4ffab0..000000000000 --- a/src/applications/edu-benefits/1995/tests/e2e/edu-1995.cypress.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -// import path from 'path'; -// import testForm from 'platform/testing/e2e/cypress/support/form-tester'; -// import { createTestConfig } from 'platform/testing/e2e/cypress/support/form-tester/utilities'; -// import formConfig from '../../config/form'; -// import manifest from '../../manifest.json'; -// import mockUser from './fixtures/mocks/mock-user.json'; -// import featureToggles from './fixtures/mocks/feature-toggles.json'; -// -// Cypress.config('waitForAnimations', true); -// -// const form = createTestConfig( -// { -// dataPrefix: 'data', -// dataSets: ['minimal'], -// fixtures: { -// data: path.join(__dirname, 'fixtures', 'data'), -// mocks: path.join(__dirname, 'fixtures', 'mocks'), -// }, -// setupPerTest: () => { -// cy.login(mockUser); -// cy.intercept('GET', '/v0/feature_toggles*', featureToggles); -// cy.intercept('POST', '/v0/education_benefits_claims/1995', { -// data: { -// attributes: { -// confirmationNumber: 'BB935000000F3VnCAW', -// submittedAt: '2020-08-09T19:18:11+00:00', -// }, -// }, -// }); -// cy.get('@testData').then(testData => { -// cy.intercept('GET', '/v0/in_progress_forms/22-1995', req => { -// req.reply({ -// formData: testData, -// metadata: { returnUrl: '/applicant/information' }, -// }); -// }); -// cy.intercept('PUT', '/v0/in_progress_forms/22-1995', testData); -// }); -// }, -// pageHooks: { -// introduction: ({ afterHook }) => { -// cy.findByText(/Find the right application form/i, { -// selector: 'button', -// }) -// .first() -// .click(); -// cy.get('#NewBenefit-1').check(); -// cy.get('#TransferredBenefits-1').check(); -// cy.get('#apply-now-link').click(); -// afterHook(() => { -// cy.findAllByText(/Start the education application/i, { -// selector: 'button', -// }) -// .first() -// .click(); -// }); -// }, -// }, -// skip: true, // skip allowed while removing the secondary wizard. will turn to false after secondary wizard has been removed -// }, -// manifest, -// formConfig, -// ); -// -// testForm(form); diff --git a/src/applications/edu-benefits/1995/tests/pages/benefitSelection.unit.spec.jsx b/src/applications/edu-benefits/1995/tests/pages/benefitSelection.unit.spec.jsx index d3dc2d5d504e..89a242c85f4a 100644 --- a/src/applications/edu-benefits/1995/tests/pages/benefitSelection.unit.spec.jsx +++ b/src/applications/edu-benefits/1995/tests/pages/benefitSelection.unit.spec.jsx @@ -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(); }); }); @@ -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(); }); }); diff --git a/src/applications/edu-benefits/hooks/useSetToggleParam.js b/src/applications/edu-benefits/hooks/useSetToggleParam.js index b8d7395180a3..bd9c4db990f2 100644 --- a/src/applications/edu-benefits/hooks/useSetToggleParam.js +++ b/src/applications/edu-benefits/hooks/useSetToggleParam.js @@ -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()}`; @@ -14,6 +18,6 @@ export const useSetToggleParam = toggleValue => { } } }, - [toggleValue], + [toggleValue, showRudisill1995], ); }; diff --git a/src/platform/utilities/feature-toggles/featureFlagNames.json b/src/platform/utilities/feature-toggles/featureFlagNames.json index c58209f11882..4b4ad5746bfe 100644 --- a/src/platform/utilities/feature-toggles/featureFlagNames.json +++ b/src/platform/utilities/feature-toggles/featureFlagNames.json @@ -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" }