Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Nov 27, 2024
1 parent 650f033 commit f190c39
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import ConfirmationIssues from '../../shared/components/ConfirmationIssues';
import { showValueOrNotSelected } from '../../shared/utils/confirmation';
import { SC_NEW_FORM_DATA } from '../constants';

// import maxData from '../tests/fixtures/data/maximal-test-v2.json';

export const ConfirmationPageV2 = () => {
resetStoredSubTask();

Expand All @@ -52,7 +54,7 @@ export const ConfirmationPageV2 = () => {
// Fix this after Lighthouse sets up the download URL
const downloadUrl = ''; // SC_PDF_DOWNLOAD_URL;

const { data = {} } = form;
const { data = {} } = form; // maxData;

const vaEvidence = getVAEvidence(data);
const privateEvidence = getPrivateEvidence(data);
Expand Down Expand Up @@ -246,7 +248,9 @@ export const ConfirmationPageV2 = () => {
<h3 className="vads-u-margin-top--2">
{evidenceContent.summaryTitle}
</h3>
<div>{evidenceContent.missingEvidenceReviewText}</div>
<div className="no-evidence">
{evidenceContent.missingEvidenceReviewText}
</div>
</>
)}

Expand Down
29 changes: 25 additions & 4 deletions src/applications/appeals/995/components/EvidenceSummaryLists.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ const removeButtonClass = [
'vads-u-margin-top--0',
].join(' ');

const confirmationPageLabel = showListOnly =>
showListOnly
? [
'vads-u-margin-bottom--0p5',
'vads-u-color--gray',
'vads-u-font-size--sm',
].join(' ')
: '';

const formatDate = (date = '', format = FORMAT_COMPACT_DATE_FNS) =>
// Use `parse` from date-fns because it is a non-ISO8061 formatted date string
// const parsedDate = parse(date, FORMAT_YMD_DATE_FNS, new Date());
Expand All @@ -72,7 +81,9 @@ export const VaContent = ({
}) =>
list?.length ? (
<>
<div className="va-title">{content.vaTitle}</div>
<div className={`va-title ${confirmationPageLabel(showListOnly)}`}>
{content.vaTitle}
</div>
{/* eslint-disable-next-line jsx-a11y/no-redundant-roles */}
<ul className="evidence-summary remove-bullets" role="list">
{list.map((location, index) => {
Expand Down Expand Up @@ -208,7 +219,9 @@ export const PrivateContent = ({
}) =>
list?.length ? (
<>
<div className="private-title">{content.privateTitle}</div>
<div className={`private-title ${confirmationPageLabel(showListOnly)}`}>
{content.privateTitle}
</div>
{/* eslint-disable-next-line jsx-a11y/no-redundant-roles */}
<ul className="evidence-summary remove-bullets" role="list">
{list.map((facility, index) => {
Expand Down Expand Up @@ -296,7 +309,13 @@ export const PrivateContent = ({
);
})}
<li key={LIMITATION_KEY} className={listClassNames(!showListOnly)}>
<div className="private-limitation">{limitContent.title}</div>
<div
className={`private-limitation ${confirmationPageLabel(
showListOnly,
)}`}
>
{limitContent.title}
</div>
<div>{limitContent.review[limitedConsent.length ? 'y' : 'n']}</div>
{!reviewMode && (
<div className="vads-u-margin-top--1p5">
Expand Down Expand Up @@ -355,7 +374,9 @@ export const UploadContent = ({
}) =>
list?.length ? (
<>
<div className="upload-title">{content.otherTitle}</div>
<div className={`upload-title ${confirmationPageLabel(showListOnly)}`}>
{content.otherTitle}
</div>
{/* eslint-disable-next-line jsx-a11y/no-redundant-roles */}
<ul className="evidence-summary remove-bullets" role="list">
{list.map((upload, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import {
} from '@department-of-veterans-affairs/platform-forms-system/ui';

import ConfirmationPageV2 from '../../components/ConfirmationPageV2';
import maxData from '../fixtures/data/maximal-test.json';
import maxData from '../fixtures/data/maximal-test-v2.json';
import { EVIDENCE_VA, EVIDENCE_PRIVATE, EVIDENCE_OTHER } from '../../constants';

const getData = (customData = {}) => ({
const getData = (customData = maxData.data) => ({
user: {
profile: {
userFullName: {
Expand All @@ -31,7 +32,6 @@ const getData = (customData = {}) => ({
response: new Date().toISOString(),
},
data: {
...maxData.data,
...customData,
},
},
Expand All @@ -50,7 +50,7 @@ describe('ConfirmationPageV2', () => {
expect($('va-alert[status="success"]', container)).to.exist;

const items = $$('.dd-privacy-hidden[data-dd-action-name]', container);
expect(items.length).to.eq(12);
expect(items.length).to.eq(7);
expect(
items.map(
(el, index) => el[[1, 2].includes(index) ? 'innerHTML' : 'textContent'],
Expand All @@ -61,11 +61,6 @@ describe('ConfirmationPageV2', () => {
'<va-telephone contact="" not-clickable="true"></va-telephone>',
'',
', ',
'Not selected',
'None selected',
'',
'',
'',
'No, I didn’t certify',
'None selected',
]);
Expand Down Expand Up @@ -105,15 +100,17 @@ describe('ConfirmationPageV2', () => {
'New and relevant evidence',
]);

const h4s = $$('h4', container);
expect(h4s.length).to.eq(3);
expect(h4s.map(el => el.textContent)).to.deep.equal([
expect($('.va-title', container).textContent).to.eq(
'We’re requesting records from these VA locations:',
);
expect($('.private-title', container).textContent).to.eq(
'We’re requesting records from these non-VA medical providers:',
);
expect($('.upload-title', container).textContent).to.eq(
'You uploaded these documents:',
]);
);

expect($$('ul', container).length).to.eq(8);
expect($$('ul', container).length).to.eq(7);

const items = $$('.dd-privacy-hidden[data-dd-action-name]', container);
expect(items.length).to.eq(30);
Expand All @@ -127,19 +124,19 @@ describe('ConfirmationPageV2', () => {
'<va-telephone contact="5558002222" extension="1234" not-clickable="true"></va-telephone>',
'[email protected]',
'123 Main StNew York, NY 30012',
'Not selected',
'None selected',
'',
'',
'',
'No',
'HeadachesDecision date: June 10, 2021',
'TinnitusDecision date: June 1, 2021',
'TestDecision date: January 1, 2022',
'Test 2Decision date: June 28, 2022',
'Yes, I certify',
'None selected',
'A VA Vet center, A community care provider that VA paid for, A VA medical center (also called a VAMC), A community-based outpatient clinic (also called a CBOC), A Department of Defense military treatment facility (also called an MTF), A non-VA healthcare provider, and Lorem ipsum',
'VAMC Location 1',
'Test and Test 2',
'Jan 1, 2001 – Jan 1, 2011',
'January 2001',
'VAMC Location 2',
'Test 2',
'Feb 2, 2002 – Feb 2, 2012',
'February 2001',
'Private Doctor',
'Test and Test 2',
'Jan 1, 2022 – Feb 1, 2022',
Expand All @@ -154,39 +151,72 @@ describe('ConfirmationPageV2', () => {
expect($$('.vads-c-action-link--green', container).length).to.eq(1);
});

it('should render the confirmation page with a hearing request', () => {
it('should render the confirmation page with no evidence', () => {
const data = getData({
boardReviewOption: 'hearing',
hearingTypePreference: 'central_office',
...maxData.data,
facilityTypes: {},
[EVIDENCE_VA]: false,
[EVIDENCE_PRIVATE]: false,
[EVIDENCE_OTHER]: false,
});
const { container } = render(
<Provider store={mockStore(data)}>
<ConfirmationPageV2 />
</Provider>,
);

const items = $$('.dd-privacy-hidden[data-dd-action-name]', container);
expect(items.length).to.eq(24);
expect(items.map(el => el.textContent).slice(-2)).to.deep.equal([
'Hearing',
'An in-person hearing at the Board in Washington, D.C.',
expect($('va-alert[status="success"]', container)).to.exist;
expect($('va-alert[status="success"]', container).innerHTML).to.contain(
`Thank you for filing a Supplemental Claim`,
);
// expect($('va-loading-indicator', container)).to.exist;
const h2s = $$('h2', container);
expect(h2s.length).to.eq(4);
expect(h2s.map(el => el.textContent)).to.deep.equal([
'File a Supplemental Claim', // print only header
'Thank you for filing a Supplemental Claim',
'What to expect next',
'Your Supplemental Claim request',
]);
});

it('should render the confirmation page with a direct review', () => {
const data = getData({
boardReviewOption: 'direct_review',
});
const { container } = render(
<Provider store={mockStore(data)}>
<ConfirmationPageV2 />
</Provider>,
const h3s = $$('h3', container);
expect(h3s.length).to.eq(6); // 7 with PDF download code added
expect(h3s.map(el => el.textContent)).to.deep.equal([
// 'Save a PDF copy of your Supplemental Claim request',
'Print this confirmation page',
'Personal information',
'Living situation',
'Issues for review',
'New and relevant evidence',
'Review the evidence you’re submitting',
]);

expect($('.no-evidence', container).textContent).to.eq(
'I didn’t add any evidence',
);

expect($$('ul', container).length).to.eq(4);

const items = $$('.dd-privacy-hidden[data-dd-action-name]', container);
expect(items.length).to.eq(14);
expect(items.map(el => el.textContent).slice(-1)).to.deep.equal([
'Direct review',
expect(
items.map((el, index) => el[index === 4 ? 'innerHTML' : 'textContent']),
).to.deep.equal([
'Michael Thomas Wazowski, Esq.',
'●●●–●●–8765V A file number ending with 8 7 6 5',
'February 3, 1990',
'',
'<va-telephone contact="5558002222" extension="1234" not-clickable="true"></va-telephone>',
'[email protected]',
'123 Main StNew York, NY 30012',
'No',
'HeadachesDecision date: June 10, 2021',
'TinnitusDecision date: June 1, 2021',
'TestDecision date: January 1, 2022',
'Test 2Decision date: June 28, 2022',
'Yes, I certify',
'None selected',
]);
expect($$('.vads-c-action-link--green', container).length).to.eq(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ describe('<EvidenceSummary>', () => {
const { container } = setupSummary({ limit: 'Pizza addiction' });

expect($$('h3', container).length).to.eq(1);
expect($$('h4', container).length).to.eq(4);
expect($$('h4', container).length).to.eq(1);
expect($$('.va-title, .private-title, .upload-title').length).to.eq(3);
expect($$('ul', container).length).to.eq(3);
expect($('a.vads-c-action-link--green', container)).to.exist;
expect($$('.form-nav-buttons button', container).length).to.eq(2);
Expand All @@ -139,7 +140,8 @@ describe('<EvidenceSummary>', () => {
});

expect($$('h3', container).length).to.eq(1);
expect($$('h4', container).length).to.eq(4);
expect($$('h4', container).length).to.eq(1);
expect($$('.va-title, .private-title, .upload-title').length).to.eq(3);
expect($$('ul', container).length).to.eq(3);
expect($$('.usa-input-error-message', container).length).to.eq(8);
expect($('a.vads-c-action-link--green', container)).to.exist;
Expand Down Expand Up @@ -410,8 +412,8 @@ describe('<EvidenceSummary>', () => {
const { container } = setupSummary({ onReviewPage: true });

expect($$('h4', container).length).to.eq(2);
// now includes limited consent
expect($$('h5', container).length).to.eq(3);
expect($$('.private-limitation', container).length).to.eq(1);
expect($$('.private-facility', container).length).to.eq(2);
expect($('a.vads-c-action-link--green', container)).to.exist;
expect($$('.form-nav-buttons button', container).length).to.eq(0);
expect(
Expand Down
Loading

0 comments on commit f190c39

Please sign in to comment.