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, + ); + }); });