Skip to content

Commit

Permalink
Vfep 1324 (#29464)
Browse files Browse the repository at this point in the history
* Updated direct deposit instructions for 5490 form

* added unit tests
  • Loading branch information
fatmakhan0395 committed Apr 29, 2024
1 parent 40a42fe commit 01b1d73
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/applications/edu-benefits/5490/config/form.js
Expand Up @@ -18,6 +18,7 @@ import {
benefitsDisclaimerSpouse,
relationshipAndChildTypeLabels,
transform,
isProductionOfTestProdEnv,
} from '../helpers';

import { urlMigration } from '../../config/migrations';
Expand All @@ -38,6 +39,7 @@ import ConfirmationPage from '../containers/ConfirmationPage';
import benefitSelectionWarning from '../components/BenefitSelectionWarning';

import manifest from '../manifest.json';
import createDirectDepositPageUpdate from '../content/directDepositUpdate';

const {
benefit,
Expand Down Expand Up @@ -644,8 +646,6 @@ const formConfig = {
fullSchema5490,
'relativeAddress',
),

directDeposit: createDirectDepositPage5490(),
},
},
GuardianInformation: {
Expand All @@ -656,5 +656,10 @@ const formConfig = {
},
},
};
if (isProductionOfTestProdEnv()) {
formConfig.chapters.personalInformation.pages.directDeposit = createDirectDepositPage5490();
} else {
formConfig.chapters.personalInformation.pages.directDeposit = createDirectDepositPageUpdate();
}

export default formConfig;
134 changes: 134 additions & 0 deletions src/applications/edu-benefits/5490/content/directDepositUpdate.jsx
@@ -0,0 +1,134 @@
import React from 'react';
import { isValidRoutingNumber } from 'platform/forms/validations';
import merge from 'lodash/merge';

export const gaBankInfoHelpText = () => {
window.dataLayer.push({
event: 'edu-5490--form-help-text-clicked',
'help-text-label': 'What if I don’t have a bank account?',
});
};

const bankInfoHelpText = (
<va-additional-info
trigger="What if I don’t have a bank account?"
onClick={gaBankInfoHelpText}
>
<div className="vads-u-margin-bottom--2">
<p>
The{' '}
<a href="https://veteransbenefitsbanking.org/">
Veterans Benefits Banking Program (VBBP)
</a>{' '}
provides a list of Veteran-friendly banks and credit unions. They’ll
work with you to set up an account, or help you qualify for an account,
so you can use direct deposit. To get started, call one of the
participating banks or credit unions listed on the VBBP website. Be sure
to mention the Veterans Benefits Banking Program.
</p>
</div>
</va-additional-info>
);

const directDepositDescription = (
<div className="vads-u-margin-top--2 vads-u-margin-bottom--2">
<p>
Direct Deposit information is not required to determine eligibility.
However, benefits cannot be paid without this information per U.S.
Treasury regulation 31 C.F.R. § 208.3.
</p>
<>{bankInfoHelpText}</>
<p>
Note: Federal regulation, found in 31 C.F.R. § 208.3 provides that,
subject to section 208.4, "all Federal payments made by an agency shall be
made by electronic funds transfer" (EFT).
</p>
<p>
Note: Any bank account information you enter here will update all other
existing Veteran benefits, including Compensation, Pension, and benefits
for certain children with disabilities (Chapter 18) payments. Information
entered here WILL NOT change your existing bank account for VA health
benefits.
</p>
<img
src="/img/direct-deposit-check-guide.svg"
alt="On a personal check, find your bank’s 9-digit routing number listed along the bottom-left edge, and your account number listed beside that."
/>
</div>
);

export function validateRoutingNumber(
errors,
routingNumber,
formData,
schema,
errorMessages,
) {
if (!isValidRoutingNumber(routingNumber)) {
errors.addError(errorMessages.pattern);
}
}

