From 269f78ff5cdb6668b1ddae2c7885e8783aa68af2 Mon Sep 17 00:00:00 2001 From: govcioChad <162637891+govcioChad@users.noreply.github.com> Date: Fri, 27 Dec 2024 07:21:21 -0800 Subject: [PATCH] #vebt-853 #comment Form tester utility 22-10282 form (#33582) * #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 --- .../tests/10282-edu-benefits.cypress.spec.js | 58 +++++++++++++++++++ .../data/{maximal.json => maximal-test.json} | 10 ++-- .../data/{minimal.json => minimal-test.json} | 6 +- .../tests/fixtures/data/transformedData.js | 10 +--- .../fixtures/mocks/application-submit.json | 15 +++++ .../tests/submit-transformer.unit.spec.js | 19 +++--- 6 files changed, 93 insertions(+), 25 deletions(-) create mode 100644 src/applications/edu-benefits/10282/tests/10282-edu-benefits.cypress.spec.js rename src/applications/edu-benefits/10282/tests/fixtures/data/{maximal.json => maximal-test.json} (86%) rename src/applications/edu-benefits/10282/tests/fixtures/data/{minimal.json => minimal-test.json} (68%) create mode 100644 src/applications/edu-benefits/10282/tests/fixtures/mocks/application-submit.json diff --git a/src/applications/edu-benefits/10282/tests/10282-edu-benefits.cypress.spec.js b/src/applications/edu-benefits/10282/tests/10282-edu-benefits.cypress.spec.js new file mode 100644 index 000000000000..d5db95bec4b0 --- /dev/null +++ b/src/applications/edu-benefits/10282/tests/10282-edu-benefits.cypress.spec.js @@ -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); diff --git a/src/applications/edu-benefits/10282/tests/fixtures/data/maximal.json b/src/applications/edu-benefits/10282/tests/fixtures/data/maximal-test.json similarity index 86% rename from src/applications/edu-benefits/10282/tests/fixtures/data/maximal.json rename to src/applications/edu-benefits/10282/tests/fixtures/data/maximal-test.json index 14b0d5990365..f0faf26a598f 100644 --- a/src/applications/edu-benefits/10282/tests/fixtures/data/maximal.json +++ b/src/applications/edu-benefits/10282/tests/fixtures/data/maximal-test.json @@ -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": "janedoe@gmail.com", @@ -25,8 +25,6 @@ "first": "Jane", "middle": "Test", "last": "Doe" - }, - "signature": "Jane Doe", - "AGREED": true + } } } diff --git a/src/applications/edu-benefits/10282/tests/fixtures/data/minimal.json b/src/applications/edu-benefits/10282/tests/fixtures/data/minimal-test.json similarity index 68% rename from src/applications/edu-benefits/10282/tests/fixtures/data/minimal.json rename to src/applications/edu-benefits/10282/tests/fixtures/data/minimal-test.json index 19c31ffdf7a8..4b8c451f6bbb 100644 --- a/src/applications/edu-benefits/10282/tests/fixtures/data/minimal.json +++ b/src/applications/edu-benefits/10282/tests/fixtures/data/minimal-test.json @@ -1,6 +1,6 @@ { "data": { - "state": "Virginia", + "state": "VA", "country": "United States", "contactInfo": { "email": "janedoe@gmail.com" @@ -10,8 +10,6 @@ "first": "Jane", "last": "Doe" }, - "highestLevelOfEducation": {}, - "signature": "Jane Doe", - "AGREED": true + "highestLevelOfEducation": {} } } \ No newline at end of file diff --git a/src/applications/edu-benefits/10282/tests/fixtures/data/transformedData.js b/src/applications/edu-benefits/10282/tests/fixtures/data/transformedData.js index c66897c99037..3905e7c0ff20 100644 --- a/src/applications/edu-benefits/10282/tests/fixtures/data/transformedData.js +++ b/src/applications/edu-benefits/10282/tests/fixtures/data/transformedData.js @@ -1,5 +1,5 @@ const transformedMinimalDataActual = { - state: 'Virginia', + state: 'VA', country: 'United States', contactInfo: { email: 'janedoe@gmail.com', @@ -10,8 +10,6 @@ const transformedMinimalDataActual = { last: 'Doe', }, highestLevelOfEducation: {}, - // signature: 'Jane Doe', - // AGREED: true, }; export const transformedMinimalData = JSON.stringify({ @@ -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: 'janedoe@gmail.com', @@ -45,8 +43,6 @@ const transformedMaximalDataActual = { middle: 'Test', last: 'Doe', }, - signature: 'Jane Doe', - AGREED: true, }; export const transformedMaximalData = JSON.stringify({ diff --git a/src/applications/edu-benefits/10282/tests/fixtures/mocks/application-submit.json b/src/applications/edu-benefits/10282/tests/fixtures/mocks/application-submit.json new file mode 100644 index 000000000000..55a780b66e7c --- /dev/null +++ b/src/applications/edu-benefits/10282/tests/fixtures/mocks/application-submit.json @@ -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": {} + } + } + } + } + \ No newline at end of file diff --git a/src/applications/edu-benefits/10282/tests/submit-transformer.unit.spec.js b/src/applications/edu-benefits/10282/tests/submit-transformer.unit.spec.js index 1652c0ac8c3d..a633da769313 100644 --- a/src/applications/edu-benefits/10282/tests/submit-transformer.unit.spec.js +++ b/src/applications/edu-benefits/10282/tests/submit-transformer.unit.spec.js @@ -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', () => { @@ -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, + ); + }); });