Skip to content

Commit

Permalink
#vebt-853 #comment Form tester utility 22-10282 form (#33582)
Browse files Browse the repository at this point in the history
* #vebt-853 #comment Form tester utility 22-10282 form

* #vebt-853 #comment Removed comments of code and fixed maximal data

* #vebt-853 #comment Fixed unit test 10282

* #vebt-853 #comment Added mock submit to e2e test
  • Loading branch information
govcioChad authored Dec 27, 2024
1 parent e7b2dbc commit 269f78f
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import path from 'path';

import testForm from 'platform/testing/e2e/cypress/support/form-tester';
import { createTestConfig } from 'platform/testing/e2e/cypress/support/form-tester/utilities';
import mockSubmit from './fixtures/mocks/application-submit.json';

import formConfig from '../config/form';
import manifest from '../manifest.json';

const testConfig = createTestConfig(
{
dataPrefix: 'data',

dataDir: path.join(__dirname, 'fixtures', 'data'),

dataSets: ['minimal-test.json', 'maximal-test.json'],

pageHooks: {
introduction: ({ afterHook }) => {
afterHook(() => {
cy.get('a.va-link--primary')
.first()
.click();
});
},
'review-and-submit': ({ afterHook }) => {
afterHook(() => {
cy.get('va-text-input')
.shadow()
.find('input')
.type('Jane Doe');
cy.get(`va-checkbox`)
.shadow()
.find('input')
.check({ force: true });

cy.findAllByText(/submit/i, { selector: 'button' })
.first()
.click();
});
},
},

setupPerTest: () => {
// Log in if the form requires an authenticated session.
// cy.login();
cy.intercept('POST', formConfig.submitUrl, mockSubmit);
},

// Skip tests in CI until the form is released.
// Remove this setting when the form has a content page in production.
skip: Cypress.env('CI'),
},
manifest,
formConfig,
);

testForm(testConfig);
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"raceAndGender": true,
"ethnicity": "NA",
"orginRace": {
"gender": "NA",
"originRace": {
"noAnswer": true
},
"gender": "NA",
"state": "Texas",
"state": "TX",
"country": "United States",
"contactInfo": {
"email": "[email protected]",
Expand All @@ -25,8 +25,6 @@
"first": "Jane",
"middle": "Test",
"last": "Doe"
},
"signature": "Jane Doe",
"AGREED": true
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"data": {
"state": "Virginia",
"state": "VA",
"country": "United States",
"contactInfo": {
"email": "[email protected]"
Expand All @@ -10,8 +10,6 @@
"first": "Jane",
"last": "Doe"
},
"highestLevelOfEducation": {},
"signature": "Jane Doe",
"AGREED": true
"highestLevelOfEducation": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const transformedMinimalDataActual = {
state: 'Virginia',
state: 'VA',
country: 'United States',
contactInfo: {
email: '[email protected]',
Expand All @@ -10,8 +10,6 @@ const transformedMinimalDataActual = {
last: 'Doe',
},
highestLevelOfEducation: {},
// signature: 'Jane Doe',
// AGREED: true,
};

export const transformedMinimalData = JSON.stringify({
Expand All @@ -31,8 +29,8 @@ const transformedMaximalDataActual = {
raceAndGender: true,
ethnicity: 'NA',
gender: 'NA',
orginRace: { noAnswer: true },
state: 'Texas',
originRace: { noAnswer: true },
state: 'TX',
country: 'United States',
contactInfo: {
email: '[email protected]',
Expand All @@ -45,8 +43,6 @@ const transformedMaximalDataActual = {
middle: 'Test',
last: 'Doe',
},
signature: 'Jane Doe',
AGREED: true,
};

export const transformedMaximalData = JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"data": {
"id": "1234567890-uuid",
"type": "education_benefits_claim",
"attributes": {
"status": "pending",
"updatedAt": "2022-01-02T03:04:05.067Z",
"createdAt": "2022-01-02T03:04:05.067Z",
"formData": {
"data": {}
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import formConfig from '../config/form';

import { transform } from '../config/submit-transformer';

import { transformedMinimalData } from './fixtures/data/transformedData';
import {
transformedMinimalData,
transformedMaximalData,
} from './fixtures/data/transformedData';

import minimalData from './fixtures/data/minimal.json';
// import maximalData from './fixtures/data/maximal.json';
import minimalData from './fixtures/data/minimal-test.json';
import maximalData from './fixtures/data/maximal-test.json';

describe('transform', () => {
it('should transform minimal data correctly', () => {
Expand All @@ -16,9 +19,9 @@ describe('transform', () => {
);
});

// it('should transform maximal data correctly', () => {
// expect(transform(formConfig, maximalData)).to.deep.equal(
// transformedMaximalData,
// );
// });
it('should transform maximal data correctly', () => {
expect(transform(formConfig, maximalData)).to.deep.equal(
transformedMaximalData,
);
});
});

0 comments on commit 269f78f

Please sign in to comment.