export default function createDirectDepositPageUpdate() {
const bankAccountProperties = {
type: 'object',
properties: {
accountType: {
type: 'string',
enum: ['checking', 'savings'],
},
routingNumber: {
type: 'string',
pattern: '^\\d{9}$',
},
accountNumber: {
type: 'string',
},
'view:bankInfoHelpText': {
type: 'object',
properties: {},
},
},
};

return {
title: 'Direct deposit',
path: 'personal-information/direct-deposit',
initialData: {},
uiSchema: {
'ui:title': 'Direct deposit',
'ui:description': directDepositDescription,
bankAccount: merge(
{},
{
accountType: {
'ui:title': 'Account type',
'ui:widget': 'radio',
'ui:options': {
labels: {
checking: 'Checking',
savings: 'Savings',
},
},
},
accountNumber: {
'ui:title': 'Bank account number',
},
routingNumber: {
'ui:title': 'Bank routing number',
'ui:validations': [validateRoutingNumber],
'ui:errorMessages': {
pattern: 'Please enter a valid 9 digit routing number',
},
},
},
),
},
schema: {
type: 'object',
properties: {
bankAccount: bankAccountProperties,
},
},
};
}
13 changes: 12 additions & 1 deletion src/applications/edu-benefits/5490/helpers.jsx
@@ -1,6 +1,7 @@
import cloneDeep from 'platform/utilities/data/cloneDeep';
import moment from 'moment';
import React from 'react';
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
import { transformForSubmit } from 'platform/forms-system/src/js/helpers';

export function transform(formConfig, form) {
Expand All @@ -23,6 +24,13 @@ export function transform(formConfig, form) {
},
});
}
export const isProductionOfTestProdEnv = automatedTest => {
return (
environment.isProduction() ||
automatedTest ||
(global && global?.window && global?.window?.buildType)
);
};

export const relationshipLabels = {
child: 'Child, stepchild, adopted child',
Expand Down Expand Up @@ -128,7 +136,10 @@ export const ageWarning = (
aria-live="polite"
>
<div className="vads-u-flex--1 vads-u-margin-top--2p5 vads-u-margin-x--2 ">
<i className="fas fa-info-circle" />
<va-icon
size={4}
icon="see Storybook for icon names: https://design.va.gov/storybook/?path=/docs/uswds-va-icon--default"
/>
</div>
<div className="vads-u-flex--5">
<p className="vads-u-font-size--base">
Expand Down
Expand Up @@ -15,6 +15,7 @@ describe('Edu 5490 personalInformation directDeposit', () => {
uiSchema,
} = formConfig.chapters.personalInformation.pages.directDeposit;
it('should render', () => {
global.window.buildType = true;
const form = ReactTestUtils.renderIntoDocument(
<DefinitionTester schema={schema} data={{}} uiSchema={uiSchema} />,
);
Expand All @@ -27,6 +28,7 @@ describe('Edu 5490 personalInformation directDeposit', () => {

describe('Edu 5490 directDeposit', () => {
it('should execute validateRoutingNumber', () => {
global.window.buildType = true;
const errors = {
addError: (pattern = undefined) => {
let result;
Expand Down Expand Up @@ -61,6 +63,7 @@ describe('Edu 5490 directDeposit', () => {
);
});
it('should execute gaBankInfoHelpText', () => {
global.window.buildType = true;
gaBankInfoHelpText();
});
});
@@ -0,0 +1,66 @@
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import { findDOMNode } from 'react-dom';
import { expect } from 'chai';
import { DefinitionTester } from 'platform/testing/unit/schemaform-utils.jsx';
import formConfig from '../../config/form';
import {
gaBankInfoHelpText,
validateRoutingNumber,
} from '../../content/directDepositUpdate';

describe('Edu 5490 personalInformation directDepositUpdate', () => {
const {
schema,
uiSchema,
} = formConfig.chapters.personalInformation.pages.directDeposit;
it('should render', () => {
const form = ReactTestUtils.renderIntoDocument(
<DefinitionTester schema={schema} data={{}} uiSchema={uiSchema} />,
);
const formDOM = findDOMNode(form);
expect(formDOM).to.not.be.null;

// expect(formDOM.querySelectorAll('input, select').length).to.equal(15);
});
});

describe('Edu 5490 directDepositUpdate', () => {
it('should execute validateRoutingNumber', () => {
const errors = {
addError: (pattern = undefined) => {
let result;
if (pattern) {
result = pattern;
}
return result;
},
};
const routingNumber = 123;
const validRoutingNumber = '026009593';
const formData = {};
const {
schema,
} = formConfig.chapters.personalInformation.pages.directDeposit;
const errorMessages = {
pattern: 'n/a',
};
validateRoutingNumber(
errors,
routingNumber,
formData,
schema,
errorMessages,
);
validateRoutingNumber(
errors,
validRoutingNumber,
formData,
schema,
errorMessages,
);
});
it('should execute gaBankInfoHelpText', () => {
gaBankInfoHelpText();
});
});

0 comments on commit 01b1d73

Please sign in to comment.