Skip to content

Commit

Permalink
9970: Fixing some of the shared tests, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Rogers committed Jul 6, 2023
1 parent f547b46 commit 77195bf
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 213 deletions.
10 changes: 4 additions & 6 deletions shared/src/business/entities/cases/Case.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { Case, getContactPrimary } from './Case';
import { Contact } from '../contacts/Contact';
import { MOCK_CASE } from '../../../test/mockCase';
import { MOCK_DOCUMENTS } from '../../../test/mockDocuments';
import { MOCK_TRIAL_REGULAR } from '../../../test/mockTrial';
import { RawTrialSession } from '../trialSessions/TrialSession';
import { applicationContext } from '../../test/createTestApplicationContext';
import { createISODateString } from '../../utilities/DateHandler';
import {
Expand Down Expand Up @@ -225,14 +227,10 @@ describe('Case entity', () => {

describe('hearings', () => {
it('sets associated hearings on the case hearings array, and make sure they are sorted by created date', () => {
const mockhearing1 = {
const mockhearing1: RawTrialSession = {
...MOCK_TRIAL_REGULAR,
createdAt: '2024-03-01T00:00:00.000Z',
maxCases: 100,
sessionType: 'Regular',
startDate: '2025-03-01T00:00:00.000Z',
term: 'Fall',
termYear: '2025',
trialLocation: 'Birmingham, Alabama',
};
const mockhearing2 = {
...mockhearing1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class OpenTrialSession extends TrialSession {
public thirtyDaysBeforeTrialFormatted: string; // TODO: should be a computed property

constructor(rawProps) {
super('OpenTrialSession');
super(rawProps);

const formattedStartDate = formatDateString(this.startDate, FORMATS.MMDDYY);
const trialStartDateString = prepareDateFromString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,6 @@ describe('TrialSession entity', () => {

expect(() => trialSession.validate()).not.toThrow();
});

it('should throw an error when the trialSession is invalid', () => {
const trialSession = TrialSessionFactory({}, applicationContext);

expect(() => trialSession.validate()).toThrow();
});
});

describe('isStandaloneRemote', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,5 @@ export class TrialSessionWorkingCopy extends JoiValidationEntity {
};
}
}

declare global {
type RawTrialSessionWorkingCopy = ExcludeMethods<TrialSessionWorkingCopy>;
}
export type RawTrialSessionWorkingCopy =
ExcludeMethods<TrialSessionWorkingCopy>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
CASE_STATUS_TYPES,
CASE_TYPES_MAP,
DOCKET_NUMBER_SUFFIXES,
TRIAL_SESSION_PROCEEDING_TYPES,
} from '../../entities/EntityConstants';
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_TRIAL_INPERSON } from '../../../test/mockTrial';
import { MOCK_WORK_ITEM } from '../../../test/mockWorkItem';
import { Message } from '../../entities/Message';
import { applicationContext } from '../../test/createTestApplicationContext';
Expand All @@ -20,29 +20,6 @@ import { faker } from '@faker-js/faker';
import { updateCaseAndAssociations } from './updateCaseAndAssociations';

describe('updateCaseAndAssociations', () => {
const MOCK_TRIAL_SESSION = {
address1: '123 Street Lane',
caseOrder: [
{ docketNumber: MOCK_CASE.docketNumber },
{ docketNumber: '123-45' },
],
city: 'Scottsburg',
judge: {
name: 'A Judge',
userId: '55f4fc65-b33e-4c04-8561-3e56d533f386',
},
maxCases: 100,
postalCode: '47130',
proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson,
sessionType: 'Regular',
startDate: '3000-03-01T00:00:00.000Z',
state: 'IN',
term: 'Fall',
termYear: '3000',
trialLocation: 'Birmingham, Alabama',
trialSessionId: '959c4338-0fac-42eb-b0eb-d53b8d0195cc',
};

let updateCaseMock = jest.fn();
let validMockCase;

Expand Down Expand Up @@ -211,15 +188,17 @@ describe('updateCaseAndAssociations', () => {
const caseToUpdate = {
...validMockCase,
docketNumber,
hearings: [{ ...MOCK_TRIAL_SESSION, trialSessionId: trialSessionIds[0] }],
hearings: [
{ ...MOCK_TRIAL_INPERSON, trialSessionId: trialSessionIds[0] },
],
};
const oldCase = {
...validMockCase,
docketNumber,
hearings: [
{ ...MOCK_TRIAL_SESSION, trialSessionId: trialSessionIds[0] },
{ ...MOCK_TRIAL_SESSION, trialSessionId: trialSessionIds[1] },
{ ...MOCK_TRIAL_SESSION, trialSessionId: trialSessionIds[2] },
{ ...MOCK_TRIAL_INPERSON, trialSessionId: trialSessionIds[0] },
{ ...MOCK_TRIAL_INPERSON, trialSessionId: trialSessionIds[1] },
{ ...MOCK_TRIAL_INPERSON, trialSessionId: trialSessionIds[2] },
],
};

Expand Down
36 changes: 3 additions & 33 deletions shared/src/business/useCases/getCaseDeadlinesInteractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ROLES,
} from '../entities/EntityConstants';
import { MOCK_CASE } from '../../test/mockCase';
import { MOCK_TRIAL_REMOTE } from '../../test/mockTrial';
import { User } from '../entities/User';
import { applicationContext } from '../test/createTestApplicationContext';
import { getCaseDeadlinesInteractor } from './getCaseDeadlinesInteractor';
Expand Down Expand Up @@ -176,39 +177,8 @@ describe('getCaseDeadlinesInteractor', () => {
docketNumber: '2000-20',
hearings: [
{
address1: '200 Second St NW',
caseOrder: [
{
addedToSessionAt: '2020-12-23T14:21:54.970Z',
calendarNotes: 'Remote Subpoena Hearing',
docketNumber: '2000-20',
isManuallyAdded: true,
},
],
city: 'Washington',
courthouseName: 'US Tax Courthouse',
createdAt: '2020-12-23T14:20:52.766Z',
entityName: 'TrialSession',
isCalendared: true,
judge: {
name: 'Carluzzo',
userId: 'a22f4615-1234-4321-9284-30af3e22e715',
},
maxCases: '100',
postalCode: '20217',
// missing proceedingType; should throw an error!
sessionType: 'Special',
startDate: '2021-01-27T05:00:00.000Z',
startTime: '13:00',
state: 'DC',
term: 'Winter',
termYear: '2021',
trialClerk: {
name: 'Aisha Miller',
userId: '1e68fefe-asdf-fdsa-b08d-d806dd85c979',
},
trialLocation: 'Washington, District of Columbia',
trialSessionId: 'bac57bdb-1123-3321-81e3-b6fb6c337c3c',
...MOCK_TRIAL_REMOTE,
proceedingType: undefined, // missing proceedingType; should throw an error!
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {
MOCK_ELIGIBLE_CASE,
MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS,
} from '../../../test/mockCase';
import {
ROLES,
TRIAL_SESSION_PROCEEDING_TYPES,
} from '../../entities/EntityConstants';
import { MOCK_TRIAL_REMOTE } from '../../../test/mockTrial';
import { ROLES } from '../../entities/EntityConstants';
import { User } from '../../entities/User';
import { applicationContext } from '../../test/createTestApplicationContext';
import { cloneDeep } from 'lodash';
Expand All @@ -16,16 +14,6 @@ describe('getEligibleCasesForTrialSessionInteractor', () => {
let mockCurrentUser;
let mockTrial;

const MOCK_TRIAL = {
maxCases: 100,
proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote,
sessionType: 'Regular',
startDate: '2025-12-01T00:00:00.000Z',
term: 'Fall',
termYear: '2025',
trialLocation: 'Birmingham, Alabama',
};

const MOCK_ASSOCIATED_CASE = {
...MOCK_CASE,
...MOCK_ELIGIBLE_CASE_WITH_PRACTITIONERS,
Expand All @@ -38,7 +26,7 @@ describe('getEligibleCasesForTrialSessionInteractor', () => {
userId: '6805d1ab-18d0-43ec-bafb-654e83405416',
});

mockTrial = MOCK_TRIAL;
mockTrial = MOCK_TRIAL_REMOTE;

applicationContext.getCurrentUser.mockImplementation(() => mockCurrentUser);
applicationContext
Expand Down Expand Up @@ -92,7 +80,7 @@ describe('getEligibleCasesForTrialSessionInteractor', () => {
const mockEligibleCase = cloneDeep(MOCK_ELIGIBLE_CASE);

mockTrial = {
...MOCK_TRIAL,
...MOCK_TRIAL_REMOTE,
caseOrder: [
{
docketNumber: MOCK_ASSOCIATED_CASE.docketNumber,
Expand Down
Loading

0 comments on commit 77195bf

Please sign in to comment.