From 8ea934f25f9e521b641354393f8eb02d6371beed Mon Sep 17 00:00:00 2001 From: William Bagayoko Date: Mon, 18 Mar 2019 16:12:13 -0500 Subject: [PATCH] 1140: Case Info Tab - Document Detail Tab Display * setDefaultDocumentDetailTabAction uses the helper to set the default tab --- .../computeds/documentDetailHelper.js | 17 +++-- .../computeds/documentDetailHelper.test.js | 65 +++++++++++++++++++ web-client/src/views/DocumentDetail.jsx | 12 ++-- 3 files changed, 82 insertions(+), 12 deletions(-) diff --git a/web-client/src/presenter/computeds/documentDetailHelper.js b/web-client/src/presenter/computeds/documentDetailHelper.js index d1816cec9cd..18533d2f890 100644 --- a/web-client/src/presenter/computeds/documentDetailHelper.js +++ b/web-client/src/presenter/computeds/documentDetailHelper.js @@ -26,18 +26,21 @@ export default get => { .map(items => formatWorkItem(items)); } + const formattedDocumentIsPetition = + (formattedDocument && formattedDocument.isPetition) || false; + const showCaseDetailsEdit = ['New', 'Recalled'].includes(caseDetail.status); + const showCaseDetailsView = ['Batched for IRS'].includes(caseDetail.status); + const showDocumentInfoTab = + formattedDocumentIsPetition && (showCaseDetailsEdit || showCaseDetailsView); + return { formattedDocument, showAction: (action, workItemId) => { const actions = get(state.workItemActions); return actions[workItemId] === action; }, - showCaseDetailsEdit: ['New', 'Recalled'].includes(caseDetail.status), - showCaseDetailsView: ['Batched for IRS'].includes(caseDetail.status), - showDocumentInfo: get(state.currentTab) === 'Document Info', - showDocumentInfoTab: formattedDocument - ? formattedDocument.isPetition - : false, - showPendingMessages: get(state.currentTab) === 'Pending Messages', + showCaseDetailsEdit, + showCaseDetailsView, + showDocumentInfoTab, }; }; diff --git a/web-client/src/presenter/computeds/documentDetailHelper.test.js b/web-client/src/presenter/computeds/documentDetailHelper.test.js index 2666342799e..1b16a4b1e48 100644 --- a/web-client/src/presenter/computeds/documentDetailHelper.test.js +++ b/web-client/src/presenter/computeds/documentDetailHelper.test.js @@ -66,4 +66,69 @@ describe('formatted work queue computed', () => { }); expect(result.showCaseDetailsEdit).toEqual(true); }); + + describe('showDocumentInfoTab', () => { + it('should be false if document is not a petition', () => { + const result = runCompute(documentDetailHelper, { + state: { + caseDetail: { + documents: [ + { + documentId: 'abc', + documentType: 'NotAPetition', + }, + ], + status: 'Recalled', + }, + documentId: 'abc', + workItemActions: { + abc: 'complete', + }, + }, + }); + expect(result.showDocumentInfoTab).toEqual(false); + }); + + it('should be true if document is a petition and status is New, Recalled, or Batched for IRS', () => { + const result = runCompute(documentDetailHelper, { + state: { + caseDetail: { + documents: [ + { + documentId: 'abc', + documentType: 'Petition', + }, + ], + status: 'Recalled', + }, + documentId: 'abc', + workItemActions: { + abc: 'complete', + }, + }, + }); + expect(result.showDocumentInfoTab).toEqual(true); + }); + + it('should be false if document is a petition and status is not New, Recalled, or Batched for IRS', () => { + const result = runCompute(documentDetailHelper, { + state: { + caseDetail: { + documents: [ + { + documentId: 'abc', + documentType: 'Petition', + }, + ], + status: 'General', + }, + documentId: 'abc', + workItemActions: { + abc: 'complete', + }, + }, + }); + expect(result.showDocumentInfoTab).toEqual(false); + }); + }); }); diff --git a/web-client/src/views/DocumentDetail.jsx b/web-client/src/views/DocumentDetail.jsx index aa0caedcc7d..817973beed4 100644 --- a/web-client/src/views/DocumentDetail.jsx +++ b/web-client/src/views/DocumentDetail.jsx @@ -86,11 +86,13 @@ class DocumentDetailComponent extends React.Component { - + {helper.showDocumentInfoTab && ( + + )}