Skip to content

Commit

Permalink
Appoint a rep container unit tests (#33510)
Browse files Browse the repository at this point in the history
* Authorization unit tests

* Veteran unit tests

* Deleted unused page

* Moved claimant tests into subfolder

* commenting out test

* NextStepsPage unit test

* Intro page unit test

* Uncommenting + skipping test for now
  • Loading branch information
cosu419 authored Dec 12, 2024
1 parent 9e514dc commit 92b22c2
Show file tree
Hide file tree
Showing 22 changed files with 477 additions and 68 deletions.
24 changes: 0 additions & 24 deletions src/applications/representative-appoint/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
claimantContactMailing,
veteranPersonalInformation,
veteranContactPhoneEmail,
// veteranContactPhoneEmailForNonVeteran,
veteranContactMailing,
veteranContactMailingClaimant,
veteranIdentification,
Expand Down Expand Up @@ -207,22 +206,6 @@ const formConfig = {
uiSchema: claimantContactPhoneEmail.uiSchema,
schema: claimantContactPhoneEmail.schema,
},
// ...profileContactInfo({
// contactInfoPageKey: 'confirmContactInfo',
// contactPath: 'claimant-contact',
// contactInfoRequiredKeys: [
// 'mailingAddress',
// 'email',
// 'homePhone',
// 'mobilePhone',
// ],
// included: ['homePhone', 'mobilePhone', 'mailingAddress', 'email'],
// depends: formData => {
// const isLoggedIn = formData?.['view:isLoggedIn'] ?? false;
// const isNotVeteran = !preparerIsVeteran({ formData });
// return isLoggedIn && isNotVeteran;
// },
// }),

veteranPersonalInformation: {
title: `Your name and date of birth`,
Expand All @@ -245,13 +228,6 @@ const formConfig = {
uiSchema: veteranContactPhoneEmail.uiSchema,
schema: veteranContactPhoneEmail.schema,
},
// veteranContactPhoneEmailForNonVeteran: {
// path: 'veteran-contact-phone-email-for-non-veteran',
// title: `Veteran’s phone number and email address`,
// depends: formData => !preparerIsVeteran({ formData }),
// uiSchema: veteranContactPhoneEmailForNonVeteran.uiSchema,
// schema: veteranContactPhoneEmailForNonVeteran.schema,
// },
veteranIdentification: {
path: 'veteran-identification',
title: `Your identification information`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,7 @@ function mapStateToProps(state) {
};
}

// named export for testing
export { IntroductionPage };

export default connect(mapStateToProps)(IntroductionPage);
2 changes: 0 additions & 2 deletions src/applications/representative-appoint/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import * as claimantPersonalInformation from './claimant/claimantPersonalInforma
import * as claimantContactMailing from './claimant/claimantContactMailing';
import * as veteranPersonalInformation from './veteran/veteranPersonalInformation';
import * as veteranContactPhoneEmail from './veteran/veteranContactPhoneEmail';
import * as veteranContactPhoneEmailForNonVeteran from './veteran/veteranContactPhoneEmailForNonVeteran';
import * as veteranContactMailing from './veteran/veteranContactMailing';
import * as veteranContactMailingClaimant from './veteran/veteranContactMailingClaimant';
import * as veteranIdentification from './veteran/veteranIdentification';
Expand All @@ -35,7 +34,6 @@ export {
claimantContactMailing,
veteranPersonalInformation,
veteranContactPhoneEmail,
veteranContactPhoneEmailForNonVeteran,
veteranContactMailing,
veteranContactMailingClaimant,
veteranIdentification,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React from 'react';
import { Provider } from 'react-redux';
import { render } from '@testing-library/react';
import { expect } from 'chai';

import { $, $$ } from 'platform/forms-system/src/js/utilities/ui';

import IntroductionPage from '../../containers/IntroductionPage';
import formConfig from '../../config/form';

const getData = ({
loggedIn = true,
isVerified = true,
data = {},
contestedIssues = {},
} = {}) => ({
props: {
loggedIn,
location: {
basename: '/sc-base-url',
},
route: {
formConfig,
pageList: [{ path: '/introduction' }, { path: '/next', formConfig }],
},
},
mockStore: {
getState: () => ({
user: {
login: {
currentlyLoggedIn: loggedIn,
},
profile: {
userFullName: { last: 'last' },
dob: '2000-01-01',
claims: { appeals: true },
savedForms: [],
prefillsAvailable: [],
verified: isVerified,
},
},
form: {
formId: formConfig.formId,
loadedStatus: 'success',
savedStatus: '',
loadedData: {
metadata: {},
},
data,
contestedIssues,
},
scheduledDowntime: {
globalDowntime: null,
isReady: true,
isPending: false,
serviceMap: { get() {} },
dismissedDowntimeWarnings: [],
},
}),
subscribe: () => {},
dispatch: () => {},
},
});

describe('IntroductionPage', () => {
it('should render', () => {
const { props, mockStore } = getData({ loggedIn: false });
const { container } = render(
<Provider store={mockStore}>
<IntroductionPage {...props} />
</Provider>,
);
expect($('h1', container).textContent).to.eq(
'Get help from a VA accredited representative or VSO',
);
expect($('va-process-list', container)).to.exist;
expect($('va-omb-info', container)).to.exist;
expect($('va-alert[status="info"]', container)).to.exist;
});

it('should render start action links', () => {
const { props, mockStore } = getData();
const { container } = render(
<Provider store={mockStore}>
<IntroductionPage {...props} />
</Provider>,
);
expect($$('.vads-c-action-link--green', container).length).to.equal(2);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { expect } from 'chai';
import configureMockStore from 'redux-mock-store';
import { $ } from 'platform/forms-system/src/js/utilities/ui';
import NextStepsPage from '../../containers/NextStepsPage';
import mockFormData from '../fixtures/data/21-22a/form-data.json';

describe('<NextStepsPage />', () => {
const mockStore = configureMockStore();

it('renders the component with mocked Redux store', () => {
const store = mockStore({
form: {
data: mockFormData,
},
});

const { container } = render(
<Provider store={store}>
<NextStepsPage />
</Provider>,
);

expect($('h1', container).textContent).to.eq(
'Get help from a VA accredited representative or VSO',
);
expect($('h2', container).textContent).to.eq('Your next steps');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { expect } from 'chai';
import { render } from '@testing-library/react';

import { DefinitionTester } from 'platform/testing/unit/schemaform-utils';
import { $ } from 'platform/forms-system/src/js/utilities/ui';
import mockFormData from '../../fixtures/data/form-data.json';
import formConfig from '../../../config/form';

describe('Authorize address page', () => {
const {
schema,
uiSchema,
} = formConfig.chapters.authorization.pages.authorizeAddress;

it('should render', () => {
const { container } = render(
<DefinitionTester
definitions={{}}
schema={schema}
uiSchema={uiSchema}
data={{}}
formData={mockFormData}
/>,
);

expect($('button[type="submit"]', container)).to.exist;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { expect } from 'chai';
import { render } from '@testing-library/react';

import { DefinitionTester } from 'platform/testing/unit/schemaform-utils';
import { $ } from 'platform/forms-system/src/js/utilities/ui';

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

describe('Authorize Inside VA page', () => {
const {
schema,
uiSchema,
} = formConfig.chapters.authorization.pages.authorizeInsideVA;

it('should render', () => {
const { container } = render(
<DefinitionTester
definitions={{}}
schema={schema}
uiSchema={uiSchema}
data={{}}
formData={{}}
/>,
);

expect($('button[type="submit"]', container)).to.exist;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { expect } from 'chai';
import { render } from '@testing-library/react';

import { DefinitionTester } from 'platform/testing/unit/schemaform-utils';
import { $ } from 'platform/forms-system/src/js/utilities/ui';

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

describe('Authorize medical page', () => {
const {
schema,
uiSchema,
} = formConfig.chapters.authorization.pages.authorizeMedical;

it('should render', () => {
const { container } = render(
<DefinitionTester
definitions={{}}
schema={schema}
uiSchema={uiSchema}
data={{}}
formData={{}}
/>,
);

expect($('button[type="submit"]', container)).to.exist;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { expect } from 'chai';
import { render } from '@testing-library/react';

import { DefinitionTester } from 'platform/testing/unit/schemaform-utils';
import { $ } from 'platform/forms-system/src/js/utilities/ui';

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

describe('Authorize medical select page', () => {
const {
schema,
uiSchema,
} = formConfig.chapters.authorization.pages.authorizeMedicalSelect;

it('should render', () => {
const { container } = render(
<DefinitionTester
definitions={{}}
schema={schema}
uiSchema={uiSchema}
data={{}}
formData={{}}
/>,
);

expect($('button[type="submit"]', container)).to.exist;
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { expect } from 'chai';
import { render } from '@testing-library/react';

import { DefinitionTester } from 'platform/testing/unit/schemaform-utils';
import { $ } from 'platform/forms-system/src/js/utilities/ui';

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

describe('Authorize Outside VA page', () => {
const {
schema,
uiSchema,
} = formConfig.chapters.authorization.pages.authorizeOutsideVA;

it('should render', () => {
const { container } = render(
<DefinitionTester
definitions={{}}
schema={schema}
uiSchema={uiSchema}
data={{}}
formData={{}}
/>,
);

expect($('button[type="submit"]', container)).to.exist;
});
});
Loading

0 comments on commit 92b22c2

Please sign in to comment.