From 5a1401861a0f94139463dfd7e9e5be0e5a7d5701 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 28 Jul 2023 07:19:34 -0700 Subject: [PATCH 01/14] 10076: Refactor calculating if document meets visibility policy change requirements into its own function --- .../Public/publicCaseDetailHelper.ts | 82 ++++++++++--------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 5d1ad6496f4..20a11b78d93 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -16,6 +16,45 @@ import { Get } from 'cerebral'; import { cloneDeep } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; +const getMeetsPolicyChangeRequirements = ( + entry: RawDocketEntry & { rootDocument: RawDocketEntry }, + visibilityPolicyDateFormatted: string, + docketEntriesEFiledByPractitioner: string[], +) => { + const filedByPractitioner = docketEntriesEFiledByPractitioner.includes( + entry.docketEntryId, + ); + + const isAmendment = ['AMAT', 'ADMT', 'REDC', 'SPML', 'SUPM'].includes( + entry.eventCode, + ); + const filedAfterPolicyChange = + entry.filingDate >= visibilityPolicyDateFormatted; + + if (!POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { + return false; + } + + if (isAmendment) { + const originalDocType = entry.rootDocument.documentType; + + if (isDocumentBriefType(originalDocType)) { + return filedAfterPolicyChange && filedByPractitioner; + } + if (originalDocType === 'Amicus Brief') { + return filedAfterPolicyChange; + } + return false; + } + + const isDocketEntryBrief = BRIEF_EVENTCODES.includes(entry.eventCode); + + if (isDocketEntryBrief) { + return filedAfterPolicyChange && filedByPractitioner; + } + return filedAfterPolicyChange; +}; + export const fetchRootDocument = ( entry: RawDocketEntry, docketEntries: RawDocketEntry[], @@ -50,46 +89,11 @@ export const formatDocketEntryOnDocketRecord = ( const isServedDocument = !record.isNotServedDocument; - let filedByPractitioner = false; - let meetsPolicyChangeRequirements = false; - const isAmendment = ['AMAT', 'ADMT', 'REDC', 'SPML', 'SUPM'].includes( - entry.eventCode, + const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( + entry, + visibilityPolicyDateFormatted, + docketEntriesEFiledByPractitioner, ); - const filedAfterPolicyChange = - record.filingDate >= visibilityPolicyDateFormatted; - - if (POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { - let isDocketEntryBriefEventCode; - const docType = entry.rootDocument.documentType; - - if (isAmendment) { - isDocketEntryBriefEventCode = isDocumentBriefType(docType); - - if (isDocketEntryBriefEventCode) { - filedByPractitioner = docketEntriesEFiledByPractitioner.includes( - entry.docketEntryId, - ); - meetsPolicyChangeRequirements = - filedAfterPolicyChange && filedByPractitioner; - } else if (docType === 'Amicus Brief') { - meetsPolicyChangeRequirements = filedAfterPolicyChange; - } else { - meetsPolicyChangeRequirements = false; - } - } else { - isDocketEntryBriefEventCode = BRIEF_EVENTCODES.includes(entry.eventCode); - - if (isDocketEntryBriefEventCode) { - filedByPractitioner = docketEntriesEFiledByPractitioner.includes( - entry.docketEntryId, - ); - meetsPolicyChangeRequirements = - filedAfterPolicyChange && filedByPractitioner; - } else { - meetsPolicyChangeRequirements = filedAfterPolicyChange; - } - } - } let canTerminalUserSeeLink = record.isFileAttached && From bb1d90b758be4324ea02b35f0d54ba620f98289b Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 28 Jul 2023 08:41:38 -0700 Subject: [PATCH 02/14] 10076: Refactoring format public docket entries for readability --- .../Public/publicCaseDetailHelper.ts | 104 ++++++++---------- 1 file changed, 43 insertions(+), 61 deletions(-) diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 20a11b78d93..51c6142e51c 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -1,5 +1,4 @@ /* eslint-disable complexity */ - import { ALLOWLIST_FEATURE_FLAGS, BRIEF_EVENTCODES, @@ -13,7 +12,6 @@ import { } from '../../../../../shared/src/business/entities/EntityConstants'; import { ClientApplicationContext } from '@web-client/applicationContext'; import { Get } from 'cerebral'; -import { cloneDeep } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; const getMeetsPolicyChangeRequirements = ( @@ -21,6 +19,10 @@ const getMeetsPolicyChangeRequirements = ( visibilityPolicyDateFormatted: string, docketEntriesEFiledByPractitioner: string[], ) => { + if (!POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { + return false; + } + const filedByPractitioner = docketEntriesEFiledByPractitioner.includes( entry.docketEntryId, ); @@ -31,10 +33,6 @@ const getMeetsPolicyChangeRequirements = ( const filedAfterPolicyChange = entry.filingDate >= visibilityPolicyDateFormatted; - if (!POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { - return false; - } - if (isAmendment) { const originalDocType = entry.rootDocument.documentType; @@ -85,9 +83,7 @@ export const formatDocketEntryOnDocketRecord = ( visibilityPolicyDateFormatted: string; // ISO Date String }, ) => { - const record = cloneDeep(entry); - - const isServedDocument = !record.isNotServedDocument; + const isServed = !entry.isNotServedDocument; const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( entry, @@ -95,69 +91,55 @@ export const formatDocketEntryOnDocketRecord = ( docketEntriesEFiledByPractitioner, ); - let canTerminalUserSeeLink = - record.isFileAttached && - isServedDocument && - !record.isSealed && - !record.isStricken; + const canTerminalUserSeeLink = + entry.isFileAttached && isServed && !entry.isSealed && !entry.isStricken; - let canPublicUserSeeLink = - ((record.isCourtIssuedDocument && !record.isStipDecision) || + const canPublicUserSeeLink = + ((entry.isCourtIssuedDocument && !entry.isStipDecision) || meetsPolicyChangeRequirements) && - record.isFileAttached && - isServedDocument && - !record.isStricken && - !record.isTranscript && - !record.isSealed && - EVENT_CODES_VISIBLE_TO_PUBLIC.includes(record.eventCode); - - const canDisplayDocumentLink = isTerminalUser + entry.isFileAttached && + isServed && + !entry.isStricken && + !entry.isTranscript && + !entry.isSealed && + EVENT_CODES_VISIBLE_TO_PUBLIC.includes(entry.eventCode) && + entry.processingStatus === DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE; + + const showLinkToDocument = isTerminalUser ? canTerminalUserSeeLink : canPublicUserSeeLink; - const showDocumentDescriptionWithoutLink = !canDisplayDocumentLink; - - let showLinkToDocument = canDisplayDocumentLink; - - if (!isTerminalUser) { - showLinkToDocument = - canDisplayDocumentLink && - record.processingStatus === DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE; - } - - if (record.isSealed) { - record.sealedToTooltip = applicationContext + if (entry.isSealed) { + entry.sealedToTooltip = applicationContext .getUtilities() - .getSealedDocketEntryTooltip(applicationContext, record); + .getSealedDocketEntryTooltip(applicationContext, entry); } - record.descriptionDisplay = applicationContext - .getUtilities() - .getDescriptionDisplay(record); - return { - action: record.action, - createdAtFormatted: record.createdAtFormatted, - description: record.description, - descriptionDisplay: record.descriptionDisplay, - docketEntryId: record.docketEntryId, - eventCode: record.eventCode, - filedBy: record.filedBy, - hasDocument: !record.isMinuteEntry, - index: record.index, - isPaper: record.isPaper, - isSealed: record.isSealed, - isStricken: record.isStricken, - numberOfPages: record.numberOfPages || 0, + action: entry.action, + createdAtFormatted: entry.createdAtFormatted, + description: entry.description, + descriptionDisplay: applicationContext + .getUtilities() + .getDescriptionDisplay(entry), + docketEntryId: entry.docketEntryId, + eventCode: entry.eventCode, + filedBy: entry.filedBy, + hasDocument: !entry.isMinuteEntry, + index: entry.index, + isPaper: entry.isPaper, + isSealed: entry.isSealed, + isStricken: entry.isStricken, + numberOfPages: entry.numberOfPages || 0, openInSameTab: !isTerminalUser, - sealedToTooltip: record.sealedToTooltip, - servedAtFormatted: record.servedAtFormatted, - servedPartiesCode: record.servedPartiesCode, - showDocumentDescriptionWithoutLink, + sealedToTooltip: entry.sealedToTooltip, + servedAtFormatted: entry.servedAtFormatted, + servedPartiesCode: entry.servedPartiesCode, + showDocumentDescriptionWithoutLink: !showLinkToDocument, showLinkToDocument, - showNotServed: record.isNotServedDocument, - showServed: record.isStatusServed, - signatory: record.signatory, + showNotServed: entry.isNotServedDocument, + showServed: entry.isStatusServed, + signatory: entry.signatory, }; }; From a0fbd81e6bc0931f4a4d154ccb95799bad404375 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 28 Jul 2023 08:59:52 -0700 Subject: [PATCH 03/14] 10076: Call new method for determining visibility, DRYing up code --- shared/src/test/mockCase.ts | 1 + .../Public/publicCaseDetailHelper.ts | 2 +- .../computeds/formattedDocketEntries.ts | 61 +++---------------- 3 files changed, 12 insertions(+), 52 deletions(-) diff --git a/shared/src/test/mockCase.ts b/shared/src/test/mockCase.ts index 5a7846c4b0d..972ad467631 100644 --- a/shared/src/test/mockCase.ts +++ b/shared/src/test/mockCase.ts @@ -16,6 +16,7 @@ export const MOCK_CASE: RawCase = { correspondence: [], createdAt: '2018-03-01T21:40:46.415Z', docketEntries: MOCK_DOCUMENTS, + docketEntriesEFiledByPractitioner: [], docketNumber: '101-18', docketNumberWithSuffix: '101-18', entityName: 'Case', diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 51c6142e51c..aba7144426c 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -14,7 +14,7 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { Get } from 'cerebral'; import { state } from '@web-client/presenter/app.cerebral'; -const getMeetsPolicyChangeRequirements = ( +export const getMeetsPolicyChangeRequirements = ( entry: RawDocketEntry & { rootDocument: RawDocketEntry }, visibilityPolicyDateFormatted: string, docketEntriesEFiledByPractitioner: string[], diff --git a/web-client/src/presenter/computeds/formattedDocketEntries.ts b/web-client/src/presenter/computeds/formattedDocketEntries.ts index f9df31fe9b9..7fd8ed2a0c6 100644 --- a/web-client/src/presenter/computeds/formattedDocketEntries.ts +++ b/web-client/src/presenter/computeds/formattedDocketEntries.ts @@ -2,12 +2,11 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { DocketEntry } from '../../../../shared/src/business/entities/DocketEntry'; import { Get } from 'cerebral'; -import { - POLICY_DATE_IMPACTED_EVENTCODES, - isDocumentBriefType, -} from '../../../../shared/src/business/entities/EntityConstants'; import { documentMeetsAgeRequirements } from '../../../../shared/src/business/utilities/getFormattedCaseDetail'; -import { fetchRootDocument } from './Public/publicCaseDetailHelper'; +import { + fetchRootDocument, + getMeetsPolicyChangeRequirements, +} from './Public/publicCaseDetailHelper'; import { state } from '@web-client/presenter/app.cerebral'; export const setupIconsToDisplay = ({ formattedResult, isExternalUser }) => { @@ -141,14 +140,13 @@ export const getFormattedDocketEntry = ({ applicationContext, docketNumber, entry, - filedAfterPolicyChange, formattedCase, isExternalUser, permissions, userAssociatedWithCase, + visibilityPolicyDateFormatted, }) => { const { - BRIEF_EVENTCODES, DOCKET_ENTRY_SEALED_TO_TYPES, DOCUMENT_PROCESSING_STATUS_OPTIONS, EVENT_CODES_VISIBLE_TO_PUBLIC, @@ -200,48 +198,12 @@ export const getFormattedDocketEntry = ({ .map(k => INITIAL_DOCUMENT_TYPES[k].documentType) .includes(entry.documentType); - let filedByPractitioner = false; - let meetsPolicyChangeRequirements = false; - - const isAmendment = ['AMAT', 'ADMT', 'REDC', 'SPML', 'SUPM'].includes( - entry.eventCode, + const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( + entry, + visibilityPolicyDateFormatted, + formattedCase.docketEntriesEFiledByPractitioner, ); - if (POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { - let isDocketEntryBriefEventCode; - const docType = entry.rootDocument.documentType; - - if (isAmendment) { - isDocketEntryBriefEventCode = isDocumentBriefType(docType); - - if (isDocketEntryBriefEventCode) { - filedByPractitioner = - formattedCase.docketEntriesEFiledByPractitioner.includes( - entry.docketEntryId, - ); - meetsPolicyChangeRequirements = - filedAfterPolicyChange && filedByPractitioner; - } else if (docType === 'Amicus Brief') { - meetsPolicyChangeRequirements = filedAfterPolicyChange; - } else { - meetsPolicyChangeRequirements = false; - } - } else { - isDocketEntryBriefEventCode = BRIEF_EVENTCODES.includes(entry.eventCode); - - if (isDocketEntryBriefEventCode) { - filedByPractitioner = - formattedCase.docketEntriesEFiledByPractitioner.includes( - entry.docketEntryId, - ); - meetsPolicyChangeRequirements = - filedAfterPolicyChange && filedByPractitioner; - } else { - meetsPolicyChangeRequirements = filedAfterPolicyChange; - } - } - } - showDocumentLinks = getShowDocumentViewerLink({ hasDocument: entry.isFileAttached, isCourtIssuedDocument: entry.isCourtIssuedDocument, @@ -374,18 +336,15 @@ export const formattedDocketEntries = ( return { ...entry, rootDocument: fetchRootDocument(entry, array) }; }) .map(entry => { - const filedAfterPolicyChange = - entry.filingDate >= visibilityPolicyDateFormatted; - return getFormattedDocketEntry({ applicationContext, docketNumber, entry, - filedAfterPolicyChange, formattedCase: result, isExternalUser, permissions, userAssociatedWithCase, + visibilityPolicyDateFormatted, }); }); From da23f1457e937446e8c38e2f08de9bcfe317677b Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 28 Jul 2023 08:59:52 -0700 Subject: [PATCH 04/14] 10076: Call new method for determining visibility, DRYing up code --- .../DocketEntry.generateFiledBy.test.ts | 2 +- shared/src/business/entities/DocketEntry.ts | 16 + .../src/business/entities/EntityConstants.ts | 4 + .../cases/Case.archiveDocketEntry.test.ts | 2 +- .../cases/Case.deleteDocketEntryById.test.ts | 2 +- .../Case.getAttachmentDocumentById.test.ts | 2 +- .../cases/Case.getDocketEntryById.test.ts | 2 +- .../src/business/entities/cases/Case.test.ts | 2 +- .../cases/Case.updateDocketEntry.test.ts | 2 +- .../updateCaseAutomaticBlock.test.ts | 2 +- .../createCaseAndAssociations.test.ts | 2 +- .../updateCaseAndAssociations.test.ts | 2 +- .../fileAndServeDocumentOnOneCase.test.ts | 2 +- .../updateInitialFilingDocuments.test.ts | 2 +- ...aftStampOrderDocketEntryInteractor.test.ts | 2 +- ...cumentInteractor.consolidatedCases.test.ts | 2 +- ...cumentInteractor.consolidatedCases.test.ts | 2 +- ...serveCourtIssuedDocumentInteractor.test.ts | 2 +- .../saveSignedDocumentInteractor.test.ts | 2 +- ...ploadDocumentAndMakeSafeInteractor.test.ts | 2 +- .../verifyUserPendingEmailInteractor.test.ts | 2 +- shared/src/test/mockCase.ts | 3 +- .../{mockDocuments.ts => mockDocketEntry.ts} | 103 + .../marshallers/marshallDocketEntry.test.ts | 2 +- .../marshallers/marshallDocketEntry.test.ts | 2 +- .../Public/publicCaseDetailHelper.test.ts | 2232 +++++++++-------- .../Public/publicCaseDetailHelper.ts | 86 +- .../computeds/formattedDocketEntries.ts | 61 +- .../src/views/Public/PublicCaseDetail.tsx | 8 +- 29 files changed, 1359 insertions(+), 1196 deletions(-) rename shared/src/test/{mockDocuments.ts => mockDocketEntry.ts} (50%) diff --git a/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts b/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts index 13e6be93afe..a3fef50751c 100644 --- a/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts +++ b/shared/src/business/entities/DocketEntry.generateFiledBy.test.ts @@ -1,5 +1,5 @@ import { DocketEntry } from './DocketEntry'; -import { MOCK_DOCUMENTS } from '../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry'; import { NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP } from './EntityConstants'; import { applicationContext } from '../test/createTestApplicationContext'; diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 82bab185c22..664a52c1091 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -4,6 +4,7 @@ import { DOCUMENT_NOTICE_EVENT_CODES, DOCUMENT_PROCESSING_STATUS_OPTIONS, EXTERNAL_DOCUMENT_TYPES, + MINUTE_ENTRIES_MAP, NOTICE_OF_CHANGE_CONTACT_INFORMATION_EVENT_CODES, PARTIES_CODES, PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES, @@ -539,9 +540,24 @@ export class DocketEntry extends JoiValidationEntity { }; } + static isMinuteEntry(rawDocketEntry: RawDocketEntry): boolean { + const MINUTE_ENTRIES_EVENT_CODES = Object.keys(MINUTE_ENTRIES_MAP).map( + key => MINUTE_ENTRIES_MAP[key].eventCode, + ); + + return MINUTE_ENTRIES_EVENT_CODES.includes(rawDocketEntry.eventCode); + } + static isServed(rawDocketEntry: RawDocketEntry): boolean { return !!rawDocketEntry.servedAt || !!rawDocketEntry.isLegacyServed; } + + static isUnservable(rawDocketEntry: RawDocketEntry): boolean { + return ( + DocketEntry.isMinuteEntry(rawDocketEntry) || + UNSERVABLE_EVENT_CODES.includes(rawDocketEntry.eventCode) + ); + } } /** diff --git a/shared/src/business/entities/EntityConstants.ts b/shared/src/business/entities/EntityConstants.ts index 3aa46f7e6f3..dd50b60aaa8 100644 --- a/shared/src/business/entities/EntityConstants.ts +++ b/shared/src/business/entities/EntityConstants.ts @@ -574,6 +574,10 @@ export const PUBLIC_DOCKET_RECORD_FILTER_OPTIONS = omit( DOCKET_RECORD_FILTER_OPTIONS, ['exhibits'], ); +export const FILTER_OPTIONS = Object.values( + PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, +); +export type PUBLIC_DOCKET_RECORD_FILTER = (typeof FILTER_OPTIONS)[number]; // TODO: should come from internal or external filing event export const INITIAL_DOCUMENT_TYPES = { diff --git a/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts b/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts index 6de1524b364..a0da852f6a7 100644 --- a/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { DocketEntry } from '../DocketEntry'; import { MOCK_CASE } from '../../../test/mockCase'; -import { PENDING_DOCKET_ENTRY } from '../../../test/mockDocuments'; +import { PENDING_DOCKET_ENTRY } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; diff --git a/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts b/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts index dbb4a03e653..2e187187d6d 100644 --- a/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts +++ b/shared/src/business/entities/cases/Case.deleteDocketEntryById.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; describe('deleteDocketEntryById', () => { diff --git a/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts b/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts index 75ceef8bac1..6c6033b2095 100644 --- a/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts +++ b/shared/src/business/entities/cases/Case.getAttachmentDocumentById.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; describe('getAttachmentDocumentById', () => { diff --git a/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts b/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts index 8c91589ceb9..f2258f70f1c 100644 --- a/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts +++ b/shared/src/business/entities/cases/Case.getDocketEntryById.test.ts @@ -1,6 +1,6 @@ import { Case } from './Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; describe('getDocketEntryById', () => { diff --git a/shared/src/business/entities/cases/Case.test.ts b/shared/src/business/entities/cases/Case.test.ts index 457e65e3cdc..71a5e9265f1 100644 --- a/shared/src/business/entities/cases/Case.test.ts +++ b/shared/src/business/entities/cases/Case.test.ts @@ -17,7 +17,7 @@ import { import { Case, getContactPrimary } from './Case'; import { Contact } from '../contacts/Contact'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { createISODateString } from '../../utilities/DateHandler'; import { diff --git a/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts b/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts index e30187b3884..142a7b91e4a 100644 --- a/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts +++ b/shared/src/business/entities/cases/Case.updateDocketEntry.test.ts @@ -1,7 +1,7 @@ import { Case } from './Case'; import { DOCUMENT_PROCESSING_STATUS_OPTIONS } from '../EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; describe('updateDocketEntry', () => { diff --git a/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts b/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts index 8a6fda46561..3c98122a407 100644 --- a/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts +++ b/shared/src/business/useCaseHelper/automaticBlock/updateCaseAutomaticBlock.test.ts @@ -5,7 +5,7 @@ import { import { Case } from '../../entities/cases/Case'; import { MOCK_CASE, MOCK_CASE_WITHOUT_PENDING } from '../../../test/mockCase'; import { MOCK_USERS } from '../../../test/mockUsers'; -import { PENDING_DOCKET_ENTRY } from '../../../test/mockDocuments'; +import { PENDING_DOCKET_ENTRY } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { cloneDeep } from 'lodash'; import { updateCaseAutomaticBlock } from './updateCaseAutomaticBlock'; diff --git a/shared/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts b/shared/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts index 98c07af38d7..afe734ab3fd 100644 --- a/shared/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts +++ b/shared/src/business/useCaseHelper/caseAssociation/createCaseAndAssociations.test.ts @@ -1,6 +1,6 @@ import { Case } from '../../entities/cases/Case'; import { MOCK_CASE } from '../../../../src/test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { createCaseAndAssociations } from './createCaseAndAssociations'; diff --git a/shared/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts b/shared/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts index 5db6f93125a..b135506743b 100644 --- a/shared/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts +++ b/shared/src/business/useCaseHelper/caseAssociation/updateCaseAndAssociations.test.ts @@ -11,7 +11,7 @@ import { import { Case } from '../../entities/cases/Case'; import { CaseDeadline } from '../../entities/CaseDeadline'; import { MOCK_CASE } from '../../../../src/test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { MOCK_WORK_ITEM } from '../../../test/mockWorkItem'; import { Message } from '../../entities/Message'; import { applicationContext } from '../../test/createTestApplicationContext'; diff --git a/shared/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts b/shared/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts index 01cd1102bb0..c8855b4fa7b 100644 --- a/shared/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts +++ b/shared/src/business/useCaseHelper/docketEntry/fileAndServeDocumentOnOneCase.test.ts @@ -13,7 +13,7 @@ import { MOCK_CASE, MOCK_LEAD_CASE_WITH_PAPER_SERVICE, } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { WorkItem } from '../../entities/WorkItem'; import { createISODateString } from '../../utilities/DateHandler'; import { docketClerkUser, judgeUser } from '../../../test/mockUsers'; diff --git a/shared/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts b/shared/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts index ce113c11761..6ff9d3e92c1 100644 --- a/shared/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts +++ b/shared/src/business/useCaseHelper/initialFilingDocuments/updateInitialFilingDocuments.test.ts @@ -6,7 +6,7 @@ import { } from '../../entities/EntityConstants'; import { Case, getContactPrimary } from '../../entities/cases/Case'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { updateInitialFilingDocuments } from './updateInitialFilingDocuments'; diff --git a/shared/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts b/shared/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts index 48a45e710bf..505af096531 100644 --- a/shared/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts +++ b/shared/src/business/useCaseHelper/stampDisposition/addDraftStampOrderDocketEntryInteractor.test.ts @@ -1,5 +1,5 @@ import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { MOTION_DISPOSITIONS, ORDER_TYPES, diff --git a/shared/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts b/shared/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts index d63892bd53e..ea66a02c0f2 100644 --- a/shared/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts +++ b/shared/src/business/useCases/courtIssuedDocument/fileAndServeCourtIssuedDocumentInteractor.consolidatedCases.test.ts @@ -7,7 +7,7 @@ import { MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE, MOCK_LEAD_CASE_WITH_PAPER_SERVICE, } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { docketClerkUser } from '../../../test/mockUsers'; import { fileAndServeCourtIssuedDocumentInteractor } from './fileAndServeCourtIssuedDocumentInteractor'; diff --git a/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts b/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts index f3e297bc295..ef5da0f4df0 100644 --- a/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts +++ b/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.consolidatedCases.test.ts @@ -8,7 +8,7 @@ import { MOCK_CONSOLIDATED_2_CASE_WITH_PAPER_SERVICE, MOCK_LEAD_CASE_WITH_PAPER_SERVICE, } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { docketClerkUser } from '../../../test/mockUsers'; import { serveCourtIssuedDocumentInteractor } from './serveCourtIssuedDocumentInteractor'; diff --git a/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts b/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts index d48578c6a70..83e40646242 100644 --- a/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts +++ b/shared/src/business/useCases/courtIssuedDocument/serveCourtIssuedDocumentInteractor.test.ts @@ -1,6 +1,6 @@ import { AUTO_GENERATED_DEADLINE_DOCUMENT_TYPES } from '../../entities/EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { MOCK_TRIAL_REGULAR } from '../../../test/mockTrial'; import { applicationContext } from '../../test/createTestApplicationContext'; import { docketClerkUser, judgeUser } from '../../../test/mockUsers'; diff --git a/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts b/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts index f38c492b5e0..021ed76722c 100644 --- a/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts +++ b/shared/src/business/useCases/saveSignedDocumentInteractor.test.ts @@ -4,7 +4,7 @@ import { SIGNED_DOCUMENT_TYPES, } from '../entities/EntityConstants'; import { MOCK_CASE } from '../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry'; import { applicationContext } from '../test/createTestApplicationContext'; import { saveSignedDocumentInteractor } from './saveSignedDocumentInteractor'; diff --git a/shared/src/business/useCases/uploadDocumentAndMakeSafeInteractor.test.ts b/shared/src/business/useCases/uploadDocumentAndMakeSafeInteractor.test.ts index e3346915da8..c3b5ae26f92 100644 --- a/shared/src/business/useCases/uploadDocumentAndMakeSafeInteractor.test.ts +++ b/shared/src/business/useCases/uploadDocumentAndMakeSafeInteractor.test.ts @@ -1,4 +1,4 @@ -import { MOCK_DOCUMENTS } from '../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry'; import { applicationContext } from '../test/createTestApplicationContext'; import { uploadDocumentAndMakeSafeInteractor } from './uploadDocumentAndMakeSafeInteractor'; diff --git a/shared/src/business/useCases/users/verifyUserPendingEmailInteractor.test.ts b/shared/src/business/useCases/users/verifyUserPendingEmailInteractor.test.ts index 99b4973cb50..74960d57c21 100644 --- a/shared/src/business/useCases/users/verifyUserPendingEmailInteractor.test.ts +++ b/shared/src/business/useCases/users/verifyUserPendingEmailInteractor.test.ts @@ -4,7 +4,7 @@ import { SERVICE_INDICATOR_TYPES, } from '../../entities/EntityConstants'; import { MOCK_CASE } from '../../../test/mockCase'; -import { MOCK_DOCUMENTS } from '../../../test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../test/mockDocketEntry'; import { applicationContext } from '../../test/createTestApplicationContext'; import { calculateISODate } from '../../utilities/DateHandler'; import { getContactPrimary } from '../../entities/cases/Case'; diff --git a/shared/src/test/mockCase.ts b/shared/src/test/mockCase.ts index 5a7846c4b0d..ed050cedb60 100644 --- a/shared/src/test/mockCase.ts +++ b/shared/src/test/mockCase.ts @@ -7,7 +7,7 @@ import { PAYMENT_STATUS, SERVICE_INDICATOR_TYPES, } from '../business/entities/EntityConstants'; -import { MOCK_DOCUMENTS } from './mockDocuments'; +import { MOCK_DOCUMENTS } from './mockDocketEntry'; export const MOCK_CASE: RawCase = { archivedDocketEntries: [], @@ -16,6 +16,7 @@ export const MOCK_CASE: RawCase = { correspondence: [], createdAt: '2018-03-01T21:40:46.415Z', docketEntries: MOCK_DOCUMENTS, + docketEntriesEFiledByPractitioner: [], docketNumber: '101-18', docketNumberWithSuffix: '101-18', entityName: 'Case', diff --git a/shared/src/test/mockDocuments.ts b/shared/src/test/mockDocketEntry.ts similarity index 50% rename from shared/src/test/mockDocuments.ts rename to shared/src/test/mockDocketEntry.ts index 9468aa3685e..e9c71f6f7f8 100644 --- a/shared/src/test/mockDocuments.ts +++ b/shared/src/test/mockDocketEntry.ts @@ -33,6 +33,109 @@ export const PENDING_DOCKET_ENTRY: RawDocketEntry = { userId: '7805d1ab-18d0-43ec-bafb-654e83405416', }; +export const MOCK_MINUTE_ENTRY: RawDocketEntry = { + addToCoversheet: false, + createdAt: '2023-02-08T16:15:08.500Z', + docketEntryId: '4086b86c-161d-41f7-ac4f-da6bbb5f6f0f', + docketNumber: '983-23', + documentTitle: 'Filing Fee Paid', + documentType: 'Filing Fee Paid', + draftOrderState: {}, + entityName: 'DocketEntry', + eventCode: 'FEE', + filers: [], + filingDate: '2023-02-08T05:00:00.000Z', + index: 3, + isDraft: false, + isFileAttached: false, + isMinuteEntry: true, + isOnDocketRecord: true, + isStricken: false, + pending: false, + processingStatus: 'complete', + receivedAt: '2023-02-08T05:00:00.000Z', + stampData: {}, + userId: '23f53824-1c1b-4cad-876e-0b7ce045e472', +}; + +export const MOCK_ANSWER: RawDocketEntry = { + addToCoversheet: false, + createdAt: '2023-03-30T18:01:14.583Z', + docketEntryId: 'd92514b3-8194-4d05-8292-0002ea11eef9', + docketNumber: '983-23', + documentTitle: 'Answer', + documentType: 'Answer', + draftOrderState: {}, + entityName: 'DocketEntry', + eventCode: 'A', + filedBy: 'Resp.', + filers: [], + filingDate: '2023-03-30T18:01:14.583Z', + hasSupportingDocuments: false, + index: 9, + isDraft: false, + isFileAttached: true, + isMinuteEntry: false, + isOnDocketRecord: true, + isStricken: false, + numberOfPages: 5, + pending: false, + processingStatus: 'complete', + qcAt: '2023-03-31T14:03:56.079Z', + qcByUserId: 'f0c1cd15-9d23-4dac-86b8-700b77e315b7', + receivedAt: '2023-03-30T04:00:00.000Z', + relationship: 'primaryDocument', + scenario: 'Standard', + servedAt: '2023-03-30T18:01:14.585Z', + servedParties: [ + { + email: '134c839d3e594782b63f344c0b7ec38d@ef-cms.ustaxcourt.gov', + name: 'Barnaby Pinkhouse', + }, + ], + servedPartiesCode: 'B', + stampData: {}, + userId: 'f0c1cd15-9d23-4dac-86b8-700b77e315b7', + workItem: { + assigneeId: 'f0c1cd15-9d23-4dac-86b8-700b77e315b7', + assigneeName: 'Docket Clerk 1', + associatedJudge: 'Chief Judge', + caseStatus: 'General Docket - At Issue (Ready for Trial)', + caseTitle: 'Barnaby Pinkhouse', + completedAt: '2023-03-31T14:03:56.090Z', + completedBy: 'Docket Clerk 1', + completedByUserId: 'f0c1cd15-9d23-4dac-86b8-700b77e315b7', + completedMessage: 'completed', + createdAt: '2023-03-30T18:01:14.585Z', + docketEntry: { + createdAt: '2023-03-30T18:01:14.583Z', + docketEntryId: 'd92514b3-8194-4d05-8292-0002ea11eef9', + documentTitle: 'Answer', + documentType: 'Answer', + eventCode: 'A', + filedBy: 'Resp.', + index: 9, + isFileAttached: true, + receivedAt: '2023-03-30T04:00:00.000Z', + servedAt: '2023-03-30T18:01:14.585Z', + userId: 'f0c1cd15-9d23-4dac-86b8-700b77e315b7', + }, + docketNumber: '983-23', + docketNumberWithSuffix: '983-23S', + entityName: 'WorkItem', + highPriority: false, + isRead: true, + section: 'docket', + sentBy: 'Docket Clerk 1', + sentBySection: 'docket', + sentByUserId: 'f0c1cd15-9d23-4dac-86b8-700b77e315b7', + trialDate: null, + trialLocation: null, + updatedAt: '2023-03-30T18:01:14.585Z', + workItemId: 'a358c6b2-076b-4850-a415-e77f4329e9d8', + }, +}; + export const MOCK_DOCUMENTS: RawDocketEntry[] = [ { createdAt: '2018-11-21T20:49:28.192Z', diff --git a/web-api/src/v1/marshallers/marshallDocketEntry.test.ts b/web-api/src/v1/marshallers/marshallDocketEntry.test.ts index 8f34a56d0af..5e92c070017 100644 --- a/web-api/src/v1/marshallers/marshallDocketEntry.test.ts +++ b/web-api/src/v1/marshallers/marshallDocketEntry.test.ts @@ -1,4 +1,4 @@ -import { MOCK_DOCUMENTS } from '../../../../shared/src/test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../../shared/src/test/mockDocketEntry'; import { marshallDocketEntry } from './marshallDocketEntry'; const MOCK_DOCUMENT = MOCK_DOCUMENTS[0]; diff --git a/web-api/src/v2/marshallers/marshallDocketEntry.test.ts b/web-api/src/v2/marshallers/marshallDocketEntry.test.ts index 8f34a56d0af..5e92c070017 100644 --- a/web-api/src/v2/marshallers/marshallDocketEntry.test.ts +++ b/web-api/src/v2/marshallers/marshallDocketEntry.test.ts @@ -1,4 +1,4 @@ -import { MOCK_DOCUMENTS } from '../../../../shared/src/test/mockDocuments'; +import { MOCK_DOCUMENTS } from '../../../../shared/src/test/mockDocketEntry'; import { marshallDocketEntry } from './marshallDocketEntry'; const MOCK_DOCUMENT = MOCK_DOCUMENTS[0]; diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts index 92f091c3c24..ef1b28d7797 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts @@ -1,11 +1,16 @@ /* eslint-disable max-lines */ import { DOCKET_ENTRY_SEALED_TO_TYPES, + DOCUMENT_PROCESSING_STATUS_OPTIONS, PARTIES_CODES, POLICY_DATE_IMPACTED_EVENTCODES, PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, STIPULATED_DECISION_EVENT_CODE, } from '../../../../../shared/src/business/entities/EntityConstants'; +import { + MOCK_ANSWER, + MOCK_MINUTE_ENTRY, +} from '../../../../../shared/src/test/mockDocketEntry'; import { applicationContextPublic } from '../../../applicationContextPublic'; import { fetchRootDocument, @@ -15,6 +20,7 @@ import { import { formatDocketEntry } from '../../../../../shared/src/business/utilities/getFormattedCaseDetail'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../../withAppContext'; + const stipDecisionDocument = formatDocketEntry(applicationContextPublic, { addToCoversheet: false, attachments: false, @@ -109,8 +115,6 @@ describe('publicCaseDetailHelper', () => { publicCaseDetailHelperComputed, applicationContextPublic, ); - const { DOCUMENT_PROCESSING_STATUS_OPTIONS, INITIAL_DOCUMENT_TYPES } = - applicationContextPublic.getConstants(); const baseDocketEntry = { docketEntryId: 'ae454c18-be84-4a2b-b055-9046ada4f65d', @@ -143,313 +147,1131 @@ describe('publicCaseDetailHelper', () => { }; }); - describe('formatDocketEntryOnDocketRecord', () => { - it('should compute sealedToTooltip value when the entry is sealed', () => { - const mockSealedDocketEntry = { - ...baseDocketEntry, - isSealed: true, - rootDocument: { documentType: 'Petition' }, - sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, - sealedToTooltip: undefined, - }; - - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: mockSealedDocketEntry, - isTerminalUser: false, - visibilityPolicyDateFormatted: '', - }); + describe('formattedDocketEntriesOnDocketRecord', () => { + it('should be sorted chronologically by date', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + createdAt: '2018-11-21T20:49:28.192Z', + filingDate: '2018-11-21T20:49:28.192Z', + index: 4, + }, + { + ...baseDocketEntry, + createdAt: '2018-10-21T20:49:28.192Z', + filingDate: '2018-10-21T20:49:28.192Z', + index: 1, + }, + { + ...baseDocketEntry, + createdAt: '2018-10-25T20:49:28.192Z', + filingDate: '2018-10-25T20:49:28.192Z', + index: 3, + }, + { + ...baseDocketEntry, + createdAt: '2018-10-25T20:49:28.192Z', + eventCode: 'O', + filingDate: '2018-10-25T20:49:28.192Z', + index: 2, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + { + ...baseDocketEntry, + createdAt: '2018-12-25T20:49:28.192Z', + filingDate: '2018-12-25T20:49:28.192Z', + index: 5, + }, + { + ...baseDocketEntry, + createdAt: '2018-12-25T20:49:28.192Z', + filingDate: '2018-12-25T20:49:28.192Z', + index: 6, + }, + { + ...baseDocketEntry, + createdAt: '2019-12-24T20:49:28.192Z', + filingDate: '2019-12-24T20:49:28.192Z', + index: 7, + }, + { + ...baseDocketEntry, + createdAt: '2019-12-24T20:49:28.192Z', + filingDate: '2019-12-24T20:49:28.192Z', + index: 8, + }, + { + ...baseDocketEntry, + createdAt: '2019-12-25T20:49:28.192Z', + filingDate: '2019-12-25T20:49:28.192Z', + index: 9, + }, + ]; + + const result = runCompute(publicCaseDetailHelper, { state }); - expect(result.sealedToTooltip).toBe('Sealed to the public'); + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + createdAtFormatted: '10/21/18', + index: 1, + }, + { + createdAtFormatted: '10/25/18', + index: 3, + }, + { + createdAtFormatted: '11/21/18', + index: 4, + }, + { + createdAtFormatted: '12/25/18', + index: 5, + }, + { + createdAtFormatted: '12/25/18', + index: 6, + }, + { + createdAtFormatted: '12/24/19', + index: 7, + }, + { + createdAtFormatted: '12/24/19', + index: 8, + }, + { + createdAtFormatted: '12/25/19', + index: 9, + }, + { + index: 2, + }, + ]); }); - it('should NOT compute sealedToTooltip value when the entry is NOT sealed', () => { - const mockDocketEntry = { - ...baseDocketEntry, - isSealed: false, - rootDocument: { documentType: 'Petition' }, - sealedToTooltip: undefined, - }; - - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: mockDocketEntry, - isTerminalUser: false, - visibilityPolicyDateFormatted: '', + describe('filtering', () => { + describe('docket record filtering', () => { + const caseDetail = { + docketEntries: [ + { + ...baseDocketEntry, + docketEntryId: '402ccc12-72c0-481e-b3f2-44debcd167a4', + documentTitle: 'Exhibit for Noodles', + eventCode: 'EXH', + }, + { + ...baseDocketEntry, + docketEntryId: '402ccc12-72c0-481e-b3f2-44debcd167a4', + documentTitle: 'Order in the Court', + eventCode: 'O', + }, + { + ...baseDocketEntry, + docketEntryId: '402ccc12-72c0-481e-b3f2-44debcd167a4', + documentTitle: 'Motion in the Ocean', + eventCode: 'M000', + }, + ], + }; + + it('should ONLY show order type docket entries when "Orders" has been selected as the filter', () => { + const result = runCompute(publicCaseDetailHelper, { + state: { + caseDetail, + sessionMetadata: { + docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.orders, + }, + }, + }); + + expect(result.formattedDocketEntriesOnDocketRecord.length).toBe(1); + expect(result.formattedDocketEntriesOnDocketRecord[0].eventCode).toBe( + 'O', + ); + }); + + it('should ONLY show motion type docket entries when "Motions" has been selected as the filter', () => { + const result = runCompute(publicCaseDetailHelper, { + state: { + caseDetail, + sessionMetadata: { + docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.motions, + }, + }, + }); + + expect(result.formattedDocketEntriesOnDocketRecord.length).toBe(1); + expect(result.formattedDocketEntriesOnDocketRecord[0].eventCode).toBe( + 'M000', + ); + }); + + it('should show all docket entries when "All documents" has been selected as the filter', () => { + const result = runCompute(publicCaseDetailHelper, { + state: { + caseDetail, + sessionMetadata: { + docketRecordFilter: + PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments, + }, + }, + }); + + expect(result.formattedDocketEntriesOnDocketRecord.length).toBe( + caseDetail.docketEntries.length, + ); + }); }); + }); + + describe('descriptionDisplay', () => { + it('should descriptionDisplay for `OCS` type documents correctly and makes it visible to public users', () => { + state.caseDetail.docketEntries = [ + { + docketEntryId: 'd-1-2-3', + documentTitle: 'Online Cited Source', + documentType: 'Online Cited Source', + eventCode: 'OCS', + freeText: 'Test site viewed on 09/09/22', + isFileAttached: true, + isOnDocketRecord: true, + isUnservable: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + ]; - expect(result.sealedToTooltip).toBe(undefined); + const result = runCompute(publicCaseDetailHelper, { state }); + + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + descriptionDisplay: + 'Test site viewed on 09/09/22 - Online Cited Source', + docketEntryId: 'd-1-2-3', + eventCode: 'OCS', + showLinkToDocument: true, + }, + ]); + }); }); - it('should set the value of isSealed on the record', () => { - const mockDocketEntry = { - ...baseDocketEntry, - isSealed: false, - rootDocument: { documentType: 'Petition' }, - }; - - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: mockDocketEntry, - isTerminalUser: false, - visibilityPolicyDateFormatted: '', + describe('hasDocument', () => { + it('should be false when the docket entry is a minute entry', () => { + state.caseDetail.docketEntries = [MOCK_MINUTE_ENTRY]; + + const { formattedDocketEntriesOnDocketRecord } = runCompute( + publicCaseDetailHelper, + { state }, + ); + + expect(formattedDocketEntriesOnDocketRecord[0].hasDocument).toBe(false); }); - expect(result.isSealed).toBe(mockDocketEntry.isSealed); + it('should be true when the docket entry is NOT a minute entry', () => { + state.caseDetail.docketEntries = [MOCK_ANSWER]; + + const { formattedDocketEntriesOnDocketRecord } = runCompute( + publicCaseDetailHelper, + { state }, + ); + + expect(formattedDocketEntriesOnDocketRecord[0].hasDocument).toBe(true); + }); }); - it('should not display the document link when the entry is stricken and the user is the terminal user', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: { + describe('sealedToTooltip', () => { + it('should compute sealedToTooltip value when the entry is sealed', () => { + const mockSealedDocketEntry = { ...baseDocketEntry, - isStricken: true, + isSealed: true, rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: true, - visibilityPolicyDateFormatted: '', - }); + sealedTo: DOCKET_ENTRY_SEALED_TO_TYPES.PUBLIC, + sealedToTooltip: undefined, + }; + + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: mockSealedDocketEntry, + isTerminalUser: false, + visibilityPolicyDateFormatted: '', + }, + ); - expect(result.showLinkToDocument).toBe(false); - }); + expect(result.sealedToTooltip).toBe('Sealed to the public'); + }); - it('should show document link for a policy date impacted document for the terminal user when filed by practitioner after policy change date', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { + it('should NOT compute sealedToTooltip value when the entry is NOT sealed', () => { + const mockDocketEntry = { ...baseDocketEntry, - eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], - isCourtIssuedDocument: false, - isNotServedDocument: false, + isSealed: false, rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: true, - visibilityPolicyDateFormatted: '2010-05-16T00:00:00.000-04:00', - }); + sealedToTooltip: undefined, + }; + + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: mockDocketEntry, + isTerminalUser: false, + visibilityPolicyDateFormatted: '', + }, + ); - expect(result.showLinkToDocument).toBe(true); + expect(result.sealedToTooltip).toBe(undefined); + }); }); - it('should show document link for brief for the terminal user when filed by practitioner before policy change date', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: true, - visibilityPolicyDateFormatted: '2040-05-16T00:00:00.000-04:00', + describe('showLinkToDocument', () => { + it('should not display a link for the PMT event code', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + documentTitle: 'PRE-TRIAL MEMORANDUM for Resp. (C/S 5-16-13)', + documentType: 'Miscellaneous', + eventCode: 'PMT', + }, + ]; + const result = runCompute(publicCaseDetailHelper, { state }); + + expect( + result.formattedDocketEntriesOnDocketRecord[0].showLinkToDocument, + ).toBeFalsy(); }); - expect(result.showLinkToDocument).toBe(true); - }); + it('should not show a link for documents not visible to the public', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', + documentTitle: 'Petition', + documentType: 'Petition', + eventCode: 'P', + index: 1, + isLegacyServed: true, + }, + { + ...baseDocketEntry, + docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', + documentTitle: + 'Request for Place of Trial at San Francisco, California', + documentType: 'Request for Place of Trial', + eventCode: 'RQT', + index: 2, + isLegacyServed: true, + }, + { + ...baseDocketEntry, + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + documentTitle: + 'Order of Dismissal and Decision Entered, Judge Buch', + documentType: 'Order of Dismissal and Decision', + eventCode: 'ODD', + index: 3, + isLegacyServed: true, + }, + { + ...baseDocketEntry, + docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', + documentTitle: + 'Notice of Trial on 12/30/2019 at San Francisco, California', + documentType: 'Notice of Trial', + eventCode: 'NTD', + index: 4, + isLegacyServed: true, + }, + { + ...baseDocketEntry, + docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 5, + isLegacyServed: true, + }, + { + ...baseDocketEntry, + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 6, + isFileAttached: false, + isLegacyServed: true, + }, + ]; - it('should show document link for a policy date impacted document when filed by practitioner after policy change date for the public user and is not a court issued document', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], - filingDate: '2030-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2020-05-16T00:00:00.000-04:00', + const result = runCompute(publicCaseDetailHelper, { state }); + + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + descriptionDisplay: 'Petition', + docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', + eventCode: 'P', + index: 1, + showLinkToDocument: false, + }, + { + descriptionDisplay: + 'Request for Place of Trial at San Francisco, California', + docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', + eventCode: 'RQT', + index: 2, + showLinkToDocument: false, + }, + { + descriptionDisplay: + 'Order of Dismissal and Decision Entered, Judge Buch', + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + eventCode: 'ODD', + index: 3, + showLinkToDocument: true, + }, + { + descriptionDisplay: + 'Notice of Trial on 12/30/2019 at San Francisco, California', + docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', + eventCode: 'NTD', // not in EVENT_CODES_VISIBLE_TO_PUBLIC + index: 4, + showLinkToDocument: false, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', + eventCode: 'SPTO', + index: 5, + showLinkToDocument: true, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + eventCode: 'SPTO', + index: 6, + showLinkToDocument: false, + }, + ]); }); - expect(result.showLinkToDocument).toBe(true); - }); + it('should not show a link for sealed docket entries requested by a public user', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + documentTitle: + 'Order of Dismissal and Decision Entered, Judge Buch', + documentType: 'Order of Dismissal and Decision', + eventCode: 'ODD', + index: 0, + isSealed: true, + servedAt: '2019-12-30T21:00:00.000Z', + }, + ]; - it('should NOT show document link for a policy date impacted, court-issued stip decision when filed before policy change date for the public user', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: STIPULATED_DECISION_EVENT_CODE, - filingDate: '2030-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: true, - isNotServedDocument: false, - isStipDecision: true, - rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2040-05-16T00:00:00.000-04:00', + const result = runCompute(publicCaseDetailHelper, { state }); + + expect( + result.formattedDocketEntriesOnDocketRecord[0].showLinkToDocument, + ).toBe(false); }); - expect(result.showLinkToDocument).toBe(false); - }); + it('should show a link for documents requested by a terminal user', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', + documentTitle: 'Petition', + documentType: 'Petition', + eventCode: 'P', + index: 1, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + { + ...baseDocketEntry, + docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', + documentTitle: + 'Request for Place of Trial at San Francisco, California', + documentType: 'Request for Place of Trial', + eventCode: 'RQT', + index: 2, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + { + ...baseDocketEntry, + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + documentTitle: + 'Order of Dismissal and Decision Entered, Judge Buch', + documentType: 'Order of Dismissal and Decision', + eventCode: 'ODD', + index: 3, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + { + ...baseDocketEntry, + docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', + documentTitle: + 'Notice of Trial on 12/30/2019 at San Francisco, California', + documentType: 'Notice of Trial', + eventCode: 'NTD', + index: 4, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + { + ...baseDocketEntry, + docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 5, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + { + ...baseDocketEntry, + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 6, + isFileAttached: false, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + ]; + + const result = runCompute(publicCaseDetailHelper, { + state: { ...state, isTerminalUser: true }, + }); + + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + descriptionDisplay: 'Petition', + docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', + eventCode: 'P', + index: 1, + openInSameTab: false, + showLinkToDocument: true, + }, + { + descriptionDisplay: + 'Request for Place of Trial at San Francisco, California', + docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', + eventCode: 'RQT', + index: 2, + openInSameTab: false, + showLinkToDocument: true, + }, + { + descriptionDisplay: + 'Order of Dismissal and Decision Entered, Judge Buch', + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + eventCode: 'ODD', + index: 3, + openInSameTab: false, + showLinkToDocument: true, + }, + { + descriptionDisplay: + 'Notice of Trial on 12/30/2019 at San Francisco, California', + docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', + eventCode: 'NTD', // not in EVENT_CODES_VISIBLE_TO_PUBLIC + index: 4, + openInSameTab: false, + showLinkToDocument: true, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', + eventCode: 'SPTO', + index: 5, + openInSameTab: false, + showLinkToDocument: true, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + eventCode: 'SPTO', + index: 6, + openInSameTab: false, + showLinkToDocument: false, + }, + ]); + }); - it('should not show document link for a policy date impacted document when filed by practitioner before policy change date for the public user and is not a court issued document', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], - filingDate: '2030-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2040-05-16T00:00:00.000-04:00', + it('should not show a link for documents requested by a public user only', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', + documentTitle: 'Decision Entered, Judge Buch Decision', + documentType: 'Decision', + eventCode: 'DEC', + index: 1, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + { + ...baseDocketEntry, + docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', + documentTitle: + 'Request for Place of Trial at San Francisco, California', + documentType: 'Request for Place of Trial', + eventCode: 'RQT', + index: 2, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + { + ...baseDocketEntry, + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + documentTitle: 'Decision Entered, Judge Buch Another Decision', + documentType: 'Decision', + eventCode: 'DEC', + index: 3, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + }, + { + ...baseDocketEntry, + docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', + documentTitle: + 'Notice of Trial on 12/30/2019 at San Francisco, California', + documentType: 'Notice of Trial', + eventCode: 'NTD', + index: 4, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + { + ...baseDocketEntry, + docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 5, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + { + ...baseDocketEntry, + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 6, + isFileAttached: false, + isLegacyServed: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + }, + ]; + + const result = runCompute(publicCaseDetailHelper, { + state: { ...state, isTerminalUser: false }, + }); + + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + descriptionDisplay: 'Decision Entered, Judge Buch Decision', + docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', + eventCode: 'DEC', + index: 1, + openInSameTab: true, + showLinkToDocument: true, + }, + { + descriptionDisplay: + 'Request for Place of Trial at San Francisco, California', + docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', + eventCode: 'RQT', + index: 2, + openInSameTab: true, + showLinkToDocument: false, + }, + { + descriptionDisplay: 'Decision Entered, Judge Buch Another Decision', + docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', + eventCode: 'DEC', + index: 3, + openInSameTab: true, + showLinkToDocument: false, + }, + { + descriptionDisplay: + 'Notice of Trial on 12/30/2019 at San Francisco, California', + docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', + eventCode: 'NTD', // not in EVENT_CODES_VISIBLE_TO_PUBLIC + index: 4, + openInSameTab: true, + showLinkToDocument: false, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', + eventCode: 'SPTO', + index: 5, + openInSameTab: true, + showLinkToDocument: true, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + eventCode: 'SPTO', + index: 6, + openInSameTab: true, + showLinkToDocument: false, + }, + ]); }); - expect(result.showLinkToDocument).toBe(false); - }); + it('should not show a link for sealed documents requested by a terminal user', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 1, + isFileAttached: false, + isLegacyServed: true, + isSealed: true, + }, + { + ...baseDocketEntry, + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + documentTitle: 'Standing Pretrial Order', + documentType: 'Standing Pretrial Order', + eventCode: 'SPTO', + index: 2, + isFileAttached: false, + isLegacySealed: true, + isLegacyServed: true, + }, + ]; + + const result = runCompute(publicCaseDetailHelper, { + state: { ...state, isTerminalUser: true }, + }); + + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + eventCode: 'SPTO', + index: 1, + openInSameTab: false, + showLinkToDocument: false, + }, + { + descriptionDisplay: 'Standing Pretrial Order', + docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', + eventCode: 'SPTO', + index: 2, + openInSameTab: false, + showLinkToDocument: false, + }, + ]); + }); - it('should NOT show document link for an amended brief when the docket entry was filed before visibility policy date (8/1/2023) by a practitioner on the case', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: 'AMAT', - filingDate: '2020-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { - docketEntryId: 'e86b58a8-aeb3-460e-af4b-3a31b6bae864', - documentTitle: 'Seriatim Answering Memorandum Brief', - documentType: 'Seriatim Answering Memorandum Brief', + it('should show a link when the current document is a multi level ammendment whose root document is a brief', () => { + state.caseDetail.docketEntriesEFiledByPractitioner = [ + '6d83425c-8ef3-4c66-b776-6c7957c53f4d', + '4796a931-14fb-43e6-948f-d2b67ce4c1cb', + '8e3ae16b-dc29-433f-878a-7a0534c39919', + 'ea55927d-f61a-4657-b828-3b8a9d9b9b70', + 'b22fd1a0-56cb-4873-bb4f-50df3a65da3f', + ]; + state.caseDetail.docketEntries = [ + { + attachments: false, + certificateOfService: false, + certificateOfServiceDate: null, + docketEntryId: 'b22fd1a0-56cb-4873-bb4f-50df3a65da3f', + docketNumber: '103-20', + documentTitle: + 'Redacted First Supplement to Seriatim Answering Brief', + documentType: 'Redacted', + entityName: 'PublicDocketEntry', + eventCode: 'REDC', + filedBy: 'Petr. Reuben Blair', + filingDate: '2024-07-26T15:27:03.890Z', + index: 9, + isFileAttached: true, + isMinuteEntry: false, + isOnDocketRecord: true, + isSealed: false, + isStricken: false, + numberOfPages: 2, + previousDocument: { + docketEntryId: 'ea55927d-f61a-4657-b828-3b8a9d9b9b70', + documentTitle: 'First Supplement to Seriatim Answering Brief', + documentType: 'Supplement', + }, + processingStatus: 'complete', + receivedAt: '2023-07-26T04:00:00.000Z', + servedAt: '2023-07-26T15:27:03.893Z', + servedPartiesCode: 'B', }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + { + attachments: false, + certificateOfService: false, + certificateOfServiceDate: null, + docketEntryId: 'ea55927d-f61a-4657-b828-3b8a9d9b9b70', + docketNumber: '103-20', + documentTitle: 'First Supplement to Seriatim Answering Brief', + documentType: 'Supplement', + entityName: 'PublicDocketEntry', + eventCode: 'SUPM', + filedBy: 'Petr. Reuben Blair', + filingDate: '2024-07-26T15:26:33.586Z', + index: 8, + isFileAttached: true, + isMinuteEntry: false, + isOnDocketRecord: true, + isSealed: false, + isStricken: false, + numberOfPages: 2, + previousDocument: { + docketEntryId: '8e3ae16b-dc29-433f-878a-7a0534c39919', + documentTitle: 'Seriatim Answering Brief', + documentType: 'Seriatim Answering Brief', + }, + processingStatus: 'complete', + receivedAt: '2023-07-26T04:00:00.000Z', + servedAt: '2023-07-26T15:26:33.591Z', + servedPartiesCode: 'B', + }, + { + attachments: false, + certificateOfService: false, + certificateOfServiceDate: null, + docketEntryId: '8e3ae16b-dc29-433f-878a-7a0534c39919', + docketNumber: '103-20', + documentTitle: 'Seriatim Answering Brief', + documentType: 'Seriatim Answering Brief', + entityName: 'PublicDocketEntry', + eventCode: 'SEAB', + filedBy: 'Petr. Reuben Blair', + filingDate: '2024-07-26T15:25:33.548Z', + index: 7, + isFileAttached: true, + isMinuteEntry: false, + isOnDocketRecord: true, + isSealed: false, + isStricken: false, + numberOfPages: 2, + processingStatus: 'complete', + receivedAt: '2023-07-26T04:00:00.000Z', + servedAt: '2023-07-26T15:25:33.550Z', + servedPartiesCode: 'B', + }, + ]; + + const result = runCompute(publicCaseDetailHelper, { state }); + + expect( + result.formattedDocketEntriesOnDocketRecord[0].showLinkToDocument, + ).toEqual(true); }); - expect(result.showLinkToDocument).toBe(false); - }); + it('should not display the document link when the entry is stricken and the user is the terminal user', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: { + ...baseDocketEntry, + isStricken: true, + rootDocument: { documentType: 'Petition' }, + }, + isTerminalUser: true, + visibilityPolicyDateFormatted: '', + }, + ); - it('should show document link for an amended brief when the docket entry was filed after the visibility policy date (8/1/2023) by a practitioner on the case', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: 'AMAT', - filingDate: '2050-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { - docketEntryId: 'e86b58a8-aeb3-460e-af4b-3a31b6bae864', - documentTitle: 'Seriatim Answering Memorandum Brief', - documentType: 'Seriatim Answering Memorandum Brief', + expect(result.showLinkToDocument).toBe(false); + }); + + it('should show document link for a policy date impacted document for the terminal user when filed by practitioner after policy change date', () => { + const { showLinkToDocument } = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], + isCourtIssuedDocument: false, + rootDocument: { documentType: 'Petition' }, + servedAt: '2012-05-16T00:00:00.000-04:00', + }, + isTerminalUser: true, + visibilityPolicyDateFormatted: '2010-05-16T00:00:00.000-04:00', }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + ); + + expect(showLinkToDocument).toBe(true); }); - expect(result.showLinkToDocument).toBe(true); - }); + it('should show document link for brief for the terminal user when filed by practitioner before policy change date', () => { + const { showLinkToDocument } = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], + isCourtIssuedDocument: false, + rootDocument: { documentType: 'Petition' }, + servedAt: '2040-05-16T00:00:00.000-04:00', + }, + isTerminalUser: true, + visibilityPolicyDateFormatted: '2040-05-16T00:00:00.000-04:00', + }, + ); - it('should NOT show document link for an amendment docket entry when the previous docket entry is NOT a brief', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], - entry: { - ...baseDocketEntry, - eventCode: 'AMAT', - filingDate: '2050-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { - docketEntryId: baseDocketEntry.docketEntryId, - documentTitle: 'Petition', - documentType: 'Petition', + expect(showLinkToDocument).toBe(true); + }); + + it('should show document link for a policy date impacted document when filed by practitioner after policy change date for the public user and is not a court issued document', () => { + const { showLinkToDocument } = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], + filingDate: '2030-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + rootDocument: { documentType: 'Petition' }, + servedAt: '2030-05-16T00:00:00.000-04:00', + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2020-05-16T00:00:00.000-04:00', }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + ); + + expect(showLinkToDocument).toBe(true); }); - expect(result.showLinkToDocument).toBe(false); - }); + it('should NOT show document link for a policy date impacted, court-issued stip decision when filed before policy change date for the public user', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: STIPULATED_DECISION_EVENT_CODE, + filingDate: '2030-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: true, + isNotServedDocument: false, + isStipDecision: true, + rootDocument: { documentType: 'Petition' }, + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2040-05-16T00:00:00.000-04:00', + }, + ); - it('should show document link for a Stipulated Decision (SDEC)', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: { - ...stipDecisionDocument, - rootDocument: { documentType: 'Petition' }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + expect(result.showLinkToDocument).toBe(false); }); - expect(result.showLinkToDocument).toBe(true); - }); + it('should not show document link for a policy date impacted document when filed by practitioner before policy change date for the public user and is not a court issued document', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: POLICY_DATE_IMPACTED_EVENTCODES[0], + filingDate: '2030-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + isNotServedDocument: false, + rootDocument: { documentType: 'Petition' }, + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2040-05-16T00:00:00.000-04:00', + }, + ); - it('should NOT show a document link for an amended brief entry when the document was not filed by a practitioner on the case', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: { - ...baseDocketEntry, - eventCode: 'AMAT', - filingDate: '2050-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { - docketEntryId: baseDocketEntry.docketEntryId, - documentTitle: 'Seriatim Answering Memorandum Brief', - documentType: 'Seriatim Answering Memorandum Brief', + expect(result.showLinkToDocument).toBe(false); + }); + + it('should NOT show document link for an amended brief when the docket entry was filed before visibility policy date (8/1/2023) by a practitioner on the case', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: 'AMAT', + filingDate: '2020-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + isNotServedDocument: false, + rootDocument: { + docketEntryId: 'e86b58a8-aeb3-460e-af4b-3a31b6bae864', + documentTitle: 'Seriatim Answering Memorandum Brief', + documentType: 'Seriatim Answering Memorandum Brief', + }, + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + ); + + expect(result.showLinkToDocument).toBe(false); }); - expect(result.showLinkToDocument).toBe(false); - }); + it('should show document link for an amended brief when the docket entry was filed after the visibility policy date (8/1/2023) by a practitioner on the case', () => { + const { showLinkToDocument } = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: 'AMAT', + filingDate: '2050-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + rootDocument: { + docketEntryId: 'e86b58a8-aeb3-460e-af4b-3a31b6bae864', + documentTitle: 'Seriatim Answering Memorandum Brief', + documentType: 'Seriatim Answering Memorandum Brief', + }, + servedAt: '2050-05-16T00:00:00.000-04:00', + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + }, + ); - it('should show a document link for an amended amicus brief when the document was filed after the visibility policy date (8/1/2023)', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: { - ...baseDocketEntry, - eventCode: 'AMAT', - filingDate: '2050-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { - docketEntryId: baseDocketEntry.docketEntryId, - documentTitle: 'Amicus Brief', - documentType: 'Amicus Brief', + expect(showLinkToDocument).toBe(true); + }); + + it('should NOT show document link for an amendment docket entry when the previous docket entry is NOT a brief', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + entry: { + ...baseDocketEntry, + eventCode: 'AMAT', + filingDate: '2050-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + isNotServedDocument: false, + rootDocument: { + docketEntryId: baseDocketEntry.docketEntryId, + documentTitle: 'Petition', + documentType: 'Petition', + }, + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + ); + + expect(result.showLinkToDocument).toBe(false); }); - expect(result.showLinkToDocument).toBe(true); - }); + it('should show document link for a Stipulated Decision (SDEC)', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: { + ...stipDecisionDocument, + rootDocument: { documentType: 'Petition' }, + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + }, + ); - it('should show a document link for a redacted amicus brief when the document was filed after the visibility policy date (8/1/2023)', () => { - const result = formatDocketEntryOnDocketRecord(applicationContextPublic, { - docketEntriesEFiledByPractitioner: [], - entry: { - ...baseDocketEntry, - eventCode: 'REDC', - filingDate: '2050-05-16T00:00:00.000-04:00', - isCourtIssuedDocument: false, - isNotServedDocument: false, - rootDocument: { - docketEntryId: baseDocketEntry.docketEntryId, - documentTitle: 'Amicus Brief', - documentType: 'Amicus Brief', + expect(result.showLinkToDocument).toBe(true); + }); + + it('should NOT show a document link for an amended brief entry when the document was not filed by a practitioner on the case', () => { + const result = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: { + ...baseDocketEntry, + eventCode: 'AMAT', + filingDate: '2050-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + isNotServedDocument: false, + rootDocument: { + docketEntryId: baseDocketEntry.docketEntryId, + documentTitle: 'Seriatim Answering Memorandum Brief', + documentType: 'Seriatim Answering Memorandum Brief', + }, + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', }, - }, - isTerminalUser: false, - visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + ); + + expect(result.showLinkToDocument).toBe(false); + }); + + it('should show a document link for an amended amicus brief when the document was filed after the visibility policy date (8/1/2023)', () => { + const { showLinkToDocument } = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: { + ...baseDocketEntry, + eventCode: 'AMAT', + filingDate: '2050-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + rootDocument: { + docketEntryId: baseDocketEntry.docketEntryId, + documentTitle: 'Amicus Brief', + documentType: 'Amicus Brief', + }, + servedAt: '2050-05-16T00:00:00.000-04:00', + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + }, + ); + + expect(showLinkToDocument).toBe(true); }); - expect(result.showLinkToDocument).toBe(true); + it('should show a document link for a redacted amicus brief when the document was filed after the visibility policy date (8/1/2023)', () => { + const { showLinkToDocument } = formatDocketEntryOnDocketRecord( + applicationContextPublic, + { + docketEntriesEFiledByPractitioner: [], + entry: { + ...baseDocketEntry, + eventCode: 'REDC', + filingDate: '2050-05-16T00:00:00.000-04:00', + isCourtIssuedDocument: false, + rootDocument: { + docketEntryId: baseDocketEntry.docketEntryId, + documentTitle: 'Amicus Brief', + documentType: 'Amicus Brief', + }, + servedAt: '2050-05-16T00:00:00.000-04:00', + }, + isTerminalUser: false, + visibilityPolicyDateFormatted: '2023-08-01T00:00:00.000-04:00', + }, + ); + + expect(showLinkToDocument).toBe(true); + }); }); }); - describe('printableDocketRecord', () => { + describe('isCaseSealed', () => {}); + + describe('showPrintableDocketRecord', () => { it('should show printable docket record button if canAllowPrintableDocketRecord is true', () => { const result = runCompute(publicCaseDetailHelper, { state: { @@ -482,839 +1304,9 @@ describe('publicCaseDetailHelper', () => { expect(result.showPrintableDocketRecord).toBeFalsy(); }); }); +}); - describe('formattedDocketEntriesOnDocketRecord', () => { - it('should return the formattedDocketEntriesOnDocketRecord as an array', () => { - const result = runCompute(publicCaseDetailHelper, { state }); - expect( - Array.isArray(result.formattedDocketEntriesOnDocketRecord), - ).toBeTruthy(); - }); - - it('should return hasDocument false if the document is a minute entry', () => { - state.caseDetail.docketEntries = [ - { - description: 'Request for Place of Trial at Flavortown, TN', - documentType: - INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.documentType, - eventCode: INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.eventCode, - isMinuteEntry: true, - isOnDocketRecord: true, - userId: '02323349-87fe-4d29-91fe-8dd6916d2fda', - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - expect(result.formattedDocketEntriesOnDocketRecord[0]).toMatchObject({ - description: 'Request for Place of Trial at Flavortown, TN', - hasDocument: false, - }); - }); - - it('formats descriptionDisplay for `OCS` type documents correctly and makes it visible to public users', () => { - state.caseDetail.docketEntries = [ - { - docketEntryId: 'd-1-2-3', - documentTitle: 'Online Cited Source', - documentType: 'Online Cited Source', - eventCode: 'OCS', - freeText: 'Test site viewed on 09/09/22', - isFileAttached: true, - isOnDocketRecord: true, - isUnservable: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - descriptionDisplay: - 'Test site viewed on 09/09/22 - Online Cited Source', - docketEntryId: 'd-1-2-3', - eventCode: 'OCS', - showLinkToDocument: true, - }, - ]); - }); - - it('should not display a link for the PMT event code', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - documentTitle: 'PRE-TRIAL MEMORANDUM for Resp. (C/S 5-16-13)', - documentType: 'Miscellaneous', - eventCode: 'PMT', - }, - ]; - const result = runCompute(publicCaseDetailHelper, { state }); - - expect( - result.formattedDocketEntriesOnDocketRecord[0].showLinkToDocument, - ).toBeFalsy(); - }); - - it('should not show a link for documents not visible to the public', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', - documentTitle: 'Petition', - documentType: 'Petition', - eventCode: 'P', - index: 1, - isLegacyServed: true, - }, - { - ...baseDocketEntry, - docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', - documentTitle: - 'Request for Place of Trial at San Francisco, California', - documentType: 'Request for Place of Trial', - eventCode: 'RQT', - index: 2, - isLegacyServed: true, - }, - { - ...baseDocketEntry, - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - documentTitle: 'Order of Dismissal and Decision Entered, Judge Buch', - documentType: 'Order of Dismissal and Decision', - eventCode: 'ODD', - index: 3, - isLegacyServed: true, - }, - { - ...baseDocketEntry, - docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', - documentTitle: - 'Notice of Trial on 12/30/2019 at San Francisco, California', - documentType: 'Notice of Trial', - eventCode: 'NTD', - index: 4, - isLegacyServed: true, - }, - { - ...baseDocketEntry, - docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 5, - isLegacyServed: true, - }, - { - ...baseDocketEntry, - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 6, - isFileAttached: false, - isLegacyServed: true, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - descriptionDisplay: 'Petition', - docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', - eventCode: 'P', - index: 1, - showLinkToDocument: false, - }, - { - descriptionDisplay: - 'Request for Place of Trial at San Francisco, California', - docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', - eventCode: 'RQT', - index: 2, - showLinkToDocument: false, - }, - { - descriptionDisplay: - 'Order of Dismissal and Decision Entered, Judge Buch', - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - eventCode: 'ODD', - index: 3, - showLinkToDocument: true, - }, - { - descriptionDisplay: - 'Notice of Trial on 12/30/2019 at San Francisco, California', - docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', - eventCode: 'NTD', // not in EVENT_CODES_VISIBLE_TO_PUBLIC - index: 4, - showLinkToDocument: false, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', - eventCode: 'SPTO', - index: 5, - showLinkToDocument: true, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - eventCode: 'SPTO', - index: 6, - showLinkToDocument: false, - }, - ]); - }); - - it('should not show a link for sealed docket entries requested by a public user', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - documentTitle: 'Order of Dismissal and Decision Entered, Judge Buch', - documentType: 'Order of Dismissal and Decision', - eventCode: 'ODD', - index: 0, - isSealed: true, - servedAt: '2019-12-30T21:00:00.000Z', - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - - expect( - result.formattedDocketEntriesOnDocketRecord[0].showLinkToDocument, - ).toBe(false); - }); - - it('should show a link for documents requested by a terminal user', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', - documentTitle: 'Petition', - documentType: 'Petition', - eventCode: 'P', - index: 1, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - { - ...baseDocketEntry, - docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', - documentTitle: - 'Request for Place of Trial at San Francisco, California', - documentType: 'Request for Place of Trial', - eventCode: 'RQT', - index: 2, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - { - ...baseDocketEntry, - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - documentTitle: 'Order of Dismissal and Decision Entered, Judge Buch', - documentType: 'Order of Dismissal and Decision', - eventCode: 'ODD', - index: 3, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - { - ...baseDocketEntry, - docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', - documentTitle: - 'Notice of Trial on 12/30/2019 at San Francisco, California', - documentType: 'Notice of Trial', - eventCode: 'NTD', - index: 4, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - { - ...baseDocketEntry, - docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 5, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - { - ...baseDocketEntry, - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 6, - isFileAttached: false, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { - state: { ...state, isTerminalUser: true }, - }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - descriptionDisplay: 'Petition', - docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', - eventCode: 'P', - index: 1, - openInSameTab: false, - showLinkToDocument: true, - }, - { - descriptionDisplay: - 'Request for Place of Trial at San Francisco, California', - docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', - eventCode: 'RQT', - index: 2, - openInSameTab: false, - showLinkToDocument: true, - }, - { - descriptionDisplay: - 'Order of Dismissal and Decision Entered, Judge Buch', - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - eventCode: 'ODD', - index: 3, - openInSameTab: false, - showLinkToDocument: true, - }, - { - descriptionDisplay: - 'Notice of Trial on 12/30/2019 at San Francisco, California', - docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', - eventCode: 'NTD', // not in EVENT_CODES_VISIBLE_TO_PUBLIC - index: 4, - openInSameTab: false, - showLinkToDocument: true, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', - eventCode: 'SPTO', - index: 5, - openInSameTab: false, - showLinkToDocument: true, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - eventCode: 'SPTO', - index: 6, - openInSameTab: false, - showLinkToDocument: false, - }, - ]); - }); - - it('should not show a link for documents requested by a public user only', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', - documentTitle: 'Decision Entered, Judge Buch Decision', - documentType: 'Decision', - eventCode: 'DEC', - index: 1, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - { - ...baseDocketEntry, - docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', - documentTitle: - 'Request for Place of Trial at San Francisco, California', - documentType: 'Request for Place of Trial', - eventCode: 'RQT', - index: 2, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - { - ...baseDocketEntry, - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - documentTitle: 'Decision Entered, Judge Buch Another Decision', - documentType: 'Decision', - eventCode: 'DEC', - index: 3, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - { - ...baseDocketEntry, - docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', - documentTitle: - 'Notice of Trial on 12/30/2019 at San Francisco, California', - documentType: 'Notice of Trial', - eventCode: 'NTD', - index: 4, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - { - ...baseDocketEntry, - docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 5, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - { - ...baseDocketEntry, - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 6, - isFileAttached: false, - isLegacyServed: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { - state: { ...state, isTerminalUser: false }, - }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - descriptionDisplay: 'Decision Entered, Judge Buch Decision', - docketEntryId: '596223c1-527b-46b4-98b0-1b10455e9495', - eventCode: 'DEC', - index: 1, - openInSameTab: true, - showLinkToDocument: true, - }, - { - descriptionDisplay: - 'Request for Place of Trial at San Francisco, California', - docketEntryId: 'af6f67db-3160-4562-ac36-5481ab091952', - eventCode: 'RQT', - index: 2, - openInSameTab: true, - showLinkToDocument: false, - }, - { - descriptionDisplay: 'Decision Entered, Judge Buch Another Decision', - docketEntryId: '1f1aa3f7-e2e3-43e6-885d-4ce341588c76', - eventCode: 'DEC', - index: 3, - openInSameTab: true, - showLinkToDocument: false, - }, - { - descriptionDisplay: - 'Notice of Trial on 12/30/2019 at San Francisco, California', - docketEntryId: '162d3c72-2a31-4c66-b3f4-efaceb2cf0fd', - eventCode: 'NTD', // not in EVENT_CODES_VISIBLE_TO_PUBLIC - index: 4, - openInSameTab: true, - showLinkToDocument: false, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: 'a456c942-9d19-491a-b764-e2eac34205b0', - eventCode: 'SPTO', - index: 5, - openInSameTab: true, - showLinkToDocument: true, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - eventCode: 'SPTO', - index: 6, - openInSameTab: true, - showLinkToDocument: false, - }, - ]); - }); - - it('should not show a link for sealed documents requested by a terminal user', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 1, - isFileAttached: false, - isLegacyServed: true, - isSealed: true, - }, - { - ...baseDocketEntry, - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - documentTitle: 'Standing Pretrial Order', - documentType: 'Standing Pretrial Order', - eventCode: 'SPTO', - index: 2, - isFileAttached: false, - isLegacySealed: true, - isLegacyServed: true, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { - state: { ...state, isTerminalUser: true }, - }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - eventCode: 'SPTO', - index: 1, - openInSameTab: false, - showLinkToDocument: false, - }, - { - descriptionDisplay: 'Standing Pretrial Order', - docketEntryId: '71ac5f88-2316-4670-89bd-3decb99cf3ba', - eventCode: 'SPTO', - index: 2, - openInSameTab: false, - showLinkToDocument: false, - }, - ]); - }); - }); - - describe('docket record filtering', () => { - const caseDetail = { - docketEntries: [ - { - ...baseDocketEntry, - docketEntryId: '402ccc12-72c0-481e-b3f2-44debcd167a4', - documentTitle: 'Exhibit for Noodles', - eventCode: 'EXH', - }, - { - ...baseDocketEntry, - docketEntryId: '402ccc12-72c0-481e-b3f2-44debcd167a4', - documentTitle: 'Order in the Court', - eventCode: 'O', - }, - { - ...baseDocketEntry, - docketEntryId: '402ccc12-72c0-481e-b3f2-44debcd167a4', - documentTitle: 'Motion in the Ocean', - eventCode: 'M000', - }, - ], - }; - - it('should ONLY show order type docket entries when "Orders" has been selected as the filter', () => { - const result = runCompute(publicCaseDetailHelper, { - state: { - caseDetail, - sessionMetadata: { - docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.orders, - }, - }, - }); - - expect(result.formattedDocketEntriesOnDocketRecord.length).toBe(1); - expect(result.formattedDocketEntriesOnDocketRecord[0].eventCode).toBe( - 'O', - ); - }); - - it('should ONLY show motion type docket entries when "Motions" has been selected as the filter', () => { - const result = runCompute(publicCaseDetailHelper, { - state: { - caseDetail, - sessionMetadata: { - docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.motions, - }, - }, - }); - - expect(result.formattedDocketEntriesOnDocketRecord.length).toBe(1); - expect(result.formattedDocketEntriesOnDocketRecord[0].eventCode).toBe( - 'M000', - ); - }); - - it('should show all docket entries when "All documents" has been selected as the filter', () => { - const result = runCompute(publicCaseDetailHelper, { - state: { - caseDetail, - sessionMetadata: { - docketRecordFilter: - PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments, - }, - }, - }); - - expect(result.formattedDocketEntriesOnDocketRecord.length).toBe( - caseDetail.docketEntries.length, - ); - }); - }); - - it('should indicate when a case is sealed', () => { - state.caseDetail.isSealed = true; - const result = runCompute(publicCaseDetailHelper, { state }); - expect(result.formattedCaseDetail.isCaseSealed).toBeTruthy(); - }); - - it('should return formatted docket entry', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - action: 'something', - attachments: true, - createdAt: '2018-11-21T20:49:28.192Z', - description: 'first record', - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - documentTitle: 'Petition', - documentType: 'Petition', - eventCode: 'P', - filingDate: '2018-11-21T20:49:28.192Z', - index: 4, - openInSameTab: true, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - servedPartiesCode: PARTIES_CODES.RESPONDENT, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - action: 'something', - createdAtFormatted: '11/21/18', - description: 'first record', - descriptionDisplay: 'Petition (Attachment(s))', - docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', - eventCode: 'P', - index: 4, - servedPartiesCode: PARTIES_CODES.RESPONDENT, - showDocumentDescriptionWithoutLink: true, - showLinkToDocument: false, - showNotServed: true, - showServed: false, - }, - ]); - }); - - it('should sort docket entries chronologically by date', () => { - state.caseDetail.docketEntries = [ - { - ...baseDocketEntry, - createdAt: '2018-11-21T20:49:28.192Z', - filingDate: '2018-11-21T20:49:28.192Z', - index: 4, - }, - { - ...baseDocketEntry, - createdAt: '2018-10-21T20:49:28.192Z', - filingDate: '2018-10-21T20:49:28.192Z', - index: 1, - }, - { - ...baseDocketEntry, - createdAt: '2018-10-25T20:49:28.192Z', - filingDate: '2018-10-25T20:49:28.192Z', - index: 3, - }, - { - ...baseDocketEntry, - createdAt: '2018-10-25T20:49:28.192Z', - eventCode: 'O', - filingDate: '2018-10-25T20:49:28.192Z', - index: 2, - processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, - }, - { - ...baseDocketEntry, - createdAt: '2018-12-25T20:49:28.192Z', - filingDate: '2018-12-25T20:49:28.192Z', - index: 5, - }, - { - ...baseDocketEntry, - createdAt: '2018-12-25T20:49:28.192Z', - filingDate: '2018-12-25T20:49:28.192Z', - index: 6, - }, - { - ...baseDocketEntry, - createdAt: '2019-12-24T20:49:28.192Z', - filingDate: '2019-12-24T20:49:28.192Z', - index: 7, - }, - { - ...baseDocketEntry, - createdAt: '2019-12-24T20:49:28.192Z', - filingDate: '2019-12-24T20:49:28.192Z', - index: 8, - }, - { - ...baseDocketEntry, - createdAt: '2019-12-25T20:49:28.192Z', - filingDate: '2019-12-25T20:49:28.192Z', - index: 9, - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - - expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ - { - createdAtFormatted: '10/21/18', - index: 1, - }, - { - createdAtFormatted: '10/25/18', - index: 3, - }, - { - createdAtFormatted: '11/21/18', - index: 4, - }, - { - createdAtFormatted: '12/25/18', - index: 5, - }, - { - createdAtFormatted: '12/25/18', - index: 6, - }, - { - createdAtFormatted: '12/24/19', - index: 7, - }, - { - createdAtFormatted: '12/24/19', - index: 8, - }, - { - createdAtFormatted: '12/25/19', - index: 9, - }, - { - index: 2, - }, - ]); - }); - - describe('Root Previous Documents', () => { - it('should show a link when the current document is a multi level ammendment whose root document is a brief', () => { - state.caseDetail.docketEntriesEFiledByPractitioner = [ - '6d83425c-8ef3-4c66-b776-6c7957c53f4d', - '4796a931-14fb-43e6-948f-d2b67ce4c1cb', - '8e3ae16b-dc29-433f-878a-7a0534c39919', - 'ea55927d-f61a-4657-b828-3b8a9d9b9b70', - 'b22fd1a0-56cb-4873-bb4f-50df3a65da3f', - ]; - state.caseDetail.docketEntries = [ - { - attachments: false, - certificateOfService: false, - certificateOfServiceDate: null, - docketEntryId: 'b22fd1a0-56cb-4873-bb4f-50df3a65da3f', - docketNumber: '103-20', - documentTitle: - 'Redacted First Supplement to Seriatim Answering Brief', - documentType: 'Redacted', - entityName: 'PublicDocketEntry', - eventCode: 'REDC', - filedBy: 'Petr. Reuben Blair', - filingDate: '2024-07-26T15:27:03.890Z', - index: 9, - isFileAttached: true, - isMinuteEntry: false, - isOnDocketRecord: true, - isSealed: false, - isStricken: false, - numberOfPages: 2, - previousDocument: { - docketEntryId: 'ea55927d-f61a-4657-b828-3b8a9d9b9b70', - documentTitle: 'First Supplement to Seriatim Answering Brief', - documentType: 'Supplement', - }, - processingStatus: 'complete', - receivedAt: '2023-07-26T04:00:00.000Z', - servedAt: '2023-07-26T15:27:03.893Z', - servedPartiesCode: 'B', - }, - { - attachments: false, - certificateOfService: false, - certificateOfServiceDate: null, - docketEntryId: 'ea55927d-f61a-4657-b828-3b8a9d9b9b70', - docketNumber: '103-20', - documentTitle: 'First Supplement to Seriatim Answering Brief', - documentType: 'Supplement', - entityName: 'PublicDocketEntry', - eventCode: 'SUPM', - filedBy: 'Petr. Reuben Blair', - filingDate: '2024-07-26T15:26:33.586Z', - index: 8, - isFileAttached: true, - isMinuteEntry: false, - isOnDocketRecord: true, - isSealed: false, - isStricken: false, - numberOfPages: 2, - previousDocument: { - docketEntryId: '8e3ae16b-dc29-433f-878a-7a0534c39919', - documentTitle: 'Seriatim Answering Brief', - documentType: 'Seriatim Answering Brief', - }, - processingStatus: 'complete', - receivedAt: '2023-07-26T04:00:00.000Z', - servedAt: '2023-07-26T15:26:33.591Z', - servedPartiesCode: 'B', - }, - { - attachments: false, - certificateOfService: false, - certificateOfServiceDate: null, - docketEntryId: '8e3ae16b-dc29-433f-878a-7a0534c39919', - docketNumber: '103-20', - documentTitle: 'Seriatim Answering Brief', - documentType: 'Seriatim Answering Brief', - entityName: 'PublicDocketEntry', - eventCode: 'SEAB', - filedBy: 'Petr. Reuben Blair', - filingDate: '2024-07-26T15:25:33.548Z', - index: 7, - isFileAttached: true, - isMinuteEntry: false, - isOnDocketRecord: true, - isSealed: false, - isStricken: false, - numberOfPages: 2, - processingStatus: 'complete', - receivedAt: '2023-07-26T04:00:00.000Z', - servedAt: '2023-07-26T15:25:33.550Z', - servedPartiesCode: 'B', - }, - ]; - - const result = runCompute(publicCaseDetailHelper, { state }); - - expect( - result.formattedDocketEntriesOnDocketRecord[0].showLinkToDocument, - ).toEqual(true); - }); - }); -}); - -describe('recursivelySetNestedPreviousDocuments', () => { +describe('fetchRootDocument', () => { it('should set up all the previous documents for the docket entry passed in', () => { const theDocketEntry: any = { docketEntryId: '1', @@ -1379,3 +1371,83 @@ describe('recursivelySetNestedPreviousDocuments', () => { // expect(docketEntry).toEqual(undefined); // }); }); + +describe('formatDocketEntryOnDocketRecord', () => { + let state; + + const publicCaseDetailHelper = withAppContextDecorator( + publicCaseDetailHelperComputed, + applicationContextPublic, + ); + + const baseDocketEntry = { + docketEntryId: 'ae454c18-be84-4a2b-b055-9046ada4f65d', + documentTitle: 'PRE-TRIAL MEMORANDUM for Resp. (C/S 5-16-13)', + documentType: 'Miscellaneous', + eventCode: 'PMT', + filedBy: 'See Filings and Proceedings', + filingDate: '2013-05-16T00:00:00.000-04:00', + index: 14, + isFileAttached: true, + isMinuteEntry: false, + isOnDocketRecord: true, + isSealed: false, + isStricken: false, + numberOfPages: 5, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE, + receivedAt: '2013-05-16T00:00:00.000-04:00', + }; + + beforeEach(() => { + state = { + caseDetail: { + docketEntries: [], + docketEntriesEFiledByPractitioner: [baseDocketEntry.docketEntryId], + docketNumber: '123-45', + }, + sessionMetadata: { + docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments, + }, + }; + }); + + it('should return formatted docket entry', () => { + state.caseDetail.docketEntries = [ + { + ...baseDocketEntry, + action: 'something', + attachments: true, + createdAt: '2018-11-21T20:49:28.192Z', + description: 'first record', + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + documentTitle: 'Petition', + documentType: 'Petition', + eventCode: 'P', + filingDate: '2018-11-21T20:49:28.192Z', + index: 4, + openInSameTab: true, + processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.PENDING, + servedPartiesCode: PARTIES_CODES.RESPONDENT, + }, + ]; + + const result = runCompute(publicCaseDetailHelper, { state }); + + expect(result.formattedDocketEntriesOnDocketRecord).toMatchObject([ + { + action: 'something', + createdAtFormatted: '11/21/18', + description: 'first record', + descriptionDisplay: 'Petition (Attachment(s))', + docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', + eventCode: 'P', + index: 4, + servedPartiesCode: PARTIES_CODES.RESPONDENT, + showDocumentDescriptionWithoutLink: true, + showLinkToDocument: false, + showNotServed: true, + showServed: false, + }, + ]); + }); +}); diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 51c6142e51c..8c96c4579b4 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -7,14 +7,16 @@ import { MOTION_EVENT_CODES, ORDER_EVENT_CODES, POLICY_DATE_IMPACTED_EVENTCODES, + PUBLIC_DOCKET_RECORD_FILTER, PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, isDocumentBriefType, } from '../../../../../shared/src/business/entities/EntityConstants'; import { ClientApplicationContext } from '@web-client/applicationContext'; +import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; import { Get } from 'cerebral'; import { state } from '@web-client/presenter/app.cerebral'; -const getMeetsPolicyChangeRequirements = ( +export const getMeetsPolicyChangeRequirements = ( entry: RawDocketEntry & { rootDocument: RawDocketEntry }, visibilityPolicyDateFormatted: string, docketEntriesEFiledByPractitioner: string[], @@ -83,7 +85,8 @@ export const formatDocketEntryOnDocketRecord = ( visibilityPolicyDateFormatted: string; // ISO Date String }, ) => { - const isServed = !entry.isNotServedDocument; + const isServed = + DocketEntry.isServed(entry) || DocketEntry.isUnservable(entry); const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( entry, @@ -143,74 +146,79 @@ export const formatDocketEntryOnDocketRecord = ( }; }; +const filterDocketEntries = ( + docketEntries: any[], + filter: PUBLIC_DOCKET_RECORD_FILTER, +) => { + switch (filter) { + case PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.motions: + return docketEntries.filter(entry => + MOTION_EVENT_CODES.includes(entry.eventCode), + ); + case PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.orders: + return docketEntries.filter(entry => + ORDER_EVENT_CODES.includes(entry.eventCode), + ); + case PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments: + default: + return docketEntries; + } +}; + export const publicCaseDetailHelper = ( get: Get, applicationContext: ClientApplicationContext, ) => { - const publicCase = get(state.caseDetail); - const isTerminalUser = get(state.isTerminalUser); - const { docketRecordFilter } = get(state.sessionMetadata); - - const formatCaseDetail = caseToFormat => ({ - ...caseToFormat, - isCaseSealed: !!caseToFormat.isSealed, - }); + const { + canAllowPrintableDocketRecord, + docketEntries, + docketEntriesEFiledByPractitioner, + isSealed, + } = get(state.caseDetail); - const formattedDocketRecordsWithDocuments = publicCase.docketEntries.map(d => - applicationContext.getUtilities().formatDocketEntry(applicationContext, d), - ); + const isTerminalUser = get(state.isTerminalUser); - const sortedFormattedDocketRecords = applicationContext - .getUtilities() - .sortDocketEntries(formattedDocketRecordsWithDocuments, 'byDate'); + const { docketRecordFilter } = get(state.sessionMetadata); const DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE = get( state.featureFlags[ ALLOWLIST_FEATURE_FLAGS.DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE.key ], ); - const visibilityPolicyDateFormatted = applicationContext .getUtilities() .prepareDateFromString(DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE) .toISO(); + const formattedDocketRecordsWithDocuments = docketEntries.map(d => + applicationContext.getUtilities().formatDocketEntry(applicationContext, d), + ); + + const sortedFormattedDocketRecords = applicationContext + .getUtilities() + .sortDocketEntries(formattedDocketRecordsWithDocuments, 'byDate'); + let formattedDocketEntriesOnDocketRecord = sortedFormattedDocketRecords .map((entry: any, _, array) => { return { ...entry, rootDocument: fetchRootDocument(entry, array) }; }) .map(entry => { return formatDocketEntryOnDocketRecord(applicationContext, { - docketEntriesEFiledByPractitioner: - publicCase.docketEntriesEFiledByPractitioner, + docketEntriesEFiledByPractitioner, entry, isTerminalUser, visibilityPolicyDateFormatted, }); }); - if (docketRecordFilter === PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.orders) { - formattedDocketEntriesOnDocketRecord = - formattedDocketEntriesOnDocketRecord.filter(entry => - ORDER_EVENT_CODES.includes(entry.eventCode), - ); - } else if ( - docketRecordFilter === PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.motions - ) { - formattedDocketEntriesOnDocketRecord = - formattedDocketEntriesOnDocketRecord.filter(entry => - MOTION_EVENT_CODES.includes(entry.eventCode), - ); - } - - const formattedCaseDetail = formatCaseDetail(publicCase); - - const showPrintableDocketRecord = - formattedCaseDetail.canAllowPrintableDocketRecord; + formattedDocketEntriesOnDocketRecord = filterDocketEntries( + formattedDocketEntriesOnDocketRecord, + docketRecordFilter, + ); return { - formattedCaseDetail, formattedDocketEntriesOnDocketRecord, - showPrintableDocketRecord, + isCaseSealed: !!isSealed, + showPrintableDocketRecord: canAllowPrintableDocketRecord, }; }; diff --git a/web-client/src/presenter/computeds/formattedDocketEntries.ts b/web-client/src/presenter/computeds/formattedDocketEntries.ts index f9df31fe9b9..7fd8ed2a0c6 100644 --- a/web-client/src/presenter/computeds/formattedDocketEntries.ts +++ b/web-client/src/presenter/computeds/formattedDocketEntries.ts @@ -2,12 +2,11 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { DocketEntry } from '../../../../shared/src/business/entities/DocketEntry'; import { Get } from 'cerebral'; -import { - POLICY_DATE_IMPACTED_EVENTCODES, - isDocumentBriefType, -} from '../../../../shared/src/business/entities/EntityConstants'; import { documentMeetsAgeRequirements } from '../../../../shared/src/business/utilities/getFormattedCaseDetail'; -import { fetchRootDocument } from './Public/publicCaseDetailHelper'; +import { + fetchRootDocument, + getMeetsPolicyChangeRequirements, +} from './Public/publicCaseDetailHelper'; import { state } from '@web-client/presenter/app.cerebral'; export const setupIconsToDisplay = ({ formattedResult, isExternalUser }) => { @@ -141,14 +140,13 @@ export const getFormattedDocketEntry = ({ applicationContext, docketNumber, entry, - filedAfterPolicyChange, formattedCase, isExternalUser, permissions, userAssociatedWithCase, + visibilityPolicyDateFormatted, }) => { const { - BRIEF_EVENTCODES, DOCKET_ENTRY_SEALED_TO_TYPES, DOCUMENT_PROCESSING_STATUS_OPTIONS, EVENT_CODES_VISIBLE_TO_PUBLIC, @@ -200,48 +198,12 @@ export const getFormattedDocketEntry = ({ .map(k => INITIAL_DOCUMENT_TYPES[k].documentType) .includes(entry.documentType); - let filedByPractitioner = false; - let meetsPolicyChangeRequirements = false; - - const isAmendment = ['AMAT', 'ADMT', 'REDC', 'SPML', 'SUPM'].includes( - entry.eventCode, + const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( + entry, + visibilityPolicyDateFormatted, + formattedCase.docketEntriesEFiledByPractitioner, ); - if (POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { - let isDocketEntryBriefEventCode; - const docType = entry.rootDocument.documentType; - - if (isAmendment) { - isDocketEntryBriefEventCode = isDocumentBriefType(docType); - - if (isDocketEntryBriefEventCode) { - filedByPractitioner = - formattedCase.docketEntriesEFiledByPractitioner.includes( - entry.docketEntryId, - ); - meetsPolicyChangeRequirements = - filedAfterPolicyChange && filedByPractitioner; - } else if (docType === 'Amicus Brief') { - meetsPolicyChangeRequirements = filedAfterPolicyChange; - } else { - meetsPolicyChangeRequirements = false; - } - } else { - isDocketEntryBriefEventCode = BRIEF_EVENTCODES.includes(entry.eventCode); - - if (isDocketEntryBriefEventCode) { - filedByPractitioner = - formattedCase.docketEntriesEFiledByPractitioner.includes( - entry.docketEntryId, - ); - meetsPolicyChangeRequirements = - filedAfterPolicyChange && filedByPractitioner; - } else { - meetsPolicyChangeRequirements = filedAfterPolicyChange; - } - } - } - showDocumentLinks = getShowDocumentViewerLink({ hasDocument: entry.isFileAttached, isCourtIssuedDocument: entry.isCourtIssuedDocument, @@ -374,18 +336,15 @@ export const formattedDocketEntries = ( return { ...entry, rootDocument: fetchRootDocument(entry, array) }; }) .map(entry => { - const filedAfterPolicyChange = - entry.filingDate >= visibilityPolicyDateFormatted; - return getFormattedDocketEntry({ applicationContext, docketNumber, entry, - filedAfterPolicyChange, formattedCase: result, isExternalUser, permissions, userAssociatedWithCase, + visibilityPolicyDateFormatted, }); }); diff --git a/web-client/src/views/Public/PublicCaseDetail.tsx b/web-client/src/views/Public/PublicCaseDetail.tsx index b1fe0be746f..a3ea8cfe92f 100644 --- a/web-client/src/views/Public/PublicCaseDetail.tsx +++ b/web-client/src/views/Public/PublicCaseDetail.tsx @@ -7,13 +7,13 @@ import React from 'react'; export const PublicCaseDetail = connect( { - formattedCaseDetail: state.publicCaseDetailHelper.formattedCaseDetail, + isCaseSealed: state.publicCaseDetailHelper.isCaseSealed, }, - function PublicCaseDetail({ formattedCaseDetail }) { + function PublicCaseDetail({ isCaseSealed }) { return ( <> - {!formattedCaseDetail.isCaseSealed && ( + {!isCaseSealed && ( <>
@@ -22,7 +22,7 @@ export const PublicCaseDetail = connect( )} - {formattedCaseDetail.isCaseSealed && ( + {isCaseSealed && ( <>

From 6f0015724ea551ffe51caaf80e69bb4da7155022 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 28 Jul 2023 15:00:29 -0700 Subject: [PATCH 05/14] 10076: Helper no longer exports this unneeded property, remove from test --- .../journey/unauthedUserViewsCaseDetail.ts | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.ts b/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.ts index 7529d84d531..a558cc3ca47 100644 --- a/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.ts +++ b/web-client/integration-tests-public/journey/unauthedUserViewsCaseDetail.ts @@ -9,7 +9,6 @@ export const unauthedUserViewsCaseDetail = cerebralTest => { publicCaseDetailHelperComputed, applicationContextPublic, ); - const { INITIAL_DOCUMENT_TYPES } = applicationContextPublic.getConstants(); return it('View case detail', async () => { await cerebralTest.runSequence('gotoPublicCaseDetailSequence', { @@ -88,29 +87,5 @@ export const unauthedUserViewsCaseDetail = cerebralTest => { }), ]), ); - - expect(helper.formattedCaseDetail.docketEntries.length).toEqual(7); - expect(helper.formattedCaseDetail.docketEntries).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - documentType: 'Petition', - }), - expect.objectContaining({ - documentType: 'Motion', - }), - expect.objectContaining({ - documentType: - INITIAL_DOCUMENT_TYPES.requestForPlaceOfTrial.documentType, - }), - expect.objectContaining({ - documentType: 'Notice of Receipt of Petition', - }), - expect.objectContaining({ - documentType: 'Order of Dismissal', - }), - expect.objectContaining({ documentType: 'Transcript' }), - expect.objectContaining({ documentType: 'Stipulated Decision' }), - ]), - ); }); }; From 6adf96f47e1a63898b1816ae497af85485cc6eca Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Fri, 28 Jul 2023 15:52:11 -0700 Subject: [PATCH 06/14] 10076: More cleanup and readability refactoring --- .../Public/publicCaseDetailHelper.test.ts | 3 +- .../Public/publicCaseDetailHelper.ts | 72 ++++++++++++------- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts index ef1b28d7797..baa9b37d8fd 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts @@ -244,6 +244,7 @@ describe('publicCaseDetailHelper', () => { index: 9, }, { + createdAtFormatted: undefined, index: 2, }, ]); @@ -1438,7 +1439,7 @@ describe('formatDocketEntryOnDocketRecord', () => { action: 'something', createdAtFormatted: '11/21/18', description: 'first record', - descriptionDisplay: 'Petition (Attachment(s))', + descriptionDisplay: 'Petition', docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', eventCode: 'P', index: 4, diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 8c96c4579b4..3ebadc03a6d 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -2,6 +2,7 @@ import { ALLOWLIST_FEATURE_FLAGS, BRIEF_EVENTCODES, + COURT_ISSUED_EVENT_CODES, DOCUMENT_PROCESSING_STATUS_OPTIONS, EVENT_CODES_VISIBLE_TO_PUBLIC, MOTION_EVENT_CODES, @@ -9,22 +10,27 @@ import { POLICY_DATE_IMPACTED_EVENTCODES, PUBLIC_DOCKET_RECORD_FILTER, PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, + STIPULATED_DECISION_EVENT_CODE, isDocumentBriefType, } from '../../../../../shared/src/business/entities/EntityConstants'; import { ClientApplicationContext } from '@web-client/applicationContext'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; import { Get } from 'cerebral'; +import { prepareDateFromString } from '../../../../../shared/src/business/utilities/DateHandler'; import { state } from '@web-client/presenter/app.cerebral'; export const getMeetsPolicyChangeRequirements = ( entry: RawDocketEntry & { rootDocument: RawDocketEntry }, - visibilityPolicyDateFormatted: string, + visibilityPolicyDate: string, docketEntriesEFiledByPractitioner: string[], ) => { if (!POLICY_DATE_IMPACTED_EVENTCODES.includes(entry.eventCode)) { return false; } + const visibilityPolicyDateFormatted = + prepareDateFromString(visibilityPolicyDate).toISO(); + const filedByPractitioner = docketEntriesEFiledByPractitioner.includes( entry.docketEntryId, ); @@ -77,20 +83,44 @@ export const formatDocketEntryOnDocketRecord = ( docketEntriesEFiledByPractitioner, entry, isTerminalUser, - visibilityPolicyDateFormatted, + visibilityPolicyDate, }: { docketEntriesEFiledByPractitioner: string[]; entry: any & { rootDocument: any }; isTerminalUser: boolean; - visibilityPolicyDateFormatted: string; // ISO Date String + visibilityPolicyDate: string; // ISO Date String }, ) => { const isServed = DocketEntry.isServed(entry) || DocketEntry.isUnservable(entry); + /// + const isCourtIssuedDocument = !!COURT_ISSUED_EVENT_CODES.map( + ({ eventCode }) => eventCode, + ).includes(entry.eventCode); + + let createdAtFormatted; + if ( + isCourtIssuedDocument && + !DocketEntry.isServed(entry) && + !DocketEntry.isUnservable(entry) && + entry.isOnDocketRecord + ) { + entry.createdAtFormatted = undefined; + } else if (entry.isOnDocketRecord) { + createdAtFormatted = applicationContext + .getUtilities() + .formatDateString(entry.filingDate, 'MMDDYY'); + } else { + createdAtFormatted = applicationContext + .getUtilities() + .formatDateString(entry.createdAt, 'MMDDYY'); + } + /// + const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( entry, - visibilityPolicyDateFormatted, + visibilityPolicyDate, docketEntriesEFiledByPractitioner, ); @@ -98,7 +128,8 @@ export const formatDocketEntryOnDocketRecord = ( entry.isFileAttached && isServed && !entry.isSealed && !entry.isStricken; const canPublicUserSeeLink = - ((entry.isCourtIssuedDocument && !entry.isStipDecision) || + ((isCourtIssuedDocument && + entry.eventCode !== STIPULATED_DECISION_EVENT_CODE) || meetsPolicyChangeRequirements) && entry.isFileAttached && isServed && @@ -120,7 +151,7 @@ export const formatDocketEntryOnDocketRecord = ( return { action: entry.action, - createdAtFormatted: entry.createdAtFormatted, + createdAtFormatted, description: entry.description, descriptionDisplay: applicationContext .getUtilities() @@ -128,6 +159,7 @@ export const formatDocketEntryOnDocketRecord = ( docketEntryId: entry.docketEntryId, eventCode: entry.eventCode, filedBy: entry.filedBy, + filingDate: entry.filingDate, hasDocument: !entry.isMinuteEntry, index: entry.index, isPaper: entry.isPaper, @@ -140,8 +172,8 @@ export const formatDocketEntryOnDocketRecord = ( servedPartiesCode: entry.servedPartiesCode, showDocumentDescriptionWithoutLink: !showLinkToDocument, showLinkToDocument, - showNotServed: entry.isNotServedDocument, - showServed: entry.isStatusServed, + showNotServed: !DocketEntry.isServed(entry), + showServed: DocketEntry.isServed(entry), signatory: entry.signatory, }; }; @@ -180,25 +212,13 @@ export const publicCaseDetailHelper = ( const { docketRecordFilter } = get(state.sessionMetadata); - const DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE = get( + const visibilityPolicyDate = get( state.featureFlags[ ALLOWLIST_FEATURE_FLAGS.DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE.key ], ); - const visibilityPolicyDateFormatted = applicationContext - .getUtilities() - .prepareDateFromString(DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE) - .toISO(); - - const formattedDocketRecordsWithDocuments = docketEntries.map(d => - applicationContext.getUtilities().formatDocketEntry(applicationContext, d), - ); - const sortedFormattedDocketRecords = applicationContext - .getUtilities() - .sortDocketEntries(formattedDocketRecordsWithDocuments, 'byDate'); - - let formattedDocketEntriesOnDocketRecord = sortedFormattedDocketRecords + let formattedDocketEntriesOnDocketRecord = docketEntries .map((entry: any, _, array) => { return { ...entry, rootDocument: fetchRootDocument(entry, array) }; }) @@ -207,12 +227,16 @@ export const publicCaseDetailHelper = ( docketEntriesEFiledByPractitioner, entry, isTerminalUser, - visibilityPolicyDateFormatted, + visibilityPolicyDate, }); }); + const sortedFormattedDocketRecords = applicationContext + .getUtilities() + .sortDocketEntries(formattedDocketEntriesOnDocketRecord as any, 'byDate'); + formattedDocketEntriesOnDocketRecord = filterDocketEntries( - formattedDocketEntriesOnDocketRecord, + sortedFormattedDocketRecords, docketRecordFilter, ); From b05e850b0fc7e17f698fb34e7b50bb088b57faef Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 08:35:31 -0700 Subject: [PATCH 07/14] 10076: Set event code to MISCL when document has been lodged --- .../src/presenter/computeds/Public/publicCaseDetailHelper.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 3ebadc03a6d..cb2044880c3 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -116,6 +116,10 @@ export const formatDocketEntryOnDocketRecord = ( .getUtilities() .formatDateString(entry.createdAt, 'MMDDYY'); } + + if (entry.lodged) { + entry.eventCode = 'MISCL'; + } /// const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( From e12b2caab14758a8b7e0ab979e7df433eab0ad7f Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 09:53:48 -0700 Subject: [PATCH 08/14] 10076 - Call DocketEntry method --- shared/src/business/entities/DocketEntry.ts | 4 ---- .../computeds/Public/publicCaseDetailHelper.ts | 11 +++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index 664a52c1091..ba3a355848b 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -440,10 +440,6 @@ export class DocketEntry extends JoiValidationEntity { ); } - /** - * Determines if the docket entry is a court issued document - * @returns {Boolean} true if the docket entry is a court issued document, false otherwise - */ isCourtIssued() { return DocketEntry.isCourtIssued(this.eventCode); } diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index cb2044880c3..8b894e5f9db 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -2,7 +2,6 @@ import { ALLOWLIST_FEATURE_FLAGS, BRIEF_EVENTCODES, - COURT_ISSUED_EVENT_CODES, DOCUMENT_PROCESSING_STATUS_OPTIONS, EVENT_CODES_VISIBLE_TO_PUBLIC, MOTION_EVENT_CODES, @@ -94,14 +93,11 @@ export const formatDocketEntryOnDocketRecord = ( const isServed = DocketEntry.isServed(entry) || DocketEntry.isUnservable(entry); - /// - const isCourtIssuedDocument = !!COURT_ISSUED_EVENT_CODES.map( - ({ eventCode }) => eventCode, - ).includes(entry.eventCode); + const isCourtIssued = DocketEntry.isCourtIssued(entry.eventCode); let createdAtFormatted; if ( - isCourtIssuedDocument && + isCourtIssued && !DocketEntry.isServed(entry) && !DocketEntry.isUnservable(entry) && entry.isOnDocketRecord @@ -132,8 +128,7 @@ export const formatDocketEntryOnDocketRecord = ( entry.isFileAttached && isServed && !entry.isSealed && !entry.isStricken; const canPublicUserSeeLink = - ((isCourtIssuedDocument && - entry.eventCode !== STIPULATED_DECISION_EVENT_CODE) || + ((isCourtIssued && entry.eventCode !== STIPULATED_DECISION_EVENT_CODE) || meetsPolicyChangeRequirements) && entry.isFileAttached && isServed && From 16cd4173fff4481edb8459e972b4b68efe439c51 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 10:11:49 -0700 Subject: [PATCH 09/14] 10076 - add unit tests --- .eslintrc.js | 1 + .../DocketEntry.isMinuteEntry.test.ts | 23 +++++++++++++ .../entities/DocketEntry.isUnservable.test.ts | 32 +++++++++++++++++++ shared/src/business/entities/DocketEntry.ts | 2 +- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts create mode 100644 shared/src/business/entities/DocketEntry.isUnservable.test.ts diff --git a/.eslintrc.js b/.eslintrc.js index 12f2ae2b49a..eb46d99b665 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -356,6 +356,7 @@ module.exports = { 'semibold', 'seriatim', 'serverless', + 'servable', 'servoss', 'sisqo', 'skipnav', diff --git a/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts b/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts new file mode 100644 index 00000000000..6944a577fb6 --- /dev/null +++ b/shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts @@ -0,0 +1,23 @@ +import { DocketEntry } from './DocketEntry'; +import { MINUTE_ENTRIES_MAP } from './EntityConstants'; +import { applicationContext } from '../test/createTestApplicationContext'; + +describe('isMinuteEntry', () => { + it('should return true when the docketEntry eventCode is in the list of minute entries', () => { + const minuteEntry = new DocketEntry( + { eventCode: MINUTE_ENTRIES_MAP.captionOfCaseIsAmended.eventCode }, + { applicationContext }, + ); + + expect(DocketEntry.isMinuteEntry(minuteEntry)).toBe(true); + }); + + it('should return false when the docketEntry eventCode is NOT in the list of minute entries', () => { + const orderDocketEntry = new DocketEntry( + { eventCode: 'O' }, // O is the event code for orders, they are NOT minute entries + { applicationContext }, + ); + + expect(DocketEntry.isMinuteEntry(orderDocketEntry)).toBe(false); + }); +}); diff --git a/shared/src/business/entities/DocketEntry.isUnservable.test.ts b/shared/src/business/entities/DocketEntry.isUnservable.test.ts new file mode 100644 index 00000000000..56a86a89a4a --- /dev/null +++ b/shared/src/business/entities/DocketEntry.isUnservable.test.ts @@ -0,0 +1,32 @@ +import { DocketEntry } from './DocketEntry'; +import { MINUTE_ENTRIES_MAP, UNSERVABLE_EVENT_CODES } from './EntityConstants'; +import { applicationContext } from '../test/createTestApplicationContext'; + +describe('isUnservable', () => { + it('should return true when the docketEntry eventCode is in the list of minute entries', () => { + const minuteEntry = new DocketEntry( + { eventCode: MINUTE_ENTRIES_MAP.captionOfCaseIsAmended.eventCode }, + { applicationContext }, + ); + + expect(DocketEntry.isUnservable(minuteEntry)).toBe(true); + }); + + it('should return true when the docketEntry event code is in the list of unservable event codes', () => { + const unservableDocketEntry = new DocketEntry( + { eventCode: UNSERVABLE_EVENT_CODES[0] }, + { applicationContext }, + ); + + expect(DocketEntry.isUnservable(unservableDocketEntry)).toBe(true); + }); + + it('should return false when the docketEntry event code is NOT in the list of unservable event codes and it is NOT a minute entry', () => { + const servableDocketEntry = new DocketEntry( + { eventCode: 'O' }, // O is the Order event code, Orders are servable and NOT minute entries + { applicationContext }, + ); + + expect(DocketEntry.isUnservable(servableDocketEntry)).toBe(false); + }); +}); diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index ba3a355848b..ff0ee458820 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -440,7 +440,7 @@ export class DocketEntry extends JoiValidationEntity { ); } - isCourtIssued() { + isCourtIssued(): boolean { return DocketEntry.isCourtIssued(this.eventCode); } From ccf3d1be93840627f98bea2b97327ad29b4baf60 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 10:30:30 -0700 Subject: [PATCH 10/14] 10076: Set filings and proceedings correctly for public docket entries --- .../src/presenter/computeds/Public/publicCaseDetailHelper.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 8b894e5f9db..6daad5decff 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -15,6 +15,7 @@ import { import { ClientApplicationContext } from '@web-client/applicationContext'; import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry'; import { Get } from 'cerebral'; +import { getFilingsAndProceedings } from '../../../../../shared/src/business/utilities/getFormattedCaseDetail'; import { prepareDateFromString } from '../../../../../shared/src/business/utilities/DateHandler'; import { state } from '@web-client/presenter/app.cerebral'; @@ -116,6 +117,8 @@ export const formatDocketEntryOnDocketRecord = ( if (entry.lodged) { entry.eventCode = 'MISCL'; } + + entry.filingsAndProceedings = getFilingsAndProceedings(entry); /// const meetsPolicyChangeRequirements = getMeetsPolicyChangeRequirements( From 59027a317e9725824c5e19abfba5fc86d331309d Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 11:52:11 -0700 Subject: [PATCH 11/14] 10076 - fix test --- .../presenter/computeds/Public/publicCaseDetailHelper.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts index baa9b37d8fd..8c4a25fd7a3 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts @@ -1439,7 +1439,7 @@ describe('formatDocketEntryOnDocketRecord', () => { action: 'something', createdAtFormatted: '11/21/18', description: 'first record', - descriptionDisplay: 'Petition', + descriptionDisplay: 'Petition (Attachment(s))', docketEntryId: '8675309b-18d0-43ec-bafb-654e83405411', eventCode: 'P', index: 4, From 00d61abba9062fe70bc4fc0e73f44f7886f9334c Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 13:21:13 -0700 Subject: [PATCH 12/14] 10076: fixing type errors --- shared/src/business/entities/DocketEntry.ts | 10 +++---- shared/src/business/entities/cases/Case.ts | 2 +- web-client/src/presenter/app.cerebral.ts | 3 +++ .../Public/publicCaseDetailHelper.ts | 8 +++++- web-client/src/presenter/presenter-public.ts | 4 +-- web-client/src/presenter/state-public.ts | 12 ++++++--- .../src/views/Public/PublicCaseDetail.tsx | 18 ++++++++----- .../views/Public/PublicDocketRecordHeader.tsx | 27 ++++++++++--------- 8 files changed, 53 insertions(+), 31 deletions(-) diff --git a/shared/src/business/entities/DocketEntry.ts b/shared/src/business/entities/DocketEntry.ts index ff0ee458820..ad75831e900 100644 --- a/shared/src/business/entities/DocketEntry.ts +++ b/shared/src/business/entities/DocketEntry.ts @@ -22,7 +22,6 @@ import { } from '../utilities/DateHandler'; export class DocketEntry extends JoiValidationEntity { - public entityName: string; public action?: string; public additionalInfo?: string; public additionalInfo2?: string; @@ -84,17 +83,17 @@ export class DocketEntry extends JoiValidationEntity { public strickenAt?: string; public trialLocation?: string; public supportingDocument?: string; - public userId: string; + public userId?: string; public privatePractitioners?: any[]; public servedParties?: any[]; public signedAt?: string; - public draftOrderState: object; - public stampData: object; + public draftOrderState?: object; + public stampData!: object; public isDraft?: boolean; public redactionAcknowledgement?: boolean; public judge?: string; public judgeUserId?: string; - public pending: boolean; + public pending?: boolean; public previousDocument?: { docketEntryId: string; documentTitle: string; @@ -124,6 +123,7 @@ export class DocketEntry extends JoiValidationEntity { }, ) { super('DocketEntry'); + if (!applicationContext) { throw new TypeError('applicationContext must be defined'); } diff --git a/shared/src/business/entities/cases/Case.ts b/shared/src/business/entities/cases/Case.ts index 6241dfe1d62..61cb15fe704 100644 --- a/shared/src/business/entities/cases/Case.ts +++ b/shared/src/business/entities/cases/Case.ts @@ -111,7 +111,7 @@ export class Case extends JoiValidationEntity { public noticeOfTrialDate: string; public docketNumberWithSuffix: string; public canAllowDocumentService: string; - public canAllowPrintableDocketRecord: string; + public canAllowPrintableDocketRecord!: boolean; public archivedDocketEntries: RawDocketEntry[]; public docketEntries: any[]; public isSealed: boolean; diff --git a/web-client/src/presenter/app.cerebral.ts b/web-client/src/presenter/app.cerebral.ts index 289bc4380eb..1ee33692944 100644 --- a/web-client/src/presenter/app.cerebral.ts +++ b/web-client/src/presenter/app.cerebral.ts @@ -1,3 +1,4 @@ +import { PublicClientState } from './state-public'; import { sequences as cerebralSequences, state as cerebralState, @@ -7,4 +8,6 @@ import type { Sequences } from '@web-client/presenter/presenter'; export const state = cerebralState as unknown as ClientState; +export const statePublic = cerebralState as unknown as PublicClientState; + export const sequences = cerebralSequences as unknown as Sequences; diff --git a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts index 6daad5decff..6b127b31010 100644 --- a/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts +++ b/web-client/src/presenter/computeds/Public/publicCaseDetailHelper.ts @@ -199,10 +199,16 @@ const filterDocketEntries = ( } }; +export interface IPublicCaseDetailHelper { + formattedDocketEntriesOnDocketRecord: any[]; + isCaseSealed: boolean; + showPrintableDocketRecord: boolean; +} + export const publicCaseDetailHelper = ( get: Get, applicationContext: ClientApplicationContext, -) => { +): IPublicCaseDetailHelper => { const { canAllowPrintableDocketRecord, docketEntries, diff --git a/web-client/src/presenter/presenter-public.ts b/web-client/src/presenter/presenter-public.ts index e4fa6dbefc2..1295bc3d075 100644 --- a/web-client/src/presenter/presenter-public.ts +++ b/web-client/src/presenter/presenter-public.ts @@ -3,6 +3,7 @@ import { InvalidRequestError } from './errors/InvalidRequestError'; import { NotFoundError } from './errors/NotFoundError'; import { ServerInvalidResponseError } from './errors/ServerInvalidResponseError'; import { advancedSearchTabChangeSequence } from './sequences/advancedSearchTabChangeSequence'; +import { baseState } from './state-public'; import { cerebralBindSimpleSetStateSequence } from './sequences/cerebralBindSimpleSetStateSequence'; import { clearAdvancedSearchFormSequence } from './sequences/clearAdvancedSearchFormSequence'; import { clearPdfPreviewUrlSequence } from './sequences/clearPdfPreviewUrlSequence'; @@ -31,7 +32,6 @@ import { setCurrentPageErrorSequence } from './sequences/setCurrentPageErrorSequ import { showMaintenancePageDecorator } from './utilities/showMaintenancePageDecorator'; import { showMoreResultsSequence } from './sequences/showMoreResultsSequence'; import { sortTodaysOrdersSequence } from './sequences/Public/sortTodaysOrdersSequence'; -import { state } from './state-public'; import { submitPublicCaseAdvancedSearchSequence } from './sequences/Public/submitPublicCaseAdvancedSearchSequence'; import { submitPublicCaseDocketNumberSearchSequence } from './sequences/Public/submitPublicCaseDocketNumberSearchSequence'; import { submitPublicOpinionAdvancedSearchSequence } from './sequences/Public/submitPublicOpinionAdvancedSearchSequence'; @@ -118,5 +118,5 @@ export const presenter = { validateOpinionSearchSequence, validateOrderSearchSequence, }, - state, + state: baseState, }; diff --git a/web-client/src/presenter/state-public.ts b/web-client/src/presenter/state-public.ts index 6909d1ec54f..05f801ccf92 100644 --- a/web-client/src/presenter/state-public.ts +++ b/web-client/src/presenter/state-public.ts @@ -12,7 +12,7 @@ import { templateHelper } from './computeds/templateHelper'; import { todaysOpinionsHelper } from './computeds/Public/todaysOpinionsHelper'; import { todaysOrdersHelper } from './computeds/Public/todaysOrdersHelper'; -const helpers = { +const computeds = { advancedDocumentSearchHelper, advancedSearchHelper, alertHelper: publicAlertHelper, @@ -27,8 +27,7 @@ const helpers = { todaysOrdersHelper, }; -export const state = { - ...helpers, +export const baseState = { advancedSearchForm: {}, advancedSearchTab: 'case', commonUI: { @@ -60,3 +59,10 @@ export const state = { user: {}, validationErrors: {}, }; + +export const initialPublicState = { + ...baseState, + ...computeds, +}; + +export type PublicClientState = typeof initialPublicState; diff --git a/web-client/src/views/Public/PublicCaseDetail.tsx b/web-client/src/views/Public/PublicCaseDetail.tsx index a3ea8cfe92f..d9330df4faf 100644 --- a/web-client/src/views/Public/PublicCaseDetail.tsx +++ b/web-client/src/views/Public/PublicCaseDetail.tsx @@ -1,19 +1,23 @@ +import { IPublicCaseDetailHelper } from '../../presenter/computeds/Public/publicCaseDetailHelper'; import { PublicCaseDetailHeader } from './PublicCaseDetailHeader'; import { PublicCaseDetailSubnavTabs } from './PublicCaseDetailSubnavTabs'; import { PublicDocketRecord } from './PublicDocketRecord'; import { connect } from '@cerebral/react'; -import { state } from '@web-client/presenter/app.cerebral'; +import { statePublic as state } from '@web-client/presenter/app.cerebral'; import React from 'react'; +const props = { + publicCaseDetailHelper: + state.publicCaseDetailHelper as unknown as IPublicCaseDetailHelper, +}; + export const PublicCaseDetail = connect( - { - isCaseSealed: state.publicCaseDetailHelper.isCaseSealed, - }, - function PublicCaseDetail({ isCaseSealed }) { + props, + function ({ publicCaseDetailHelper }: typeof props) { return ( <> - {!isCaseSealed && ( + {!publicCaseDetailHelper.isCaseSealed && ( <>

@@ -22,7 +26,7 @@ export const PublicCaseDetail = connect( )} - {isCaseSealed && ( + {publicCaseDetailHelper.isCaseSealed && ( <>

diff --git a/web-client/src/views/Public/PublicDocketRecordHeader.tsx b/web-client/src/views/Public/PublicDocketRecordHeader.tsx index 96e3fa54b51..70b2dbd83b1 100644 --- a/web-client/src/views/Public/PublicDocketRecordHeader.tsx +++ b/web-client/src/views/Public/PublicDocketRecordHeader.tsx @@ -3,26 +3,29 @@ import { Button } from '../../ustc-ui/Button/Button'; import { OpenPrintableDocketRecordModal } from '../DocketRecord/OpenPrintableDocketRecordModal'; import { connect } from '@cerebral/react'; import { sequences } from '@web-client/presenter/app.cerebral'; -import { state } from '@web-client/presenter/app.cerebral'; +import { statePublic as state } from '@web-client/presenter/app.cerebral'; import React from 'react'; +const props = { + PUBLIC_DOCKET_RECORD_FILTER_OPTIONS: + state.constants.PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, + docketNumber: state.caseDetail.docketNumber, + gotoPublicPrintableDocketRecordSequence: + sequences.gotoPublicPrintableDocketRecordSequence, + publicCaseDetailHelper: + state.publicCaseDetailHelper as unknown as IPublicCaseDetailHelper, + showModal: state.modal.showModal, +}; + export const PublicDocketRecordHeader = connect( - { - PUBLIC_DOCKET_RECORD_FILTER_OPTIONS: - state.constants.PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, - docketNumber: state.caseDetail.docketNumber, - gotoPublicPrintableDocketRecordSequence: - sequences.gotoPublicPrintableDocketRecordSequence, - publicCaseDetailHelper: state.publicCaseDetailHelper, - showModal: state.modal.showModal, - }, - function PublicDocketRecordHeader({ + props, + function ({ docketNumber, gotoPublicPrintableDocketRecordSequence, PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, publicCaseDetailHelper, showModal, - }) { + }: typeof props) { return (

From 021e3de32c712c4830efa71219e1861ac11ac7d6 Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 13:33:08 -0700 Subject: [PATCH 13/14] 10076: Fixing more type errors --- .../src/authorization/getUserPermissions.test.ts | 12 +++++------- shared/src/authorization/getUserPermissions.ts | 4 +++- shared/src/business/entities/User.ts | 6 +++--- .../caseAssociation/AddIrsPractitioner.test.ts | 12 ++++++++---- .../caseAssociation/AddIrsPractitioner.ts | 2 +- shared/src/business/entities/cases/Case.test.ts | 2 +- shared/src/business/entities/cases/Case.ts | 16 ++++++++-------- shared/src/test/mockUsers.ts | 4 +++- web-client/src/applicationContext.ts | 6 ++++-- 9 files changed, 36 insertions(+), 28 deletions(-) diff --git a/shared/src/authorization/getUserPermissions.test.ts b/shared/src/authorization/getUserPermissions.test.ts index bfb32cc5862..a239c0f1002 100644 --- a/shared/src/authorization/getUserPermissions.test.ts +++ b/shared/src/authorization/getUserPermissions.test.ts @@ -1,23 +1,21 @@ -import { ROLES } from '../business/entities/EntityConstants'; import { ROLE_PERMISSIONS } from './authorizationClientService'; +import { docketClerk1User } from '../test/mockUsers'; import { getUserPermissions } from './getUserPermissions'; describe('getUserPermissions', () => { it('returns an object containing ROLE_PERMISSIONS and a boolean value based on the given user role', () => { - const user = { - role: ROLES.docketClerk, - }; + const permissions = getUserPermissions(docketClerk1User); - const permissions = getUserPermissions(user); - const permissionsKeys = Object.keys(permissions); + const permissionsKeys = Object.keys(permissions!); expect(permissionsKeys.length).toEqual( Object.keys(ROLE_PERMISSIONS).length, ); - expect(typeof permissions[permissionsKeys[0]]).toEqual('boolean'); + expect(typeof permissions![permissionsKeys[0]]).toEqual('boolean'); }); it('returns undefined when a user is not provided', () => { const permissions = getUserPermissions(); + expect(permissions).toEqual(undefined); }); }); diff --git a/shared/src/authorization/getUserPermissions.ts b/shared/src/authorization/getUserPermissions.ts index 9bab3dac380..da3ef488a06 100644 --- a/shared/src/authorization/getUserPermissions.ts +++ b/shared/src/authorization/getUserPermissions.ts @@ -6,7 +6,9 @@ import { ROLE_PERMISSIONS, isAuthorized } from './authorizationClientService'; * @param {object} user the user to check for authorization * @returns {object|void} ROLE_PERMISSIONS keys with boolean value based on user role */ -export const getUserPermissions = user => { +export const getUserPermissions = ( + user?: RawUser | RawPractitioner | RawIrsPractitioner, +) => { if (user) { const permissions = {}; Object.keys(ROLE_PERMISSIONS).forEach(key => { diff --git a/shared/src/business/entities/User.ts b/shared/src/business/entities/User.ts index 1e7e6a2d4cd..20bec2fb5ce 100644 --- a/shared/src/business/entities/User.ts +++ b/shared/src/business/entities/User.ts @@ -15,11 +15,11 @@ export class User extends JoiValidationEntity { public pendingEmailVerificationToken?: string; public email: string; public name: string; - public pendingEmail: string; + public pendingEmail?: string; public role: string; - public token: string; + public token?: string; public userId: string; - public isUpdatingInformation: string; + public isUpdatingInformation?: boolean; public contact?: { address1: string; address2: string; diff --git a/shared/src/business/entities/caseAssociation/AddIrsPractitioner.test.ts b/shared/src/business/entities/caseAssociation/AddIrsPractitioner.test.ts index 2e28447c42c..2fbda9c9228 100644 --- a/shared/src/business/entities/caseAssociation/AddIrsPractitioner.test.ts +++ b/shared/src/business/entities/caseAssociation/AddIrsPractitioner.test.ts @@ -1,14 +1,14 @@ import { AddIrsPractitioner } from './AddIrsPractitioner'; import { SERVICE_INDICATOR_TYPES } from '../EntityConstants'; -const errorMessages = AddIrsPractitioner.VALIDATION_ERROR_MESSAGES; - describe('AddIrsPractitioner', () => { describe('validation', () => { it('should have error messages for missing fields', () => { const entity = new AddIrsPractitioner({}); + expect(entity.getFormattedValidationErrors()).toEqual({ - serviceIndicator: errorMessages.serviceIndicator[1], + serviceIndicator: + AddIrsPractitioner.VALIDATION_ERROR_MESSAGES.serviceIndicator[1], user: AddIrsPractitioner.VALIDATION_ERROR_MESSAGES.user, }); }); @@ -18,6 +18,7 @@ describe('AddIrsPractitioner', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER, user: { userId: '02323349-87fe-4d29-91fe-8dd6916d2fda' }, }); + expect(entity.getFormattedValidationErrors()).toEqual(null); }); }); @@ -27,8 +28,11 @@ describe('AddIrsPractitioner', () => { serviceIndicator: SERVICE_INDICATOR_TYPES.SI_ELECTRONIC, user: { userId: '02323349-87fe-4d29-91fe-8dd6916d2fda' }, }); + expect(entity.getFormattedValidationErrors()).toEqual({ - serviceIndicator: errorMessages.serviceIndicator[0].message, + serviceIndicator: + AddIrsPractitioner.VALIDATION_ERROR_MESSAGES.serviceIndicator[0] + .message, }); }); }); diff --git a/shared/src/business/entities/caseAssociation/AddIrsPractitioner.ts b/shared/src/business/entities/caseAssociation/AddIrsPractitioner.ts index d2cce9d6112..1f18ec99b7c 100644 --- a/shared/src/business/entities/caseAssociation/AddIrsPractitioner.ts +++ b/shared/src/business/entities/caseAssociation/AddIrsPractitioner.ts @@ -25,7 +25,7 @@ export class AddIrsPractitioner extends JoiValidationEntity { 'Select service type', ], user: 'Select a respondent counsel', - }; + } as const; getErrorToMessageMap() { return AddIrsPractitioner.VALIDATION_ERROR_MESSAGES; diff --git a/shared/src/business/entities/cases/Case.test.ts b/shared/src/business/entities/cases/Case.test.ts index 71a5e9265f1..9f1477aaf1b 100644 --- a/shared/src/business/entities/cases/Case.test.ts +++ b/shared/src/business/entities/cases/Case.test.ts @@ -111,7 +111,7 @@ describe('Case entity', () => { }); }); it('should throw an error if app context is not passed in', () => { - expect(() => new Case({}, {})).toThrow(); + expect(() => new Case({}, {} as any)).toThrow(); }); it('defaults the orders to false', () => { diff --git a/shared/src/business/entities/cases/Case.ts b/shared/src/business/entities/cases/Case.ts index 61cb15fe704..75c11b92349 100644 --- a/shared/src/business/entities/cases/Case.ts +++ b/shared/src/business/entities/cases/Case.ts @@ -10,6 +10,7 @@ import { CHIEF_JUDGE, CLOSED_CASE_STATUSES, CONTACT_TYPES, + CaseStatus, DOCKET_NUMBER_SUFFIXES, FILING_TYPES, INITIAL_DOCUMENT_TYPES, @@ -181,7 +182,7 @@ export class Case extends JoiValidationEntity { * @param {string} docketNumber the docket number to use * @returns {string|void} the sortable docket number */ - static getSortableDocketNumber(docketNumber) { + static getSortableDocketNumber(docketNumber?: string) { if (!docketNumber) { return; } @@ -1421,17 +1422,15 @@ export class Case extends JoiValidationEntity { return this; } - /** - * remove case from trial, setting case status to generalDocketReadyForTrial - * @param {string} providers.updatedCaseStatus optional case status to set the case to - * @param {string} providers.associatedJudge optional associatedJudge to set on the case - * @returns {Case} the updated case entity - */ removeFromTrial({ associatedJudge = CHIEF_JUDGE, changedBy, updatedCaseStatus = CASE_STATUS_TYPES.generalDocketReadyForTrial, - }) { + }: { + associatedJudge?: string; + changedBy?: string; + updatedCaseStatus?: CaseStatus; + }): Case { this.setAssociatedJudge(associatedJudge); this.setCaseStatus({ changedBy, @@ -1441,6 +1440,7 @@ export class Case extends JoiValidationEntity { this.trialLocation = undefined; this.trialSessionId = undefined; this.trialTime = undefined; + return this; } diff --git a/shared/src/test/mockUsers.ts b/shared/src/test/mockUsers.ts index 44397d3d82c..afd54d59a1c 100644 --- a/shared/src/test/mockUsers.ts +++ b/shared/src/test/mockUsers.ts @@ -91,7 +91,9 @@ export const docketClerkUser = { userId: 'a7d90c05-f6cd-442c-a168-202db587f16f', }; -export const docketClerk1User = { +export const docketClerk1User: RawUser = { + email: 'docketclerk1@example.com', + entityName: 'User', name: 'Docketclerk1', role: ROLES.docketClerk, section: DOCKET_SECTION, diff --git a/web-client/src/applicationContext.ts b/web-client/src/applicationContext.ts index 8f4b1f2e1b7..be0b256f97e 100644 --- a/web-client/src/applicationContext.ts +++ b/web-client/src/applicationContext.ts @@ -355,10 +355,12 @@ import deepFreeze from 'deep-freeze'; let user; let broadcastChannel; -const getCurrentUser = () => { +const getCurrentUser = (): RawUser | RawPractitioner | RawIrsPractitioner => { return user; }; -const setCurrentUser = newUser => { +const setCurrentUser = ( + newUser: RawUser | RawPractitioner | RawIrsPractitioner, +) => { user = newUser; }; From 925576f3350d37eee8ddda776ea58dd6e0286eff Mon Sep 17 00:00:00 2001 From: Rachel Schneiderman Date: Mon, 31 Jul 2023 15:48:00 -0700 Subject: [PATCH 14/14] 10076: Cerebral demands we name state state and not statePublic or anything else, create new state file for public state to appease cerebral naming conventions --- .../src/presenter/app-public.cerebral.ts | 10 ++++++++++ web-client/src/presenter/presenter-public.ts | 4 ++-- web-client/src/views/AppComponentPublic.tsx | 2 +- .../src/views/Public/PublicCaseDetail.tsx | 18 +++++++++++------- .../src/views/Public/PublicDocketRecord.tsx | 14 +++++++++----- .../views/Public/PublicDocketRecordHeader.tsx | 9 ++++++--- 6 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 web-client/src/presenter/app-public.cerebral.ts diff --git a/web-client/src/presenter/app-public.cerebral.ts b/web-client/src/presenter/app-public.cerebral.ts new file mode 100644 index 00000000000..9931d2f0fe1 --- /dev/null +++ b/web-client/src/presenter/app-public.cerebral.ts @@ -0,0 +1,10 @@ +import { PublicClientState } from './state-public'; +import { + sequences as cerebralSequences, + state as cerebralState, +} from 'cerebral'; +import type { Sequences } from '@web-client/presenter/presenter'; + +export const state = cerebralState as unknown as PublicClientState; + +export const sequences = cerebralSequences as unknown as Sequences; diff --git a/web-client/src/presenter/presenter-public.ts b/web-client/src/presenter/presenter-public.ts index 1295bc3d075..93a2de4b231 100644 --- a/web-client/src/presenter/presenter-public.ts +++ b/web-client/src/presenter/presenter-public.ts @@ -3,7 +3,6 @@ import { InvalidRequestError } from './errors/InvalidRequestError'; import { NotFoundError } from './errors/NotFoundError'; import { ServerInvalidResponseError } from './errors/ServerInvalidResponseError'; import { advancedSearchTabChangeSequence } from './sequences/advancedSearchTabChangeSequence'; -import { baseState } from './state-public'; import { cerebralBindSimpleSetStateSequence } from './sequences/cerebralBindSimpleSetStateSequence'; import { clearAdvancedSearchFormSequence } from './sequences/clearAdvancedSearchFormSequence'; import { clearPdfPreviewUrlSequence } from './sequences/clearPdfPreviewUrlSequence'; @@ -20,6 +19,7 @@ import { gotoPublicPrintableDocketRecordSequence } from './sequences/Public/goto import { gotoPublicSearchSequence } from './sequences/Public/gotoPublicSearchSequence'; import { gotoTodaysOpinionsSequence } from './sequences/Public/gotoTodaysOpinionsSequence'; import { gotoTodaysOrdersSequence } from './sequences/Public/gotoTodaysOrdersSequence'; +import { initialPublicState } from './state-public'; import { loadMoreTodaysOrdersSequence } from './sequences/loadMoreTodaysOrdersSequence'; import { navigateBackSequence } from './sequences/navigateBackSequence'; import { navigateToCognitoSequence } from './sequences/navigateToCognitoSequence'; @@ -118,5 +118,5 @@ export const presenter = { validateOpinionSearchSequence, validateOrderSearchSequence, }, - state: baseState, + state: initialPublicState, }; diff --git a/web-client/src/views/AppComponentPublic.tsx b/web-client/src/views/AppComponentPublic.tsx index dde253edd61..5e4e7866e13 100644 --- a/web-client/src/views/AppComponentPublic.tsx +++ b/web-client/src/views/AppComponentPublic.tsx @@ -16,7 +16,7 @@ import { TodaysOpinions } from './Public/TodaysOpinions'; import { TodaysOrders } from './Public/TodaysOrders'; import { UsaBanner } from './UsaBanner'; import { connect } from '@cerebral/react'; -import { state } from '@web-client/presenter/app.cerebral'; +import { state } from '@web-client/presenter/app-public.cerebral'; import { useScript } from '../utilities/useScript'; import React, { useEffect } from 'react'; diff --git a/web-client/src/views/Public/PublicCaseDetail.tsx b/web-client/src/views/Public/PublicCaseDetail.tsx index a3ea8cfe92f..08f1d9a57bd 100644 --- a/web-client/src/views/Public/PublicCaseDetail.tsx +++ b/web-client/src/views/Public/PublicCaseDetail.tsx @@ -1,19 +1,23 @@ +import { IPublicCaseDetailHelper } from '../../presenter/computeds/Public/publicCaseDetailHelper'; import { PublicCaseDetailHeader } from './PublicCaseDetailHeader'; import { PublicCaseDetailSubnavTabs } from './PublicCaseDetailSubnavTabs'; import { PublicDocketRecord } from './PublicDocketRecord'; import { connect } from '@cerebral/react'; -import { state } from '@web-client/presenter/app.cerebral'; +import { state } from '@web-client/presenter/app-public.cerebral'; import React from 'react'; +const props = { + publicCaseDetailHelper: + state.publicCaseDetailHelper as unknown as IPublicCaseDetailHelper, +}; + export const PublicCaseDetail = connect( - { - isCaseSealed: state.publicCaseDetailHelper.isCaseSealed, - }, - function PublicCaseDetail({ isCaseSealed }) { + props, + function ({ publicCaseDetailHelper }: typeof props) { return ( <> - {!isCaseSealed && ( + {!publicCaseDetailHelper.isCaseSealed && ( <>
@@ -22,7 +26,7 @@ export const PublicCaseDetail = connect( )} - {isCaseSealed && ( + {publicCaseDetailHelper.isCaseSealed && ( <>

diff --git a/web-client/src/views/Public/PublicDocketRecord.tsx b/web-client/src/views/Public/PublicDocketRecord.tsx index 2c90d9f3d46..b17a3a69eb9 100644 --- a/web-client/src/views/Public/PublicDocketRecord.tsx +++ b/web-client/src/views/Public/PublicDocketRecord.tsx @@ -1,16 +1,20 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { IPublicCaseDetailHelper } from '../../presenter/computeds/Public/publicCaseDetailHelper'; import { PublicDocketRecordHeader } from './PublicDocketRecordHeader'; import { PublicFilingsAndProceedings } from './PublicFilingsAndProceedings'; import { connect } from '@cerebral/react'; -import { state } from '@web-client/presenter/app.cerebral'; +import { state } from '@web-client/presenter/app-public.cerebral'; import React from 'react'; import classNames from 'classnames'; +const props = { + publicCaseDetailHelper: + state.publicCaseDetailHelper as unknown as IPublicCaseDetailHelper, +}; + export const PublicDocketRecord = connect( - { - publicCaseDetailHelper: state.publicCaseDetailHelper, - }, - function PublicDocketRecord({ publicCaseDetailHelper }) { + props, + function ({ publicCaseDetailHelper }: typeof props) { return ( <> diff --git a/web-client/src/views/Public/PublicDocketRecordHeader.tsx b/web-client/src/views/Public/PublicDocketRecordHeader.tsx index 40176ba8a30..e525b88d684 100644 --- a/web-client/src/views/Public/PublicDocketRecordHeader.tsx +++ b/web-client/src/views/Public/PublicDocketRecordHeader.tsx @@ -1,5 +1,6 @@ import { BindedSelect } from '../../ustc-ui/BindedSelect/BindedSelect'; import { Button } from '../../ustc-ui/Button/Button'; +import { IPublicCaseDetailHelper } from '../../presenter/computeds/Public/publicCaseDetailHelper'; import { OpenPrintableDocketRecordModal } from '../DocketRecord/OpenPrintableDocketRecordModal'; import { connect } from '@cerebral/react'; import { sequences } from '@web-client/presenter/app.cerebral'; @@ -12,19 +13,21 @@ const props = { docketNumber: state.caseDetail.docketNumber, gotoPublicPrintableDocketRecordSequence: sequences.gotoPublicPrintableDocketRecordSequence, - publicCaseDetailHelper: state.publicCaseDetailHelper, + publicCaseDetailHelper: + state.publicCaseDetailHelper as unknown as IPublicCaseDetailHelper, + showModal: state.modal.showModal, }; export const PublicDocketRecordHeader = connect( props, - function PublicDocketRecordHeader({ + function ({ docketNumber, gotoPublicPrintableDocketRecordSequence, PUBLIC_DOCKET_RECORD_FILTER_OPTIONS, publicCaseDetailHelper, showModal, - }) { + }: typeof props) { return (