Skip to content

Commit

Permalink
Merge pull request #5573 from flexion/10556-bug
Browse files Browse the repository at this point in the history
10556 Bug: Filter Off-The-Record Docket Entries for Non-Internal Users
  • Loading branch information
jimlerza authored Nov 23, 2024
2 parents 65f0d37 + 5908c5f commit 7c03937
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
51 changes: 51 additions & 0 deletions shared/src/business/useCases/getCaseInteractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,57 @@ describe('getCaseInteractor', () => {
expect(result.docketNumber).toEqual('101-00');
});

it('should filter out docket entries that are not on the docket record when the currentUser is an external user associated with an unsealed case', async () => {
const expectedDocketEntries = testCase.docketEntries.filter(
de => de.isOnDocketRecord,
);
applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockResolvedValue(testCase);

const result = await getCaseInteractor(
applicationContext,
{
docketNumber: testCase.docketNumber,
},
{
email: mockCaseContactPrimary.email,
name: mockCaseContactPrimary.name,
role: ROLES.petitioner,
userId: mockCaseContactPrimary.contactId,
},
);

expect(result.docketEntries).toMatchObject(expectedDocketEntries);
});

it('should filter out docket entries that are not on the docket record when the currentUser is an external user associated with a sealed case', async () => {
const expectedDocketEntries = testCase.docketEntries.filter(
de => de.isOnDocketRecord,
);
applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockResolvedValue({
...testCase,
isSealed: true,
});

const result = await getCaseInteractor(
applicationContext,
{
docketNumber: testCase.docketNumber,
},
{
email: mockCaseContactPrimary.email,
name: mockCaseContactPrimary.name,
role: ROLES.petitioner,
userId: mockCaseContactPrimary.contactId,
},
);

expect(result.docketEntries).toMatchObject(expectedDocketEntries);
});

it('should return the case when the currentUser is an irs superuser even if the case has sealed documents', async () => {
applicationContext
.getPersistenceGateway()
Expand Down
24 changes: 24 additions & 0 deletions shared/src/business/useCases/getCaseInteractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import {
isAssociatedUser,
isUserPartOfGroup,
} from '../entities/cases/Case';
import {
INITIAL_DOCUMENT_TYPES,
ROLES,
} from '@shared/business/entities/EntityConstants';
import { NotFoundError, UnauthorizedError } from '@web-api/errors/errors';
import { PublicCase } from '../entities/cases/PublicCase';
import {
Expand Down Expand Up @@ -49,6 +53,10 @@ const getSealedCase = ({
}
}

if (!User.isInternalUser(authorizedUser.role)) {
filterDocketEntriesNotOnDocketRecord({ authorizedUser, caseRecord });
}

if (isAuthorizedToViewSealedCase || isAssociatedWithCase) {
return new Case(caseRecord, { authorizedUser }).validate().toRawObject();
} else {
Expand All @@ -68,6 +76,7 @@ const getCaseForExternalUser = ({
isAssociatedWithCase,
isAuthorizedToGetCase,
}) => {
filterDocketEntriesNotOnDocketRecord({ authorizedUser, caseRecord });
if (isAuthorizedToGetCase && isAssociatedWithCase) {
return new Case(caseRecord, { authorizedUser }).validate().toRawObject();
} else {
Expand Down Expand Up @@ -202,3 +211,18 @@ export const getCaseInteractor = async (
);
return caseDetailRaw;
};

const filterDocketEntriesNotOnDocketRecord = ({
authorizedUser,
caseRecord,
}: {
caseRecord: RawCase;
authorizedUser: AuthUser;
}) => {
caseRecord.docketEntries = caseRecord.docketEntries.filter(
d =>
d.isOnDocketRecord ||
(d.documentType === INITIAL_DOCUMENT_TYPES.stin.documentType &&
authorizedUser.role === ROLES.irsSuperuser),
);
};
8 changes: 4 additions & 4 deletions web-client/integration-tests/caseJourney.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ describe('Case journey', () => {

loginAs(cerebralTest, 'irspractitioner@example.com');
respondentViewsDashboard(cerebralTest);
const documentCountPreStipDecision = 6;
const documentsOnRecordCount = 5;
respondentAddsAnswer(cerebralTest, fakeFile, {
documentCount: documentCountPreStipDecision,
documentCount: documentsOnRecordCount,
});
respondentAddsStipulatedDecision(cerebralTest, fakeFile, {
documentCount: documentCountPreStipDecision + 1,
documentCount: documentsOnRecordCount + 1,
});
respondentAddsMotionWithBrief(cerebralTest, fakeFile, {
documentCount: documentCountPreStipDecision + 3,
documentCount: documentsOnRecordCount + 3,
});

loginAs(cerebralTest, 'docketclerk@example.com');
Expand Down
4 changes: 2 additions & 2 deletions web-client/integration-tests/petitionerFilesADocument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('petitioner files document', () => {

loginAs(cerebralTest, 'petitioner@example.com');
petitionerViewsCaseDetail(cerebralTest, {
documentCount: 4,
documentCount: 3,
});
petitionerFilesDocumentForCase(cerebralTest, fakeFile);
petitionerViewsCaseDetailAfterFilingDocument(cerebralTest, {
documentCount: 8,
documentCount: 7,
});
petitionerFilesAmendedMotion(cerebralTest, fakeFile);
});

0 comments on commit 7c03937

Please sign in to comment.