Skip to content

Commit

Permalink
10455-story: make old persistence method test-specific and remove it …
Browse files Browse the repository at this point in the history
…from applicationContext
  • Loading branch information
Mwindo committed Aug 19, 2024
1 parent 109d981 commit 3b5d3c9
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 133 deletions.
15 changes: 0 additions & 15 deletions shared/src/business/test/createTestApplicationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ import { getAllWebSocketConnections } from '@web-api/persistence/dynamo/notifica
import { getCaseByDocketNumber } from '@web-api/persistence/dynamo/cases/getCaseByDocketNumber';
import { getCaseDeadlinesByDocketNumber } from '@web-api/persistence/dynamo/caseDeadlines/getCaseDeadlinesByDocketNumber';
import { getCaseDocumentsIdsFilteredByDocumentType } from '@shared/business/utilities/getCaseDocumentsIdsFilteredByDocumentType';
import {
getChambersSections,
getChambersSectionsLabels,
getJudgesChambers,
getJudgesChambersWithLegacy,
} from '@web-client/business/chambers/getJudgesChambers';
import { getConfigurationItemValue } from '@web-api/persistence/dynamo/deployTable/getConfigurationItemValue';
import { getConstants } from '@web-client/getConstants';
import { getCropBox } from '@shared/business/utilities/getCropBox';
Expand Down Expand Up @@ -293,7 +287,6 @@ export const createTestApplicationContext = ({
.fn()
.mockImplementation(getFormattedTrialSessionDetails),
getJudgeLastName: jest.fn().mockImplementation(getJudgeLastName),
getJudgesChambers: jest.fn().mockImplementation(getJudgesChambers),
getMonthDayYearInETObj: jest
.fn()
.mockImplementation(DateHandler.getMonthDayYearInETObj),
Expand Down Expand Up @@ -500,10 +493,6 @@ export const createTestApplicationContext = ({
.fn()
.mockImplementation(getCaseDeadlinesByDocketNumber),
getCasesByFilters: jest.fn(),
getChambersSections: jest.fn().mockImplementation(getChambersSections),
getChambersSectionsLabels: jest
.fn()
.mockImplementation(getChambersSectionsLabels),
getConfigurationItemValue: jest
.fn()
.mockImplementation(getConfigurationItemValue),
Expand All @@ -526,10 +515,6 @@ export const createTestApplicationContext = ({
}
}),
getItem: jest.fn().mockImplementation(getItem),
getJudgesChambers: jest.fn().mockImplementation(getJudgesChambers),
getJudgesChambersWithLegacy: jest
.fn()
.mockImplementation(getJudgesChambersWithLegacy),
getLimiterByKey: jest.fn(),
getMaintenanceMode: jest.fn(),
getMessagesByDocketNumber: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ const JUDGES_CHAMBERS: Record<string, JudgeInfo> = omitBy(
chambers => chambers.isLegacy,
);

export const getJudgesChambers = () => {
export const getTestJudgesChambers = () => {
return JUDGES_CHAMBERS;
};

export const getJudgesChambersWithLegacy = () => {
export const getTestJudgesChambersWithLegacy = () => {
return {
...JUDGES_CHAMBERS,
LEGACY_JUDGES_CHAMBERS_SECTION: {
Expand All @@ -243,7 +243,7 @@ export const getJudgesChambersWithLegacy = () => {

export const getChambersSectionsLabels = () => {
const chambersSectionsLabels = [];
Object.keys(getJudgesChambers()).forEach(k => {
Object.keys(getTestJudgesChambers()).forEach(k => {
const chambers = JUDGES_CHAMBERS[k];
chambersSectionsLabels[chambers.section] = chambers.label;
});
Expand All @@ -252,7 +252,7 @@ export const getChambersSectionsLabels = () => {

export const getChambersSections = () => {
const chambersSections = [];
Object.keys(getJudgesChambers()).forEach(k => {
Object.keys(getTestJudgesChambers()).forEach(k => {
const chambers = JUDGES_CHAMBERS[k];
chambersSections.push(chambers.section);
});
Expand Down
14 changes: 8 additions & 6 deletions shared/src/test/mockUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import {
import { RawIrsPractitioner } from '@shared/business/entities/IrsPractitioner';
import { RawPractitioner } from '@shared/business/entities/Practitioner';
import { RawUser } from '@shared/business/entities/User';

import {
getJudgesChambers,
getJudgesChambersWithLegacy,
} from '../../../web-client/src/business/chambers/getJudgesChambers';
getTestJudgesChambers,
getTestJudgesChambersWithLegacy,
} from './mockJudgesChambers';

export const adminUser: RawUser = {
entityName: 'User',
Expand All @@ -35,7 +36,7 @@ export const adcUser = {
export const colvinsChambersUser = {
name: 'Chandler Chambers',
role: ROLES.chambers,
section: getJudgesChambers().COLVINS_CHAMBERS_SECTION.section,
section: getTestJudgesChambers().COLVINS_CHAMBERS_SECTION.section,
userId: '3d9fa032-ad00-475a-9183-8aa0229a31eb',
};

Expand Down Expand Up @@ -123,7 +124,8 @@ export const legacyJudgeUser: RawUser = {
entityName: 'User',
name: 'Legacy Judge Ginsburg',
role: ROLES.legacyJudge,
section: getJudgesChambersWithLegacy().LEGACY_JUDGES_CHAMBERS_SECTION.section,
section:
getTestJudgesChambersWithLegacy().LEGACY_JUDGES_CHAMBERS_SECTION.section,
userId: 'dc67e189-cf3e-4ca3-a33f-91db111ec270',
};

Expand All @@ -134,7 +136,7 @@ export const judgeColvin: RawUser = {
judgeFullName: 'John O. Colvin',
name: 'Colvin',
role: ROLES.judge,
section: getJudgesChambers().COLVINS_CHAMBERS_SECTION.section,
section: getTestJudgesChambers().COLVINS_CHAMBERS_SECTION.section,
userId: 'd17b07dc-6455-447e-bea3-f91d12ac5a6a',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '../../../../../shared/src/business/entities/EntityConstants';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import { getDocumentQCInboxForSectionInteractor } from './getDocumentQCInboxForSectionInteractor';
import { getTestJudgesChambers } from '../../../../../shared/src/test/mockJudgesChambers';

describe('getDocumentQCInboxForSectionInteractor', () => {
it('should throw an error when the user does not have permission to retrieve work items', async () => {
Expand Down Expand Up @@ -59,8 +60,7 @@ describe('getDocumentQCInboxForSectionInteractor', () => {

await getDocumentQCInboxForSectionInteractor(applicationContext, {
judgeUserName: 'Ashford',
section: applicationContext.getPersistenceGateway().getJudgesChambers()
.ASHFORDS_CHAMBERS_SECTION.section,
section: getTestJudgesChambers().ASHFORDS_CHAMBERS_SECTION.section,
});

expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { refreshElasticsearchIndex } from '../helpers';
import { runCompute } from '@web-client/presenter/test.cerebral';
import { withAppContextDecorator } from '../../src/withAppContext';

// TODO: 10455
const JUDGES_CHAMBERS = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { getTestJudgesChambers } from '@shared/test/mockJudgesChambers';
import { messageModalHelper as messageModalHelperComputed } from '../../src/presenter/computeds/messageModalHelper';
import { refreshElasticsearchIndex } from '../helpers';
import { runCompute } from '@web-client/presenter/test.cerebral';
import { withAppContextDecorator } from '../../src/withAppContext';

const JUDGES_CHAMBERS = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
const JUDGES_CHAMBERS = getTestJudgesChambers();
const messageModalHelper = withAppContextDecorator(messageModalHelperComputed);

export const petitionsClerkCreatesMessageToChambers = cerebralTest => {
Expand Down
6 changes: 2 additions & 4 deletions web-client/integration-tests/journey/userSendsMessage.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { getTestJudgesChambers } from '@shared/test/mockJudgesChambers';
import { messageModalHelper as messageModalHelperComputed } from '../../src/presenter/computeds/messageModalHelper';
import { refreshElasticsearchIndex } from '../helpers';
import { runCompute } from '@web-client/presenter/test.cerebral';
import { withAppContextDecorator } from '../../src/withAppContext';

const messageModalHelper = withAppContextDecorator(messageModalHelperComputed);
const JUDGES_CHAMBERS = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
const JUDGES_CHAMBERS = getTestJudgesChambers();

export const userSendsMessage = (
cerebralTest,
Expand Down
8 changes: 3 additions & 5 deletions web-client/integration-tests/messagesTableJourney.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CASE_STATUS_TYPES } from '../../shared/src/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { createNewMessageOnCase } from './journey/createNewMessageOnCase';
import { formattedMessages as formattedMessagesComputed } from '../src/presenter/computeds/formattedMessages';
import { getTestJudgesChambers } from '@shared/test/mockJudgesChambers';
import { loginAs, refreshElasticsearchIndex, setupTest } from './helpers';
import { runCompute } from '@web-client/presenter/test.cerebral';
import { userSendsMessage } from './journey/userSendsMessage';
Expand All @@ -18,9 +18,7 @@ describe('messages table journey', () => {
};
const messageSubjectForJudge = 'Check your recent messages!';

const judgesChambers = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
const JUDGES_CHAMBERS = getTestJudgesChambers();
const judgeCohenUserId = 'dabbad04-18d0-43ec-bafb-654e83405416';

const formattedMessages = withAppContextDecorator(formattedMessagesComputed);
Expand Down Expand Up @@ -159,7 +157,7 @@ describe('messages table journey', () => {
userSendsMessage(
cerebralTest,
messageSubjectForJudge,
judgesChambers.COHENS_CHAMBERS_SECTION.section,
JUDGES_CHAMBERS.COHENS_CHAMBERS_SECTION.section,
judgeCohenUserId,
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FORMATS } from '@shared/business/utilities/DateHandler';
import { MOTION_DISPOSITIONS } from '../../shared/src/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import {
contactPrimaryFromState,
fakeFile,
Expand All @@ -9,14 +8,12 @@ import {
uploadPetition,
waitForCondition,
} from './helpers';
import { getTestJudgesChambers } from '@shared/test/mockJudgesChambers';
import { userSendsMessage } from './journey/userSendsMessage';

describe('Stamp disposition judge journey test', () => {
const cerebralTest = setupTest();

const judgesChambers = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
const judgesChambers = getTestJudgesChambers();
const judgeCohenUserId = 'dabbad04-18d0-43ec-bafb-654e83405416';
const messageSubject = 'Motion to Stamp';
const deniedMotionDocketEntryTitle =
Expand Down
8 changes: 0 additions & 8 deletions web-client/src/applicationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ import { getCaseInventoryReportInteractor } from '../../shared/src/proxies/repor
import { getCaseWorksheetsByJudgeInteractor } from '@shared/proxies/reports/getCaseWorksheetsByJudgeProxy';
import { getCasesClosedByJudgeInteractor } from '../../shared/src/proxies/reports/getCasesClosedByJudgeProxy';
import { getCasesForUserInteractor } from '../../shared/src/proxies/getCasesForUserProxy';
import {
getChambersSections,
getChambersSectionsLabels,
getJudgesChambers,
} from './business/chambers/getJudgesChambers';
import { getClinicLetterKey } from '../../shared/src/business/utilities/getClinicLetterKey';
import { getColdCaseReportInteractor } from '../../shared/src/proxies/reports/getColdCaseReportProxy';
import { getCompletedMessagesForSectionInteractor } from '../../shared/src/proxies/messages/getCompletedMessagesForSectionProxy';
Expand Down Expand Up @@ -701,8 +696,6 @@ const applicationContext = {
},
getPersistenceGateway: () => {
return {
getChambersSections,
getChambersSectionsLabels,
getDocument,
getItem,
getPdfFromUrl,
Expand Down Expand Up @@ -781,7 +774,6 @@ const applicationContext = {
getFormattedPartiesNameAndTitle,
getFormattedTrialSessionDetails,
getJudgeLastName,
getJudgesChambers,
getMonthDayYearInETObj,
getOtherFilers,
getPetitionDocketEntry,
Expand Down
45 changes: 0 additions & 45 deletions web-client/src/business/chambers/getJudgesChambers.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const computeSubmitTrialSessionDataAction = ({
}: ActionProps) => {
const form = get(state.form);

console.log('WTF??');

computeTermAndUpdateState(
{ startDate: form.startDate },
store,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ export const computeTrialSessionFormDataAction = ({
store.set(state.form.judgeId, selectedJudge.userId);
store.set(state.form.judge, selectedJudge);

const JUDGES_CHAMBERS = applicationContext
.getUtilities()
.getJudgesChambers();
const JUDGES_CHAMBERS = get(state.judgesChambers);

const judge = Object.values(JUDGES_CHAMBERS).find(
const judge = JUDGES_CHAMBERS.find(
({ section }) => section === selectedJudge.section,
);

Expand All @@ -119,6 +117,7 @@ export const computeTrialSessionFormDataAction = ({
);
}

// TODO 10455 phone number
store.set(state.form.chambersPhoneNumber, judge.phoneNumber);
}

Expand Down
6 changes: 3 additions & 3 deletions web-client/src/presenter/actions/getJudgesChambersAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export const getJudgesChambersAction = async ({
return { judgesChambers: judgesChambersCached };
}

const users = await applicationContext
const judgesChambers = await applicationContext
.getUseCases()
.getJudgesChambersInteractor(applicationContext);

console.log('Getting the chambers', users);
console.log('Getting the chambers', judgesChambers);
return {
judgesChambers: sortBy(users, 'label'),
judgesChambers: sortBy(judgesChambers, 'label'),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import {
petitionsClerkUser,
trialClerkUser,
} from '../../../../shared/src/test/mockUsers';
import { getTestJudgesChambers } from '../../../../shared/src/test/mockJudgesChambers';
import { getUserIsAssignedToSession } from './formattedCaseDetail';
import { runCompute } from '@web-client/presenter/test.cerebral';

const JUDGES_CHAMBERS = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
const JUDGES_CHAMBERS = getTestJudgesChambers();

describe('formattedCaseDetail getUserIsAssignedToSession', () => {
const mockTrialSessionId = applicationContext.getUniqueId();
Expand Down
7 changes: 4 additions & 3 deletions web-client/src/presenter/computeds/messageModalHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SECTIONS,
} from '../../../../shared/src/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { getTestJudgesChambers } from '../../../../shared/src/test/mockJudgesChambers';
import { messageModalHelper as messageModalHelperComputed } from './messageModalHelper';
import { runCompute } from '@web-client/presenter/test.cerebral';
import { withAppContextDecorator } from '../../withAppContext';
Expand All @@ -16,9 +17,7 @@ describe('messageModalHelper', () => {
};
const mockDocketEntryIdOnDocketRecord = '123';
const mockDocketEntryIdAlsoOnDocketRecord = '234';
const JUDGES_CHAMBERS = applicationContext
.getPersistenceGateway()
.getJudgesChambers();
const JUDGES_CHAMBERS = getTestJudgesChambers();

const mockDocketEntryWithFileAttachedOnDocketRecord = {
descriptionDisplay: 'Hello with additional info',
Expand Down Expand Up @@ -484,6 +483,7 @@ describe('messageModalHelper', () => {
{
state: {
caseDetail: {},
judgesChambers: Object.values(JUDGES_CHAMBERS),
modal: {
form: {
attachments: [{}, {}], // 2/2 documents attached
Expand All @@ -509,6 +509,7 @@ describe('messageModalHelper', () => {
{
state: {
...baseState,
judgesChambers: Object.values(JUDGES_CHAMBERS),
modal: {
form: {
attachments: [{}],
Expand Down
Loading

0 comments on commit 3b5d3c9

Please sign in to comment.