Skip to content

Commit

Permalink
Appoint a rep phone validation bug (#33887)
Browse files Browse the repository at this point in the history
* Renamed 'Primary phone' to primaryPhone to avoid UI bug with validation display.

* More 'primary phone' renaming

* Updated helper to compare old and new rep

* Repair unit test

* Renamed isAttorneyOrClaimsAgent to formIs2122A for clarity
  • Loading branch information
cosu419 authored Jan 6, 2025
1 parent d4e4224 commit d12e8c6
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 66 deletions.
4 changes: 2 additions & 2 deletions src/applications/representative-appoint/api/generatePDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { apiRequest } from '@department-of-veterans-affairs/platform-utilities/a
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
import * as Sentry from '@sentry/browser';
import { pdfTransform } from '../utilities/pdfTransform';
import { isAttorneyOrClaimsAgent } from '../utilities/helpers';
import { formIs2122A } from '../utilities/helpers';
import manifest from '../manifest.json';

export const generatePDF = async formData => {
Expand All @@ -20,7 +20,7 @@ export const generatePDF = async formData => {
body: JSON.stringify(transformedFormData),
};

const formType = isAttorneyOrClaimsAgent(formData) ? '2122a' : '2122';
const formType = formIs2122A(formData) ? '2122a' : '2122';

const requestUrl = `${
environment.API_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SearchResult from './SearchResult';
import SearchInput from './SearchInput';
import { useReviewPage } from '../hooks/useReviewPage';
import { SearchResultsHeader } from './SearchResultsHeader';
import { isAttorneyOrClaimsAgent } from '../utilities/helpers';
import { isVSORepresentative } from '../utilities/helpers';

const SelectAccreditedRepresentative = props => {
const {
Expand Down Expand Up @@ -73,8 +73,8 @@ const SelectAccreditedRepresentative = props => {
const selection = formData['view:selectedRepresentative'];

const repTypeChanged =
isAttorneyOrClaimsAgent(currentSelectedRep) !==
isAttorneyOrClaimsAgent(newSelection);
isVSORepresentative(currentSelectedRep.current) !==
isVSORepresentative(newSelection);
const noSelectionExists = !selection && !selectionMade;
const noNewSelection =
!newSelection || newSelection === currentSelectedRep.current;
Expand Down
21 changes: 6 additions & 15 deletions src/applications/representative-appoint/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import ConfirmationPage from '../containers/ConfirmationPage';
import { generatePDF } from '../api/generatePDF';
import NextStepsPage from '../containers/NextStepsPage';
import PreSubmitInfo from '../containers/PreSubmitInfo';
import {
preparerIsVeteran,
isAttorneyOrClaimsAgent,
} from '../utilities/helpers';
import { preparerIsVeteran, formIs2122A } from '../utilities/helpers';
import {
authorizeMedical,
authorizeMedicalSelect,
Expand Down Expand Up @@ -240,10 +237,7 @@ const formConfig = {
path: 'veteran-service-information',
title: `Your service information`,
depends: formData => {
return (
isAttorneyOrClaimsAgent(formData) &&
preparerIsVeteran({ formData })
);
return formIs2122A(formData) && preparerIsVeteran({ formData });
},
uiSchema: veteranServiceInformation.uiSchema,
schema: veteranServiceInformation.schema,
Expand Down Expand Up @@ -286,10 +280,7 @@ const formConfig = {
path: 'veteran-service-information',
title: `Veteran's service information`,
depends: formData => {
return (
isAttorneyOrClaimsAgent(formData) &&
!preparerIsVeteran({ formData })
);
return formIs2122A(formData) && !preparerIsVeteran({ formData });
},
uiSchema: veteranServiceInformation.uiSchema,
schema: veteranServiceInformation.schema,
Expand Down Expand Up @@ -326,7 +317,7 @@ const formConfig = {
authorizeInsideVA: {
path: 'authorize-inside-va',
depends: formData => {
return isAttorneyOrClaimsAgent(formData);
return formIs2122A(formData);
},
title: 'Authorization for Access Inside VA Systems',
uiSchema: authorizeInsideVA.uiSchema,
Expand All @@ -335,7 +326,7 @@ const formConfig = {
authorizeOutsideVA: {
path: 'authorize-outside-va',
depends: formData => {
return isAttorneyOrClaimsAgent(formData);
return formIs2122A(formData);
},
title: 'Authorization for Access Outside VA Systems',
uiSchema: authorizeOutsideVA.uiSchema,
Expand All @@ -345,7 +336,7 @@ const formConfig = {
path: 'authorize-outside-va/names',
depends: formData => {
return (
isAttorneyOrClaimsAgent(formData) &&
formIs2122A(formData) &&
formData.authorizeOutsideVARadio === 'Yes'
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function prefillTransformer(formData) {
street: formData?.contactInformation?.address?.street,
};
newFormData.veteranEmail = formData?.contactInformation?.email;
newFormData['Primary phone'] = formData?.contactInformation?.primaryPhone;
newFormData.primaryPhone = formData?.contactInformation?.primaryPhone;
newFormData['Branch of Service'] =
formData?.militaryInformation?.serviceBranch;
// reset the applicant information in case of claimant type change
Expand Down Expand Up @@ -58,7 +58,7 @@ export default function prefillTransformer(formData) {
street: undefined,
};
newFormData.veteranEmail = undefined;
newFormData['Primary phone'] = undefined;
newFormData.primaryPhone = undefined;
newFormData['Branch of Service'] = undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export const uiSchema = {
profileNotUpdatedNote: {
'ui:description': () => <ProfileNotUpdatedNote includePhone />,
},
'Primary phone': phoneUI({
primaryPhone: phoneUI({
required: true,
}),
veteranEmail: emailUI(),
};

export const schema = {
type: 'object',
required: ['Primary phone'],
required: ['primaryPhone'],
properties: {
titleSchema,
profileNotUpdatedNote: { type: 'object', properties: {} },
'Primary phone': phoneSchema,
primaryPhone: phoneSchema,
veteranEmail: emailSchema,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const uiSchema = {
profileNotUpdatedNote: {
'ui:description': () => <ProfileNotUpdatedNote includePhone />,
},
'Primary phone': phoneUI({}),
primaryPhone: phoneUI({}),
veteranEmail: emailUI(),
};

Expand All @@ -26,7 +26,7 @@ export const schema = {
properties: {
titleSchema,
profileNotUpdatedNote: { type: 'object', properties: {} },
'Primary phone': phoneSchema,
primaryPhone: phoneSchema,
veteranEmail: emailSchema,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('prefillTransformer', () => {
postalCode: '75014',
});
expect(result.veteranEmail).to.eql('test2@test1.net');
expect(result['Primary phone']).to.eql('4445551212');
expect(result.primaryPhone).to.eql('4445551212');
expect(result['Branch of Service']).to.eql('Army');
});

Expand Down Expand Up @@ -91,7 +91,7 @@ describe('prefillTransformer', () => {
veteranFullName: 'test',
veteranDateOfBirth: 'test',
veteranEmail: 'test',
'Primary phone': 'test',
primaryPhone: 'test',
veteranHomeAddress: {
city: 'test',
country: 'test',
Expand All @@ -108,7 +108,7 @@ describe('prefillTransformer', () => {
expect(result.veteranFullName).to.be.undefined;
expect(result.veteranDateOfBirth).to.be.undefined;
expect(result.veteranEmail).to.be.undefined;
expect(result['Primary phone']).to.be.undefined;
expect(result.primaryPhone).to.be.undefined;
expect(result.veteranHomeAddress).to.eql({
city: undefined,
country: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Authenticated', () => {
h.verifyUrl(ROUTES.VETERAN_CONTACT_PHONE_EMAIL);
cy.injectAxeThenAxeCheck();

cy.get('input[name="root_Primary phone"]').type('5467364732');
cy.get('input[name="root_primaryPhone"]').type('5467364732');

h.clickContinue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('Unauthenticated', () => {
h.verifyUrl(ROUTES.VETERAN_CONTACT_PHONE_EMAIL);
cy.injectAxeThenAxeCheck();

cy.get('input[name="root_Primary phone"]').type('5467364732');
cy.get('input[name="root_primaryPhone"]').type('5467364732');

h.clickContinue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
"postalCode": "01050"
},
"veteranEmail": "test@example.com",
"Primary phone": "5551234567",
"primaryPhone": "5551234567",
"mobilePhone": "5551234567",
"internationalPhone": "001-555-123-4567",
"view:aidAttendance": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"postalCode": "01050"
},
"veteranEmail": "test@example.com",
"Primary phone": "5551234567",
"primaryPhone": "5551234567",
"mobilePhone": "5551234567",
"internationalPhone": "001-555-123-4567",
"view:aidAttendance": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"postalCode": "01050"
},
"veteranEmail": "test@example.com",
"'Primary phone'": "5551234567",
"primaryPhone": "5551234567",
"mobilePhone": "5551234567",
"internationalPhone": "001-555-123-4567",
"homeAddress": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"postalCode": "01050"
},
"veteranEmail": "test@example.com",
"Primary phone": "5551234567",
"primaryPhone": "5551234567",
"mobilePhone": "5551234567",
"internationalPhone": "001-555-123-4567",
"view:aidAttendance": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { isAttorneyOrClaimsAgent } from '../../utilities/helpers';
import { formIs2122A } from '../../utilities/helpers';

describe('isAttorneyOrClaimsAgent', () => {
describe('formIs2122A', () => {
it('should return true when the selected rep has an individualType of attorney', () => {
const mockFormData = {
'view:selectedRepresentative': {
Expand All @@ -10,7 +10,7 @@ describe('isAttorneyOrClaimsAgent', () => {
},
},
};
const result = isAttorneyOrClaimsAgent(mockFormData);
const result = formIs2122A(mockFormData);
expect(result).to.be.true;
});

Expand All @@ -22,7 +22,7 @@ describe('isAttorneyOrClaimsAgent', () => {
},
},
};
const result = isAttorneyOrClaimsAgent(mockFormData);
const result = formIs2122A(mockFormData);
expect(result).to.be.true;
});

Expand All @@ -34,7 +34,7 @@ describe('isAttorneyOrClaimsAgent', () => {
},
},
};
const result = isAttorneyOrClaimsAgent(mockFormData);
const result = formIs2122A(mockFormData);
expect(result).to.be.true;
});

Expand All @@ -46,7 +46,7 @@ describe('isAttorneyOrClaimsAgent', () => {
},
},
};
const result = isAttorneyOrClaimsAgent(mockFormData);
const result = formIs2122A(mockFormData);
expect(result).to.be.true;
});

Expand All @@ -58,7 +58,7 @@ describe('isAttorneyOrClaimsAgent', () => {
},
},
};
const result = isAttorneyOrClaimsAgent(mockFormData);
const result = formIs2122A(mockFormData);
expect(result).to.not.be.ok;
});

Expand All @@ -68,7 +68,7 @@ describe('isAttorneyOrClaimsAgent', () => {
attributes: {},
},
};
const result = isAttorneyOrClaimsAgent(mockFormData);
const result = formIs2122A(mockFormData);
expect(result).to.not.be.ok;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@ import { isVSORepresentative } from '../../utilities/helpers';

describe('isVSORepresentative', () => {
it('should return true when the selected rep has at least one organization', () => {
const mockFormData = {
'view:selectedRepresentative': {
type: 'individual',
attributes: {
accreditedOrganizations: { data: [{ id: 1 }, { id: 2 }] },
},
const mockRep = {
type: 'individual',
attributes: {
accreditedOrganizations: { data: [{ id: 1 }, { id: 2 }] },
},
};
const result = isVSORepresentative(mockFormData);
const result = isVSORepresentative(mockRep);
expect(result).to.be.true;
});

it('should return false when the selected rep has no organizations', () => {
const mockFormData = {
'view:selectedRepresentative': {
type: 'individual',
attributes: {
accreditedOrganizations: { data: [] },
},
const mockRep = {
type: 'individual',
attributes: {
accreditedOrganizations: { data: [] },
},
};
const result = isVSORepresentative(mockFormData);

const result = isVSORepresentative(mockRep);
expect(result).to.be.false;
});
});
20 changes: 13 additions & 7 deletions src/applications/representative-appoint/utilities/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,21 @@ export const getFormName = formData => {
return "Appointment of Individual As Claimant's Representative";
};

export const isVSORepresentative = formData => {
const rep = formData['view:selectedRepresentative'];

if (rep.attributes?.accreditedOrganizations?.data?.length > 0) {
/**
* Takes representative object (rather than formData object)
*/
export const isVSORepresentative = rep => {
if (rep?.attributes?.accreditedOrganizations?.data?.length > 0) {
return true;
}

return false;
};

export const isAttorneyOrClaimsAgent = formData =>
/**
* If the representative is a claims agent or attorney, user will fill out 21-22A
*/
export const formIs2122A = formData =>
['attorney', 'claimsAgent', 'claims_agent', 'claim_agents'].includes(
formData?.['view:selectedRepresentative']?.attributes?.individualType,
) || null;
Expand All @@ -162,7 +167,7 @@ export const getOrgName = formData => {
return formData['view:selectedRepresentative']?.attributes?.name;
}

if (isAttorneyOrClaimsAgent(formData)) {
if (formIs2122A(formData)) {
return null;
}

Expand Down Expand Up @@ -190,7 +195,8 @@ export const getRepresentativeName = formData => {
if (isOrg(formData)) {
return formData['view:selectedRepresentative']?.attributes?.name;
}
return isVSORepresentative(formData)

return isVSORepresentative(formData['view:selectedRepresentative'])
? formData.selectedAccreditedOrganizationName
: rep.attributes.fullName;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function pdfTransform(formData) {
veteranDateOfBirth: dateOfBirth,
serviceNumber,
veteranHomeAddress: homeAddress,
'Primary phone': phone,
primaryPhone: phone,
veteranEmail: email,
'view:selectedRepresentative': selectedRep,
applicantName,
Expand Down

0 comments on commit d12e8c6

Please sign in to comment.