Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Integration form engine 2 #2273

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
*
* The "Address" Digital Form pattern.
*
* Pattern documentation:
* https://design.va.gov/patterns/ask-users-for/addresses
*
*/
module.exports = `
fragment address on ParagraphDigitalFormAddress {
fieldTitle
fieldMilitaryAddressCheckbox
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @department-of-veterans-affairs/axe-check-required */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint disabled here


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

describe('address fragment', () => {
it('includes fieldTitle', () => {
expect(address).to.have.string('fieldTitle');
});
it('includes fieldMilitaryAddressCheckbox', () => {
expect(address).to.have.string('fieldMilitaryAddressCheckbox');
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const address = require('./address.graphql');
const identificationInformation = require('./identificationInformation.graphql');
const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql');

/*
Expand All @@ -6,13 +8,19 @@ const nameAndDateOfBirth = require('./nameAndDateOfBirth.graphql');
*
*/
module.exports = `
${address}
${identificationInformation}
${nameAndDateOfBirth}
fragment digitalForm on NodeDigitalForm {
nid
entityLabel
fieldVaFormNumber
fieldOmbNumber
fieldRespondentBurden
fieldExpirationDate {
value
}
fieldChapters {
entity {
entityId
Expand All @@ -22,6 +30,8 @@ module.exports = `
entityLabel
}
}
...address
...identificationInformation
...nameAndDateOfBirth
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,26 @@ describe('digitalForm fragment', () => {
expect(digitalForm).to.have.string('nid');
expect(digitalForm).to.have.string('entityLabel');
expect(digitalForm).to.have.string('fieldVaFormNumber');
expect(digitalForm).to.have.string('fieldOmbNumber');
expect(digitalForm).to.have.string('fieldChapters');
});

it('include OMB info', () => {
expect(digitalForm).to.have.string('fieldOmbNumber');
expect(digitalForm).to.have.string('fieldRespondentBurden');
expect(digitalForm).to.have.string('fieldExpirationDate');
});

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

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 */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint disabled here


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,15 +2,34 @@ 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') {
additionalFields.includeDateOfBirth = entity.fieldIncludeDateOfBirth;
switch (entityId) {
case 'digital_form_address':
additionalFields.militaryAddressCheckbox =
entity.fieldMilitaryAddressCheckbox;
break;
case 'digital_form_name_and_date_of_bi':
additionalFields.includeDateOfBirth = entity.fieldIncludeDateOfBirth;
break;
case 'digital_form_identification_info':
additionalFields.includeServiceNumber =
entity.fieldIncludeVeteranSService;
break;
default:
break;
}

return additionalFields;
};
const extractForms = resultObject => resultObject?.data?.nodeQuery?.entities;

const formatDate = dateString => {
const removeLeadingZero = s => s.replace(/^0+/, '');
const [year, month, day] = dateString.split('-');
return `${removeLeadingZero(month)}/${removeLeadingZero(day)}/${year}`;
};

const normalizeChapter = ({ entity }) => {
return {
id: parseInt(entity.entityId, 10),
Expand All @@ -27,7 +46,11 @@ const normalizeForm = (form, logger = logDrupal) => {
cmsId: form.nid,
formId: form.fieldVaFormNumber,
title: form.entityLabel,
ombNumber: form.fieldOmbNumber,
ombInfo: {
expDate: formatDate(form.fieldExpirationDate.value),
ombNumber: form.fieldOmbNumber,
resBurden: form.fieldRespondentBurden,
},
chapters: form.fieldChapters.map(normalizeChapter),
};
} catch (error) {
Expand Down
Loading
Loading