Skip to content

Commit

Permalink
update code logic and add tests (#30847)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmclaren19 authored Jul 16, 2024
1 parent ce251b0 commit aa2a8c1
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Automated5103Notice({
return null;
}
return (
<div id="automated-5103-notice-page">
<div id="automated-5103-notice-page" className="vads-u-margin-bottom--3">
<h1 className="vads-u-margin-top--0 vads-u-margin-bottom--2">
5103 Evidence Notice
</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function DefaultPage({
uploading,
}) {
return (
<div id="default-page">
<div id="default-page" className="vads-u-margin-bottom--3">
<h1 className="claims-header">Request for {item.displayName}</h1>
{item.status === 'NEEDED_FROM_YOU' ? (
<DueDate date={item.suspenseDate} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {

export default function RecentActivity({ claim }) {
const { TOGGLE_NAMES, useToggleValue } = useFeatureToggle();
const cst5103UpdateEnabled = useToggleValue(
TOGGLE_NAMES.cst5103UpdateEnabled,
);
const cstClaimPhasesEnabled = useToggleValue(TOGGLE_NAMES.cstClaimPhases);
// When feature flag cstClaimPhases is enabled and claim type code is for a disability
// compensation claim we show 8 phases instead of 5 with updated description, link text
Expand Down Expand Up @@ -45,18 +48,29 @@ export default function RecentActivity({ claim }) {
}
};

const is5103Notice = item => {
return (
item.displayName === 'Automated 5103 Notice Response' ||
item.displayName === '5103 Notice Response'
);
};

const getTrackedItemDescription = item => {
const displayName =
is5103Notice(item) && cst5103UpdateEnabled
? '5103 Evidence Notice'
: item.displayName;
switch (item.status) {
case 'NEEDED_FROM_YOU':
case 'NEEDED_FROM_OTHERS':
return `We opened a request for "${item.displayName}"`;
return `We opened a request for "${displayName}"`;
case 'NO_LONGER_REQUIRED':
return `We closed a request for "${item.displayName}"`;
return `We closed a request for "${displayName}"`;
case 'SUBMITTED_AWAITING_REVIEW':
return `We received your document(s) for "${item.displayName}"`;
return `We received your document(s) for "${displayName}"`;
case 'INITIAL_REVIEW_COMPLETE':
case 'ACCEPTED':
return `We completed a review for "${item.displayName}"`;
return `We completed a review for "${displayName}"`;
default:
return 'There was an update to this item';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ import { $ } from '@department-of-veterans-affairs/platform-forms-system/ui';
import RecentActivity from '../../../components/claim-status-tab/RecentActivity';
import { renderWithRouter } from '../../utils';

const getStore = (cstClaimPhasesEnabled = false) =>
const getStore = (
cstClaimPhasesEnabled = false,
cst5103UpdateEnabled = false,
) =>
createStore(() => ({
featureToggles: {
// eslint-disable-next-line camelcase
cst_claim_phases: cstClaimPhasesEnabled,
// eslint-disable-next-line camelcase
cst_5103_update_enabled: cst5103UpdateEnabled,
},
}));

Expand Down Expand Up @@ -322,6 +327,59 @@ const openClaimStep4WithMultipleItems = {
},
};

const openClaimStep4WithAuto5103Notice = {
attributes: {
claimDate: '2024-05-02',
claimPhaseDates: {
phaseChangeDate: '2024-05-22',
currentPhaseBack: false,
latestPhaseType: 'REVIEW_OF_EVIDENCE',
previousPhases: {
phase1CompleteDate: '2024-05-10',
phase2CompleteDate: '2024-05-22',
phase3CompleteDate: '2024-06-07',
},
},
claimTypeCode: '110LCMP7IDES',
trackedItems: [
{
id: 1,
requestedDate: '2024-05-12',
status: 'NEEDED_FROM_YOU',
suspenseDate: '2024-08-07',
displayName: 'Automated 5103 Notice Response',
},
],
},
};

const openClaimStep4WithClosed5103Notice = {
attributes: {
claimDate: '2024-05-02',
claimPhaseDates: {
phaseChangeDate: '2024-05-22',
currentPhaseBack: false,
latestPhaseType: 'REVIEW_OF_EVIDENCE',
previousPhases: {
phase1CompleteDate: '2024-05-10',
phase2CompleteDate: '2024-05-22',
phase3CompleteDate: '2024-06-07',
},
},
claimTypeCode: '110LCMP7IDES',
trackedItems: [
{
id: 1,
requestedDate: '2024-05-12',
status: 'NO_LONGER_REQUIRED',
suspenseDate: '2024-08-07',
displayName: '5103 Notice Response',
closedDate: '2024-06-12',
},
],
},
};

describe('<RecentActivity>', () => {
context('when cstClaimPhasesEnabled enabled', () => {
context('when claim doesn’t have trackedItems', () => {
Expand Down Expand Up @@ -553,6 +611,106 @@ describe('<RecentActivity>', () => {
expect(pagination).to.exist;
expect(pagination.pages).to.equal(2);
});
context(
'when cst5103UpdateEnabled and has an Automated 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore(true, true)}>
<RecentActivity claim={openClaimStep4WithAuto5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(5);
getByText('We received your claim in our system');
getByText('Your claim moved into Step 2: Initial review');
getByText('Your claim moved into Step 3: Evidence gathering');
getByText('Your claim moved into Step 4: Evidence review');
getByText('Request for you');
getByText('We opened a request for "5103 Evidence Notice"');
expect($('va-pagination', container)).not.to.exist;
});
},
);
context(
'when cst5103UpdateEnabled disabled and has an Automated 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore(true, false)}>
<RecentActivity claim={openClaimStep4WithAuto5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(5);
getByText('We received your claim in our system');
getByText('Your claim moved into Step 2: Initial review');
getByText('Your claim moved into Step 3: Evidence gathering');
getByText('Your claim moved into Step 4: Evidence review');
getByText('Request for you');
getByText(
'We opened a request for "Automated 5103 Notice Response"',
);
expect($('va-pagination', container)).not.to.exist;
});
},
);
context(
'when cst5103UpdateEnabled and has a closed 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore(true, true)}>
<RecentActivity claim={openClaimStep4WithClosed5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(5);
getByText('We received your claim in our system');
getByText('Your claim moved into Step 2: Initial review');
getByText('Your claim moved into Step 3: Evidence gathering');
getByText('Your claim moved into Step 4: Evidence review');
getByText('We closed a request for "5103 Evidence Notice"');
expect($('va-pagination', container)).not.to.exist;
});
},
);
context(
'when cst5103UpdateEnabled disabled and has a closed 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore(true, false)}>
<RecentActivity claim={openClaimStep4WithClosed5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(5);
getByText('We received your claim in our system');
getByText('Your claim moved into Step 2: Initial review');
getByText('Your claim moved into Step 3: Evidence gathering');
getByText('Your claim moved into Step 4: Evidence review');
getByText('We closed a request for "5103 Notice Response"');
expect($('va-pagination', container)).not.to.exist;
});
},
);
});
});
});
Expand Down Expand Up @@ -802,6 +960,110 @@ describe('<RecentActivity>', () => {
expect(pagination).to.exist;
expect(pagination.pages).to.equal(2);
});
context(
'when cst5103UpdateEnabled and has an Automated 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore(false, true)}>
<RecentActivity claim={openClaimStep4WithAuto5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(4);
getByText('Your claim moved into Step 1: Claim received');
getByText('Your claim moved into Step 2: Initial review');
getByText(
'Your claim moved into Step 3: Evidence gathering, review, and decision',
);
getByText('Request for you');
getByText('We opened a request for "5103 Evidence Notice"');
expect($('va-pagination', container)).not.to.exist;
});
},
);
context(
'when cst5103UpdateEnabled and has an Automated 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore()}>
<RecentActivity claim={openClaimStep4WithAuto5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(4);
getByText('Your claim moved into Step 1: Claim received');
getByText('Your claim moved into Step 2: Initial review');
getByText(
'Your claim moved into Step 3: Evidence gathering, review, and decision',
);
getByText('Request for you');
getByText(
'We opened a request for "Automated 5103 Notice Response"',
);
expect($('va-pagination', container)).not.to.exist;
});
},
);
context(
'when cst5103UpdateEnabled and has an Automated 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore(false, true)}>
<RecentActivity claim={openClaimStep4WithClosed5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(4);
getByText('Your claim moved into Step 1: Claim received');
getByText('Your claim moved into Step 2: Initial review');
getByText(
'Your claim moved into Step 3: Evidence gathering, review, and decision',
);
getByText('We closed a request for "5103 Evidence Notice"');
expect($('va-pagination', container)).not.to.exist;
});
},
);
context(
'when cst5103UpdateEnabled and has an Automated 5103 Notice Response item',
() => {
it('should render list', () => {
const { container, getByText } = renderWithRouter(
<Provider store={getStore()}>
<RecentActivity claim={openClaimStep4WithClosed5103Notice} />
</Provider>,
);

const recentActivityList = $('ol', container);
expect(recentActivityList).to.exist;
expect(
within(recentActivityList).getAllByRole('listitem').length,
).to.equal(4);
getByText('Your claim moved into Step 1: Claim received');
getByText('Your claim moved into Step 2: Initial review');
getByText(
'Your claim moved into Step 3: Evidence gathering, review, and decision',
);
getByText('We closed a request for "5103 Notice Response"');
expect($('va-pagination', container)).not.to.exist;
});
},
);
});
});
});
Expand Down

0 comments on commit aa2a8c1

Please sign in to comment.