Skip to content

Commit

Permalink
VATEAM-91741: Normalize Identification Information pattern output (#2274
Browse files Browse the repository at this point in the history
)

* Add Identification Information fragment

* Import identificationInformation fragment into digitalForm fragment

* Extract Identification Information fields

* Fix imports
  • Loading branch information
derekhouck authored Sep 18, 2024
1 parent 52edb57 commit 195a33f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const identificationInformation = require('./identificationInformation.graphql');
const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql');

/*
Expand All @@ -6,6 +7,7 @@ const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql');
*
*/
module.exports = `
${identificationInformation}
${nameAndDateOfBirth}
fragment digitalForm on NodeDigitalForm {
Expand All @@ -26,6 +28,7 @@ module.exports = `
entityLabel
}
}
...identificationInformation
...nameAndDateOfBirth
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ describe('digitalForm fragment', () => {
});

describe('chapter fragments', () => {
it('imports the identificationInformation fragment', () => {
expect(digitalForm).to.have.string('fragment identificationInformation');
expect(digitalForm).to.have.string('...identificationInformation');
});

it('imports the nameAndDateOfBirth fragment', () => {
expect(digitalForm).to.have.string('fragment nameAndDateOfBirth');
expect(digitalForm).to.have.string('...nameAndDateOfBirth');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* The "Identification Information" Digital Form pattern.
*
* Pattern documentation:
* https://design.va.gov/patterns/ask-users-for/social-security-number
*
*/
module.exports = `
fragment identificationInformation on ParagraphDigitalFormIdentificationInfo {
fieldTitle
fieldIncludeVeteranSService
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable @department-of-veterans-affairs/axe-check-required */

import { expect } from 'chai';
import identificationInformation from './identificationInformation.graphql';

describe('identificationInformation fragment', () => {
it('includes fieldTitle', () => {
expect(identificationInformation).to.have.string('fieldTitle');
});
it('includes fieldIncludeVeteranSService', () => {
expect(identificationInformation).to.have.string(
'fieldIncludeVeteranSService',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ const { logDrupal } = require('../../utilities-drupal');

const extractAdditionalFields = entity => {
const additionalFields = {};
const { entityId } = entity.type.entity;

if (entity.type.entity.entityId === 'digital_form_name_and_date_of_bi') {
if (entityId === 'digital_form_name_and_date_of_bi') {
additionalFields.includeDateOfBirth = entity.fieldIncludeDateOfBirth;
} else if (entityId === 'digital_form_identification_info') {
additionalFields.includeServiceNumber = entity.fieldIncludeVeteranSService;
}

return additionalFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,10 @@ describe('postProcessDigitalForm', () => {
},
},
};
let processedResult;

beforeEach(() => {
processedResult = postProcessDigitalForm(queryResult);
});

it('returns a normalized JSON object', () => {
const testForm = processedResult[1];
const processedResult = postProcessDigitalForm(queryResult);
const [, testForm] = processedResult;
const testChapter = testForm.chapters[1];

expect(processedResult.length).to.eq(2);
Expand All @@ -104,7 +100,8 @@ describe('postProcessDigitalForm', () => {
});

it('includes an OMB info object', () => {
const { ombInfo } = processedResult[1];
const [, testForm] = postProcessDigitalForm(queryResult);
const { ombInfo } = testForm;
// expDate is 2027-01-29
const formattedDate = '1/29/2027';

Expand All @@ -115,11 +112,44 @@ describe('postProcessDigitalForm', () => {

context('with a Name and Date of Birth step', () => {
it('includes the appropriate fields', () => {
const { additionalFields } = processedResult[1].chapters[1];
const [, testForm] = postProcessDigitalForm(queryResult);
const { additionalFields } = testForm.chapters[1];

expect(additionalFields.includeDateOfBirth).to.eq(false);
});
});

context('with an Identification Information step', () => {
let additionalFields;

beforeEach(() => {
twoStepEntity.fieldChapters.push({
entity: {
entityId: '160594',
type: {
entity: {
entityId: 'digital_form_identification_info',
entityLabel: 'Identification Information',
},
},
fieldTitle: 'Identification information',
fieldIncludeVeteranSService: true,
},
});
const [, testForm] = postProcessDigitalForm(queryResult);
[{ additionalFields }] = testForm.chapters.filter(
chapter => chapter.type === 'digital_form_identification_info',
);
});

it('includes appropriate fields', () => {
expect(additionalFields.includeServiceNumber).to.eq(true);
});

it('does not include inappropriate fields', () => {
expect(additionalFields.includeDateOfBirth).to.eq(undefined);
});
});
});

context('with a malformed query result', () => {
Expand Down

0 comments on commit 195a33f

Please sign in to comment.