Skip to content

Commit

Permalink
Merge branch '10502-dxox' of github.com:flexion/ef-cms into 10502-dxox
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiwyn committed Feb 11, 2025
2 parents 5802c07 + b617f71 commit 1737e9a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 74 deletions.
4 changes: 2 additions & 2 deletions shared/src/business/useCases/prioritizeCaseInteractor.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import '@web-api/persistence/postgres/cases/mocks.jest';
import '@web-api/persistence/postgres/workitems/mocks.jest';
import { CASE_STATUS_TYPES } from '../entities/EntityConstants';
import { MOCK_CASE } from '../../test/mockCase';
import { MOCK_LOCK } from '../../test/mockLock';
import { MOCK_CASE } from '@shared/test/mockCase';
import { MOCK_LOCK } from '@shared/test/mockLock';
import { ServiceUnavailableError } from '@web-api/errors/errors';
import { applicationContext } from '../test/createTestApplicationContext';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable max-lines */
import '@web-api/persistence/postgres/cases/mocks.jest';
import {
CASE_STATUS_TYPES,
DOCKET_ENTRY_SEALED_TO_TYPES,
Expand All @@ -7,24 +8,24 @@ import {
NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP,
STIPULATED_DECISION_EVENT_CODE,
TRANSCRIPT_EVENT_CODE,
} from '../../../../../shared/src/business/entities/EntityConstants';
} from '@shared/business/entities/EntityConstants';
import { ConsolidatedCaseSummary } from '@shared/business/dto/cases/ConsolidatedCaseSummary';
import { MOCK_CASE } from '../../../../../shared/src/test/mockCase';
import { MOCK_CASE } from '@shared/test/mockCase';
import {
UNAUTHORIZED_DOCUMENT_MESSAGE,
getDownloadPolicyUrlInteractor,
} from './getDownloadPolicyUrlInteractor';
import { UnauthorizedError } from '@web-api/errors/errors';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import { applicationContext } from '@shared/business/test/createTestApplicationContext';
import {
calculateISODate,
createISODateString,
} from '../../../../../shared/src/business/utilities/DateHandler';
} from '@shared/business/utilities/DateHandler';
import {
casePetitioner,
irsPractitionerUser,
privatePractitionerUser,
} from '../../../../../shared/src/test/mockUsers';
} from '@shared/test/mockUsers';
import { cloneDeep } from 'lodash';
import {
mockAdminUser,
Expand All @@ -35,6 +36,7 @@ import {
mockPetitionsClerkUser,
mockPrivatePractitionerUser,
} from '@shared/test/mockAuthUsers';
import { getCaseByDocketNumber as getCaseByDocketNumberMock } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';

describe('getDownloadPolicyUrlInteractor', () => {
let mockCase;
Expand All @@ -47,14 +49,13 @@ describe('getDownloadPolicyUrlInteractor', () => {
const petitionDocketEntry = MOCK_CASE.docketEntries.find(
d => d.eventCode === INITIAL_DOCUMENT_TYPES.petition.eventCode,
);
const getCaseByDocketNumber = getCaseByDocketNumberMock as jest.Mock;

beforeEach(() => {
mockCase = cloneDeep(MOCK_CASE);
mockCase.status = CASE_STATUS_TYPES.generalDocket;

applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockImplementation(() => mockCase);
getCaseByDocketNumber.mockResolvedValue(mockCase);
applicationContext
.getPersistenceGateway()
.getDownloadPolicyUrl.mockReturnValue('localhost');
Expand Down Expand Up @@ -376,9 +377,7 @@ describe('getDownloadPolicyUrlInteractor', () => {
});

it('should throw a not found error when the case the document belonds to is not found', async () => {
applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockReturnValue({ docketEntries: [] });
getCaseByDocketNumber.mockResolvedValue({ docketEntries: [] });

await expect(
getDownloadPolicyUrlInteractor(
Expand Down Expand Up @@ -499,35 +498,33 @@ describe('getDownloadPolicyUrlInteractor', () => {

it('should throw an error when the document requested is a brief that has not yet been served', async () => {
const briefDocketEntryId = 'abb81f4d-1e47-423a-8caf-6d2fdc3d3859';
applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockReturnValue({
...MOCK_CASE,
docketEntries: [
{
createdAt: '2009-11-21T20:49:28.192Z',
docketEntryId: briefDocketEntryId,
docketNumber: '101-18',
documentTitle: 'Simultaneous Opening Brief',
documentType: 'Simultaneous Opening Brief',
draftOrderState: {},
entityName: 'DocketEntry',
eventCode: 'SIOB',
filedBy: 'Test Petitioner',
filers: [],
filingDate: '2009-03-01T05:00:00.000Z',
index: 6,
isFileAttached: true,
isOnDocketRecord: true,
pending: false,
processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE,
receivedAt: '2009-03-01T05:00:00.000Z',
servedAt: undefined,
stampData: {},
userId: '7805d1ab-18d0-43ec-bafb-654e83405416',
},
],
});
getCaseByDocketNumber.mockResolvedValue({
...MOCK_CASE,
docketEntries: [
{
createdAt: '2009-11-21T20:49:28.192Z',
docketEntryId: briefDocketEntryId,
docketNumber: '101-18',
documentTitle: 'Simultaneous Opening Brief',
documentType: 'Simultaneous Opening Brief',
draftOrderState: {},
entityName: 'DocketEntry',
eventCode: 'SIOB',
filedBy: 'Test Petitioner',
filers: [],
filingDate: '2009-03-01T05:00:00.000Z',
index: 6,
isFileAttached: true,
isOnDocketRecord: true,
pending: false,
processingStatus: DOCUMENT_PROCESSING_STATUS_OPTIONS.COMPLETE,
receivedAt: '2009-03-01T05:00:00.000Z',
servedAt: undefined,
stampData: {},
userId: '7805d1ab-18d0-43ec-bafb-654e83405416',
},
],
});

await expect(
getDownloadPolicyUrlInteractor(
Expand Down Expand Up @@ -927,9 +924,7 @@ describe('getDownloadPolicyUrlInteractor', () => {
];

beforeEach(() => {
applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockReturnValue(leadMockCase);
getCaseByDocketNumber.mockResolvedValue(leadMockCase);
});

it('should return the policy url when the document requested is an available document', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Case } from '../../../../../shared/src/business/entities/cases/Case';
import { MOCK_CASE } from '../../../../../shared/src/test/mockCase';
import { PAYMENT_STATUS } from '../../../../../shared/src/business/entities/EntityConstants';
import { Case } from '@shared/business/entities/cases/Case';
import { MOCK_CASE } from '@shared/test/mockCase';
import { PAYMENT_STATUS } from '@shared/business/entities/EntityConstants';
import { addDocketEntryForPaymentStatus } from './serveCaseToIrsInteractor';
import {
mockPetitionerUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,34 @@ import {
ROLES,
SERVICE_INDICATOR_TYPES,
SYSTEM_GENERATED_DOCUMENT_TYPES,
} from '../../../../../shared/src/business/entities/EntityConstants';
import {
Case,
getContactPrimary,
} from '../../../../../shared/src/business/entities/cases/Case';
} from '@shared/business/entities/EntityConstants';
import { Case, getContactPrimary } from '@shared/business/entities/cases/Case';
import {
FORMATS,
formatDateString,
formatNow,
getBusinessDateInFuture,
} from '../../../../../shared/src/business/utilities/DateHandler';
import { MOCK_CASE } from '../../../../../shared/src/test/mockCase';
import { MOCK_LOCK } from '../../../../../shared/src/test/mockLock';
} from '@shared/business/utilities/DateHandler';
import { MOCK_CASE } from '@shared/test/mockCase';
import { MOCK_LOCK } from '@shared/test/mockLock';
import {
ServiceUnavailableError,
UnauthorizedError,
} from '@web-api/errors/errors';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import {
getFakeFile,
testPdfDoc,
} from '../../../../../shared/src/business/test/getFakeFile';
import { applicationContext } from '@shared/business/test/createTestApplicationContext';
import { getFakeFile, testPdfDoc } from '@shared/business/test/getFakeFile';
import {
mockDocketClerkUser,
mockPetitionsClerkUser,
} from '@shared/test/mockAuthUsers';
import { serveCaseToIrsInteractor } from './serveCaseToIrsInteractor';
import { getCaseByDocketNumber as getCaseByDocketNumberMock } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';
import { updateCase as updateCaseMock } from '@web-api/persistence/postgres/cases/updateCase';

describe('serveCaseToIrsInteractor', () => {
const getCaseByDocketNumber = getCaseByDocketNumberMock as jest.Mock;
const updateCase = updateCaseMock as jest.Mock;
updateCase.mockImplementation(c => c.caseToUpdate);
const clientConnectionId = '6805d1ab-18d0-43ec-bafb-654e83405416';
const mockParams = {
clientConnectionId,
Expand Down Expand Up @@ -121,9 +120,7 @@ describe('serveCaseToIrsInteractor', () => {
.getPersistenceGateway()
.getDownloadPolicyUrl.mockReturnValue({ url: 'www.example.com' });

applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockImplementation(() => mockCase);
getCaseByDocketNumber.mockImplementation(() => mockCase);

applicationContext
.getUseCases()
Expand Down Expand Up @@ -1129,11 +1126,8 @@ describe('serveCaseToIrsInteractor', () => {
],
};

applicationContext
.getPersistenceGateway()
.getCaseByDocketNumber.mockReturnValueOnce(
mockCaseWithoutServedDocketEntries,
)
getCaseByDocketNumber
.mockResolvedValueOnce(mockCaseWithoutServedDocketEntries)
.mockReturnValueOnce(mockCase)
.mockReturnValueOnce(mockCaseWithServedDocketEntries)
.mockReturnValueOnce(mockCaseWithServedDocketEntries);
Expand All @@ -1145,8 +1139,7 @@ describe('serveCaseToIrsInteractor', () => {
);

expect(
applicationContext.getPersistenceGateway().updateCase.mock.calls[0][0]
.caseToUpdate.docketEntries,
updateCase.mock.calls[0][0].caseToUpdate.docketEntries,
).toMatchObject([
{
documentTitle: INITIAL_DOCUMENT_TYPES.petition.documentTitle,
Expand Down Expand Up @@ -1553,9 +1546,7 @@ describe('serveCaseToIrsInteractor', () => {
),
).rejects.toThrow(ServiceUnavailableError);

expect(
applicationContext.getPersistenceGateway().getCaseByDocketNumber,
).not.toHaveBeenCalled();
expect(getCaseByDocketNumber).not.toHaveBeenCalled();
});

it('should acquire and remove the lock on the case', async () => {
Expand Down

0 comments on commit 1737e9a

Please sign in to comment.