Skip to content

Commit

Permalink
[CST] Remove EVSS code from DocumentRequestPage component (#28351)
Browse files Browse the repository at this point in the history
* Removing EVSS code from the `DocumentRequestPage` component

* Updating e2e tests to work with Lighthouse version of claim details instead of EVSS
  • Loading branch information
jerekshoe authored and Peter Hill committed Mar 14, 2024
1 parent eb10fbd commit 7742edf
Show file tree
Hide file tree
Showing 17 changed files with 510 additions and 246 deletions.

This file was deleted.

47 changes: 9 additions & 38 deletions src/applications/claims-status/containers/DocumentRequestPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import PropTypes from 'prop-types';
import scrollTo from '@department-of-veterans-affairs/platform-utilities/scrollTo';
import scrollToTop from '@department-of-veterans-affairs/platform-utilities/scrollToTop';

import DocumentRequestPageContent from '../components/evss/DocumentRequestPageContent';
import AddFilesFormOld from '../components/AddFilesFormOld';
import AskVAQuestions from '../components/AskVAQuestions';
import ClaimsBreadcrumbs from '../components/ClaimsBreadcrumbs';
Expand All @@ -26,15 +25,14 @@ import {
cancelUpload,
// START lighthouse_migration
getClaim as getClaimAction,
getClaimDetail as getClaimEVSSAction,
// END lighthouse_migration
setFieldsDirty,
clearNotification,
} from '../actions';
import { scrubDescription } from '../utils/helpers';
import { setPageFocus, setUpPage } from '../utils/page';
// START lighthouse_migration
import { cstUseLighthouse, benefitsDocumentsUseLighthouse } from '../selectors';
import { benefitsDocumentsUseLighthouse } from '../selectors';
// END lighthouse_migration

const scrollToError = () => {
Expand Down Expand Up @@ -85,10 +83,7 @@ class DocumentRequestPage extends React.Component {
}

getPageContent() {
const { trackedItem, useLighthouse } = this.props;
if (!useLighthouse) {
return <DocumentRequestPageContent trackedItem={trackedItem} />;
}
const { trackedItem } = this.props;

return (
<>
Expand All @@ -110,13 +105,7 @@ class DocumentRequestPage extends React.Component {
}

goToFilesPage() {
// START lighthouse_migration
if (this.props.useLighthouse) {
this.props.getClaimLighthouse(this.props.claim.id);
} else {
this.props.getClaimEVSS(this.props.claim.id);
}
// END lighthouse_migration
this.props.getClaim(this.props.claim.id);
this.props.router.push(`your-claims/${this.props.claim.id}/files`);
}

Expand Down Expand Up @@ -223,24 +212,14 @@ class DocumentRequestPage extends React.Component {
function mapStateToProps(state, ownProps) {
const claimsState = state.disability.status;
const { claimDetail, uploads } = claimsState;
const useLighthouse = cstUseLighthouse(state, 'show');

let trackedItems = [];
let trackedItem = null;
if (claimDetail.detail) {
const { attributes } = claimDetail.detail;
const { trackedItems } = claimDetail.detail.attributes;
const { trackedItemId } = ownProps.params;
if (useLighthouse) {
trackedItems = attributes.trackedItems;
[trackedItem] = trackedItems.filter(
event => event.id === parseInt(trackedItemId, 10),
);
} else {
trackedItems = attributes.eventsTimeline;
[trackedItem] = trackedItems.filter(
event => event.trackedItemId === parseInt(trackedItemId, 10),
);
}
[trackedItem] = trackedItems.filter(
item => item.id === parseInt(trackedItemId, 10),
);
}

return {
Expand All @@ -256,7 +235,6 @@ function mapStateToProps(state, ownProps) {
lastPage: claimsState.routing.lastPage,
message: claimsState.notifications.message,
// START lighthouse_migration
useLighthouse,
documentsUseLighthouse: benefitsDocumentsUseLighthouse(state),
// END lighthouse_migration
};
Expand All @@ -268,9 +246,8 @@ const mapDispatchToProps = {
submitFiles,
updateField,
cancelUpload,
getClaim: getClaimAction,
// START lighthouse_migration
getClaimEVSS: getClaimEVSSAction,
getClaimLighthouse: getClaimAction,
submitFilesLighthouse,
// END lighthouse_migration
setFieldsDirty,
Expand All @@ -294,10 +271,7 @@ DocumentRequestPage.propTypes = {
documentsUseLighthouse: PropTypes.bool,
// END lighthouse_migration
files: PropTypes.array,
// START lighthouse_migration
getClaimEVSS: PropTypes.func,
getClaimLighthouse: PropTypes.func,
// END lighthouse_migration
getClaim: PropTypes.func,
lastPage: PropTypes.string,
loading: PropTypes.bool,
message: PropTypes.object,
Expand All @@ -314,9 +288,6 @@ DocumentRequestPage.propTypes = {
updateField: PropTypes.func,
uploadComplete: PropTypes.bool,
uploading: PropTypes.bool,
// START lighthouse_migration
useLighthouse: PropTypes.bool,
// END lighthouse_migration
};

export { DocumentRequestPage };
12 changes: 12 additions & 0 deletions src/applications/claims-status/sass/claims-status.scss
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,18 @@ h1:focus {
padding-left: 1em;
}

.submitted-file-list-item:nth-child(1) {
background-color: $color-red;
}

.submitted-file-list-item:nth-child(4) {
background-color: $color-gold;
}

.submitted-file-list-item:nth-child(6) {
background-color: $color-blue;
}

// Slimmed version of .claim-timeline with appeals-specific stuff
// To be used in conjunction with .process .form-process
.appeal-timeline {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { expect } from 'chai';
import sinon from 'sinon';
import ReactTestUtils from 'react-dom/test-utils';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import { render } from '@testing-library/react';

import { uploadStore } from 'platform/forms-system/test/config/helpers';

import { DocumentRequestPage } from '../../containers/DocumentRequestPage';

const claim = {
Expand All @@ -17,10 +16,6 @@ const claim = {

const params = { id: 1 };

const store = createStore(() => ({
featureToggles: {},
}));

const getRouter = () => ({
push: sinon.spy(),
replace: sinon.spy(),
Expand All @@ -37,7 +32,7 @@ describe('<DocumentRequestPage>', () => {

it('should render upload error alert', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
};
const message = {
title: 'Test',
Expand All @@ -57,7 +52,7 @@ describe('<DocumentRequestPage>', () => {

it('should clear upload error when leaving', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
};
const message = {
title: 'test',
Expand All @@ -82,7 +77,7 @@ describe('<DocumentRequestPage>', () => {

it('should not clear notification after completed upload', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
};
const message = {
title: 'test',
Expand All @@ -108,7 +103,7 @@ describe('<DocumentRequestPage>', () => {

it('should render due date info', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
suspenseDate: '2010-05-10',
};

Expand All @@ -119,32 +114,33 @@ describe('<DocumentRequestPage>', () => {
trackedItem={trackedItem}
/>,
);
const content = tree.dive(['DocumentRequestPageContent']);
expect(content.subTree('DueDateOld')).not.to.be.false;
expect(content.subTree('DueDateOld').props.date).to.eql(

expect(tree.subTree('DueDateOld')).not.to.be.false;
expect(tree.subTree('DueDateOld').props.date).to.eql(
trackedItem.suspenseDate,
);
});

it('should render optional upload alert', () => {
const trackedItem = {
type: 'still_need_from_others_list',
status: 'NEEDED_FROM_OTHERS',
suspenseDate: '2010-05-10',
};

const tree = SkinDeep.shallowRender(
<DocumentRequestPage
params={params}
claim={claim}
trackedItem={trackedItem}
/>,
);
const content = tree.dive(['DocumentRequestPageContent']);
expect(content.subTree('.optional-upload')).not.to.be.false;

expect(tree.subTree('.optional-upload')).not.to.be.false;
});

it('should handle submit files', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
suspenseDate: '2010-05-10',
};
const onSubmit = sinon.spy();
Expand All @@ -162,7 +158,7 @@ describe('<DocumentRequestPage>', () => {

it('should reset uploads and set title on mount', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
displayName: 'Testing',
};
const resetUploads = sinon.spy();
Expand All @@ -188,14 +184,14 @@ describe('<DocumentRequestPage>', () => {

it('should set details and go to files page if complete', () => {
const trackedItem = {
type: 'still_need_from_you_list',
status: 'NEEDED_FROM_YOU',
displayName: 'Testing',
};
const router = getRouter();
const parameters = {
id: 339,
};
const getClaimEVSS = sinon.spy();
const getClaim = sinon.spy();
const resetUploads = sinon.spy();

const tree = SkinDeep.shallowRender(
Expand All @@ -207,79 +203,15 @@ describe('<DocumentRequestPage>', () => {
trackedItem={trackedItem}
router={router}
params={parameters}
getClaimEVSS={getClaimEVSS}
getClaim={getClaim}
resetUploads={resetUploads}
/>,
);

tree
.getMountedInstance()
.UNSAFE_componentWillReceiveProps({ uploadComplete: true });
expect(getClaimEVSS.calledWith(1)).to.be.true;
expect(getClaim.calledWith(1)).to.be.true;
expect(router.push.calledWith('your-claims/1/files')).to.be.true;
});

// START lighthouse_migration
context('cst_use_lighthouse feature toggle', () => {
const trackedItem = {
type: 'still_need_from_you_list',
displayName: 'Testing',
};

const props = {
claim,
clearNotification: () => {},
files: [],
params,
resetUploads: () => {},
router: getRouter(),
trackedItem,
uploadField: { value: null, dirty: false },
};

it('calls getClaimLighthouse when enabled', () => {
// Reset sinon spies / set up props
props.getClaimEVSS = sinon.spy();
props.getClaimLighthouse = sinon.spy();
props.useLighthouse = true;

const { rerender } = render(
<Provider store={store}>
<DocumentRequestPage {...props} />
</Provider>,
);

rerender(
<Provider store={store}>
<DocumentRequestPage {...props} uploadComplete />
</Provider>,
);

expect(props.getClaimEVSS.called).to.be.false;
expect(props.getClaimLighthouse.called).to.be.true;
});

it('calls getClaimEVSS when disabled', () => {
// Reset sinon spies / set up props
props.getClaimEVSS = sinon.spy();
props.getClaimLighthouse = sinon.spy();
props.useLighthouse = false;

const { rerender } = render(
<Provider store={store}>
<DocumentRequestPage {...props} />
</Provider>,
);

rerender(
<Provider store={store}>
<DocumentRequestPage {...props} uploadComplete />
</Provider>,
);

expect(props.getClaimEVSS.called).to.be.true;
expect(props.getClaimLighthouse.called).to.be.false;
});
});
// END lighthouse_migration
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import TrackClaimsPage from './page-objects/TrackClaimsPage';
import claimsList from './fixtures/mocks/lighthouse/claims-list.json';
import claimDetail from './fixtures/mocks/lighthouse/claim-detail.json';

describe('Claims List Test', () => {
it('Tests consolidated claim functionality - C30698', () => {
const trackClaimsPage = new TrackClaimsPage();
trackClaimsPage.loadPage(claimsList);
trackClaimsPage.loadPage(claimsList, claimDetail);
cy.expandAccordions();
cy.axeCheck();
trackClaimsPage.checkClaimsContent();
Expand Down

0 comments on commit 7742edf

Please sign in to comment.