Skip to content

Commit

Permalink
10502-dxox: fix (maybe all??) api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mwindo committed Feb 12, 2025
1 parent 3a29a81 commit 791817a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ const deleteCaseDeadline = deleteCaseDeadlineMock as jest.Mock;

describe('deleteCaseDeadlineInteractor', () => {
let user;
let mockCase;
let mockDeadlines;
let mockLock;
const getCaseByDocketNumber = getCaseByDocketNumberMock as jest.Mock;
const updateCase = updateCaseMock as jest.Mock;
updateCase.mockImplementation(c => c.caseToUpdate);

beforeAll(() => {
applicationContext
.getPersistenceGateway()
.getLock.mockImplementation(() => mockLock);
mockCase = MOCK_CASE_WITHOUT_PENDING;

applicationContext.environment.stage = 'local';
getCaseByDocketNumber.mockReturnValue(mockCase);
getCaseByDocketNumber.mockResolvedValue(MOCK_CASE_WITHOUT_PENDING);

getCaseDeadlinesByDocketNumber.mockImplementation(() => mockDeadlines);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
jest.mock('@web-api/persistence/elasticsearch/elasticSearchHealthCheck.ts');
import { S3 } from '@aws-sdk/client-s3';
import { getHealthCheckInteractor } from './getHealthCheckInteractor';
import { elasticSearchHealthCheck as elasticSearchHealthCheckMock } from '@web-api/persistence/elasticsearch/elasticSearchHealthCheck';
import { SearchClientResultsType } from '@web-api/persistence/elasticsearch/searchClient';

const mockListObjectsV2 = jest
.spyOn(S3.prototype, 'listObjectsV2')
.mockResolvedValue({} as never);

const elasticSearchHealthCheck = jest.mocked(elasticSearchHealthCheckMock);

describe('getHealthCheckInteractor', () => {
it('should return the expected true statuses for all services', async () => {
elasticSearchHealthCheck.mockResolvedValue({} as SearchClientResultsType);

const statusResult = await getHealthCheckInteractor({
environment: {
stage: 'dev',
Expand Down Expand Up @@ -62,6 +69,7 @@ describe('getHealthCheckInteractor', () => {
});

it('should return false for all services when services are down', async () => {
elasticSearchHealthCheck.mockRejectedValue(false);
mockListObjectsV2.mockRejectedValue(new Error('S3 is down') as never);
const status = await getHealthCheckInteractor({
environment: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,8 @@ describe('updatePetitionerInformationInteractor', () => {
{
docketNumber: MOCK_CASE.docketNumber,
updatedPetitionerData: {
address1: '989 Division St',
city: 'Somewhere',
contactId: mockPetitioners[0].contactId,
countryType: COUNTRY_TYPES.DOMESTIC,
name: 'Test Primary Petitioner',
phone: '1234568',
postalCode: '12345',
serviceIndicator: SERVICE_INDICATOR_TYPES.SI_PAPER,
state: 'TN',
title: 'Executor',
...MOCK_CASE.petitioners[0],
address2: null,
},
},
mockDocketClerkUser,
Expand Down
4 changes: 2 additions & 2 deletions web-api/src/lambdas/v1/getDocumentDownloadUrlLambda.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
jest.mock(
'@web-api/business/useCases/featureFlag/getAllFeatureFlagsInteractor',
);
jest.mock('@web-api/persistence/dynamo/cases/getCaseByDocketNumber');
jest.mock('@web-api/persistence/s3/getDownloadPolicyUrl');
jest.mock('@web-api/persistence/dynamo/deployTable/getMaintenanceMode');
import '@web-api/persistence/postgres/cases/mocks.jest';
import { CASE_STATUS_TYPES } from '@shared/business/entities/EntityConstants';
import { MOCK_PETITION } from '@shared/test/mockDocketEntry';
import { getAllFeatureFlagsInteractor as getAllFeatureFlagsInteractorMock } from '@web-api/business/useCases/featureFlag/getAllFeatureFlagsInteractor';
import { getCaseByDocketNumber as getCaseByDocketNumberMock } from '@web-api/persistence/dynamo/cases/getCaseByDocketNumber';
import { getCaseByDocketNumber as getCaseByDocketNumberMock } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';
import { getDocumentDownloadUrlLambda } from './getDocumentDownloadUrlLambda';
import { getDownloadPolicyUrl as getDownloadPolicyUrlMock } from '@web-api/persistence/s3/getDownloadPolicyUrl';
import { getMaintenanceMode as getMaintenanceModeMock } from '@web-api/persistence/dynamo/deployTable/getMaintenanceMode';
Expand Down
10 changes: 5 additions & 5 deletions web-api/src/lambdas/v2/getCaseLambda.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
jest.mock(
'@web-api/business/useCases/featureFlag/getAllFeatureFlagsInteractor',
);
jest.mock('@web-api/persistence/dynamo/cases/getCaseByDocketNumber');
jest.mock('@web-api/persistence/dynamo/deployTable/getMaintenanceMode');
import { MOCK_CASE_WITH_TRIAL_SESSION } from '../../../../shared/src/test/mockCase';
import { MOCK_COMPLEX_CASE } from '../../../../shared/src/test/mockComplexCase';
import { MOCK_PRACTITIONER } from '../../../../shared/src/test/mockUsers';
import '@web-api/persistence/postgres/cases/mocks.jest';
import { MOCK_CASE_WITH_TRIAL_SESSION } from '@shared/test/mockCase';
import { MOCK_COMPLEX_CASE } from '@shared/test/mockComplexCase';
import { MOCK_PRACTITIONER } from '@shared/test/mockUsers';
import { getCaseLambda } from './getCaseLambda';
import {
mockDocketClerkUser,
mockPetitionerUser,
} from '@shared/test/mockAuthUsers';
import { getCaseByDocketNumber as mockGetCaseByDocketNumber } from '@web-api/persistence/dynamo/cases/getCaseByDocketNumber';
import { getCaseByDocketNumber as mockGetCaseByDocketNumber } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';

const mockDynamoCaseRecord = Object.assign({}, MOCK_CASE_WITH_TRIAL_SESSION, {
entityName: 'Case',
Expand Down
4 changes: 2 additions & 2 deletions web-api/src/lambdas/v2/getDocumentDownloadUrlLambda.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
jest.mock(
'@web-api/business/useCases/featureFlag/getAllFeatureFlagsInteractor',
);
jest.mock('@web-api/persistence/dynamo/cases/getCaseByDocketNumber');
jest.mock('@web-api/persistence/s3/getDownloadPolicyUrl');
jest.mock('@web-api/persistence/dynamo/deployTable/getMaintenanceMode');
import '@web-api/persistence/postgres/cases/mocks.jest';
import {
CASE_STATUS_TYPES,
Role,
} from '@shared/business/entities/EntityConstants';
import { MOCK_PETITION } from '@shared/test/mockDocketEntry';
import { getAllFeatureFlagsInteractor as getAllFeatureFlagsInteractorMock } from '@web-api/business/useCases/featureFlag/getAllFeatureFlagsInteractor';
import { getCaseByDocketNumber as getCaseByDocketNumberMock } from '@web-api/persistence/dynamo/cases/getCaseByDocketNumber';
import { getCaseByDocketNumber as getCaseByDocketNumberMock } from '@web-api/persistence/postgres/cases/getCaseByDocketNumber';
import { getDocumentDownloadUrlLambda } from './getDocumentDownloadUrlLambda';
import { getDownloadPolicyUrl as getDownloadPolicyUrlMock } from '@web-api/persistence/s3/getDownloadPolicyUrl';
import { getMaintenanceMode as getMaintenanceModeMock } from '@web-api/persistence/dynamo/deployTable/getMaintenanceMode';
Expand Down

0 comments on commit 791817a

Please sign in to comment.