From 195a33fe48b978a960a83f2a13ec398a003cc358 Mon Sep 17 00:00:00 2001 From: Derek Houck Date: Wed, 18 Sep 2024 10:44:18 -0500 Subject: [PATCH] VATEAM-91741: Normalize Identification Information pattern output (#2274) * Add Identification Information fragment * Import identificationInformation fragment into digitalForm fragment * Extract Identification Information fields * Fix imports --- .../fragments/digitalForm.graphql.js | 3 ++ .../digitalForm.graphql.unit.spec.js | 5 ++ .../identificationInformation.graphql.js | 14 ++++++ ...tificationInformation.graphql.unit.spec.js | 15 ++++++ .../digitalForm/postProcessDigitalForm.js | 5 +- .../postProcessDigitalForm.unit.spec.js | 46 +++++++++++++++---- 6 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.js create mode 100644 src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.unit.spec.js diff --git a/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.js b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.js index 78741337d3..7c47c8c381 100644 --- a/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.js +++ b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.js @@ -1,3 +1,4 @@ +const identificationInformation = require('./identificationInformation.graphql'); const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql'); /* @@ -6,6 +7,7 @@ const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql'); * */ module.exports = ` + ${identificationInformation} ${nameAndDateOfBirth} fragment digitalForm on NodeDigitalForm { @@ -26,6 +28,7 @@ module.exports = ` entityLabel } } + ...identificationInformation ...nameAndDateOfBirth } } diff --git a/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.unit.spec.js b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.unit.spec.js index b31db07e1d..1002b7046c 100644 --- a/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.unit.spec.js +++ b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/digitalForm.graphql.unit.spec.js @@ -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'); diff --git a/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.js b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.js new file mode 100644 index 0000000000..8d583cf6d5 --- /dev/null +++ b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.js @@ -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 + } +`; diff --git a/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.unit.spec.js b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.unit.spec.js new file mode 100644 index 0000000000..3935815a3f --- /dev/null +++ b/src/site/stages/build/drupal/static-data-files/digitalForm/fragments/identificationInformation.graphql.unit.spec.js @@ -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', + ); + }); +}); diff --git a/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.js b/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.js index 7e8c7e8ab2..b010ed63d0 100644 --- a/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.js +++ b/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.js @@ -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; diff --git a/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.unit.spec.js b/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.unit.spec.js index 6bb3cf08f9..d734efe58c 100644 --- a/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.unit.spec.js +++ b/src/site/stages/build/drupal/static-data-files/digitalForm/postProcessDigitalForm.unit.spec.js @@ -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); @@ -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'; @@ -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', () => {