Skip to content

Commit

Permalink
9970: Add specific entity names of trial sessions. Fix seed data for …
Browse files Browse the repository at this point in the history
…new trial sessions start date.
  • Loading branch information
Zachary Rogers committed Jul 7, 2023
1 parent 72f2441 commit 843cc94
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TrialSession } from './TrialSession';

export class ClosedTrialSession extends TrialSession {
constructor(rawSession: RawClosedTrialSession) {
super(rawSession);
super(rawSession, 'ClosedTrialSession');

this.sessionStatus = SESSION_STATUS_TYPES.closed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class NewTrialSession extends TrialSession {
public trialClerkId?: string;

constructor(rawSession: RawNewTrialSession, { applicationContext }) {
super(rawSession);
super(rawSession, 'NewTrialSession');

if (!applicationContext) {
throw new TypeError('applicationContext must be defined');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class OpenTrialSession extends TrialSession {
public thirtyDaysBeforeTrialFormatted: string; // TODO: should be a computed property

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

const formattedStartDate = formatDateString(this.startDate, FORMATS.MMDDYY);
const trialStartDateString = prepareDateFromString(
Expand Down
5 changes: 2 additions & 3 deletions shared/src/business/entities/trialSessions/TrialSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ export class TrialSession extends JoiValidationEntity {
courtReporter: JoiValidationConstants.STRING.max(100).optional(),
courthouseName: JoiValidationConstants.STRING.max(100).allow('').optional(),
createdAt: JoiValidationConstants.ISO_DATE.optional(),
entityName: JoiValidationConstants.STRING.valid('TrialSession').required(),
estimatedEndDate: JoiValidationConstants.ISO_DATE.optional()
.min(joi.ref('startDate'))
.allow(null),
Expand Down Expand Up @@ -231,8 +230,8 @@ export class TrialSession extends JoiValidationEntity {
trialSessionId: JoiValidationConstants.UUID.required(),
};

constructor(rawSession) {
super('TrialSession');
constructor(rawSession, entityName: string) {
super(entityName);

this.address1 = rawSession.address1;
this.address2 = rawSession.address2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ROLE_PERMISSIONS,
isAuthorized,
} from '../../../authorization/authorizationClientService';
import { TrialSession } from '../../entities/trialSessions/TrialSession';
import { TrialSessionFactory } from '../../entities/trialSessions/TrialSessionFactory';
import { TrialSessionInfoDTO } from '../../dto/trialSessions/TrialSessionInfoDTO';
import { UnauthorizedError } from '../../../errors/errors';

Expand Down Expand Up @@ -32,14 +32,13 @@ export const getTrialSessionsForJudgeInteractor = async (
session => session.judge?.userId === judgeId,
);

const validatedSessions = TrialSession.validateRawCollection(
judgeSessions as any,
{
applicationContext,
},
const validatedTrialSessions = judgeSessions.map(trialSession =>
TrialSessionFactory(trialSession, applicationContext)
.validate()
.toRawObject(),
);

return validatedSessions.map(
trialSession => new TrialSessionInfoDTO(trialSession as any),
return validatedTrialSessions.map(
trialSession => new TrialSessionInfoDTO(trialSession),
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ describe('getTrialSessionsInteractor', () => {

await expect(
getTrialSessionsInteractor(applicationContext),
).rejects.toThrow('The TrialSession entity was invalid.');
).rejects.toThrow(
'The OpenTrialSession entity was invalid. {"maxCases":"\'maxCases\' is required"}',
);
});

it('should return a list of validated trial sessions', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ROLE_PERMISSIONS,
isAuthorized,
} from '../../../authorization/authorizationClientService';
import { TrialSession } from '../../entities/trialSessions/TrialSession';
import { TrialSessionFactory } from '../../entities/trialSessions/TrialSessionFactory';
import { TrialSessionInfoDTO } from '../../dto/trialSessions/TrialSessionInfoDTO';
import { UnauthorizedError } from '../../../errors/errors';

Expand All @@ -21,11 +21,13 @@ export const getTrialSessionsInteractor = async (
applicationContext,
});

const validatedSessions = TrialSession.validateRawCollection(trialSessions, {
applicationContext,
});
const validatedTrialSessions = trialSessions.map(trialSession =>
TrialSessionFactory(trialSession, applicationContext)
.validate()
.toRawObject(),
);

return validatedSessions.map(
return validatedTrialSessions.map(
trialSession => new TrialSessionInfoDTO(trialSession),
);
};
30 changes: 15 additions & 15 deletions web-api/storage/fixtures/seed/efcms-local.json
Original file line number Diff line number Diff line change
Expand Up @@ -29760,7 +29760,7 @@
"name": "Cohen",
"userId": "dabbad04-18d0-43ec-bafb-654e83405416"
},
"startDate": "2019-12-02T05:00:00.000Z",
"startDate": "2040-12-02T05:00:00.000Z",
"maxCases": 30,
"trialSessionId": "0d943468-bc2e-4631-84e3-b084cf5b1fbb",
"isCalendared": false,
Expand Down Expand Up @@ -29806,7 +29806,7 @@
"name": "Cohen",
"userId": "dabbad04-18d0-43ec-bafb-654e83405416"
},
"startDate": "2020-12-02T05:00:00.000Z",
"startDate": "2040-12-02T05:00:00.000Z",
"maxCases": 8,
"trialSessionId": "149159ca-f4a1-4b2b-bc24-bd1fbe6defdc",
"isCalendared": false
Expand Down Expand Up @@ -29857,7 +29857,7 @@
"userId": "dabbad03-18d0-43ec-bafb-654e83405416"
},
"swingSession": true,
"startDate": "2020-11-25T05:00:00.000Z",
"startDate": "2040-11-25T05:00:00.000Z",
"maxCases": 6,
"trialSessionId": "208a959f-9526-4db5-b262-e58c476a4604",
"isCalendared": false
Expand All @@ -29879,7 +29879,7 @@
"name": "Cohen",
"userId": "dabbad04-18d0-43ec-bafb-654e83405416"
},
"startDate": "2019-12-02T05:00:00.000Z",
"startDate": "2040-12-02T05:00:00.000Z",
"maxCases": 8,
"trialSessionId": "259159ca-f4a1-4b2b-bc24-bd1fbe6defee",
"isCalendared": false,
Expand All @@ -29902,7 +29902,7 @@
"name": "Buch",
"userId": "dabbad02-18d0-43ec-bafb-654e83405416"
},
"startDate": "2019-11-02T05:00:00.000Z",
"startDate": "2060-11-02T05:00:00.000Z",
"maxCases": 8,
"trialSessionId": "259159ca-f4a1-4b2b-bc24-bd1fbe6defef",
"isCalendared": false,
Expand Down Expand Up @@ -30006,7 +30006,7 @@
"name": "Colvin",
"userId": "dabbad00-18d0-43ec-bafb-654e83405416"
},
"startDate": "2020-11-25T05:00:00.000Z",
"startDate": "2060-11-25T05:00:00.000Z",
"maxCases": 100,
"trialSessionId": "5b18af9e-4fbd-459b-8db7-7b15108c7fa5",
"isCalendared": false
Expand All @@ -30028,7 +30028,7 @@
"name": "Carluzzo",
"userId": "dabbad03-18d0-43ec-bafb-654e83405416"
},
"startDate": "2020-12-02T05:00:00.000Z",
"startDate": "2060-12-02T05:00:00.000Z",
"maxCases": 125,
"trialSessionId": "6b6975cf-2b10-4e84-bcae-91e162d2f9d1",
"isCalendared": false
Expand All @@ -30050,7 +30050,7 @@
"name": "Carluzzo",
"userId": "dabbad03-18d0-43ec-bafb-654e83405416"
},
"startDate": "2019-12-02T05:00:00.000Z",
"startDate": "2060-12-02T05:00:00.000Z",
"maxCases": 125,
"trialSessionId": "7c6975cf-2b10-4e84-bcae-91e162d2f9ee",
"isCalendared": false,
Expand Down Expand Up @@ -30144,7 +30144,7 @@
"name": "Cohen",
"userId": "dabbad04-18d0-43ec-bafb-654e83405416"
},
"startDate": "2020-12-02T05:00:00.000Z",
"startDate": "2060-12-02T05:00:00.000Z",
"maxCases": 30,
"trialSessionId": "9c943468-bc2e-4631-84e3-b084cf5b1faa",
"isCalendared": false
Expand All @@ -30166,7 +30166,7 @@
"name": "Buch",
"userId": "dabbad02-18d0-43ec-bafb-654e83405416"
},
"startDate": "2030-11-25T05:00:00.000Z",
"startDate": "2060-11-25T05:00:00.000Z",
"maxCases": 125,
"trialSessionId": "a1b04943-8ea8-422b-8990-dec3ca644c83",
"isCalendared": false
Expand All @@ -30190,7 +30190,7 @@
"userId": "dabbad03-18d0-43ec-bafb-654e83405416"
},
"swingSession": true,
"startDate": "2019-09-25T05:00:00.000Z",
"startDate": "2060-09-25T05:00:00.000Z",
"maxCases": 6,
"trialSessionId": "a3bee7c0-bd98-4504-890b-b00eb398e547",
"isCalendared": false,
Expand All @@ -30213,7 +30213,7 @@
"name": "Buch",
"userId": "dabbad02-18d0-43ec-bafb-654e83405416"
},
"startDate": "2019-09-25T05:00:00.000Z",
"startDate": "2060-09-25T05:00:00.000Z",
"maxCases": 125,
"trialSessionId": "b4bee7c0-bd98-4504-890b-b00eb398e547",
"isCalendared": false,
Expand All @@ -30236,7 +30236,7 @@
"name": "Colvin",
"userId": "dabbad00-18d0-43ec-bafb-654e83405416"
},
"startDate": "2019-09-25T05:00:00.000Z",
"startDate": "2060-09-25T05:00:00.000Z",
"maxCases": 100,
"trialSessionId": "c5bee7c0-bd98-4504-890b-b00eb398e547",
"isCalendared": false,
Expand All @@ -30261,7 +30261,7 @@
"userId": "dabbad00-18d0-43ec-bafb-654e83405416"
},
"swingSession": true,
"startDate": "2019-09-27T05:00:00.000Z",
"startDate": "2060-09-27T05:00:00.000Z",
"maxCases": 100,
"trialSessionId": "c7220f03-e46e-4d5e-8e1d-a640e64df552",
"isCalendared": false,
Expand All @@ -30284,7 +30284,7 @@
"name": "Buch",
"userId": "dabbad02-18d0-43ec-bafb-654e83405416"
},
"startDate": "2020-11-25T05:00:00.000Z",
"startDate": "2060-11-25T05:00:00.000Z",
"maxCases": 125,
"trialSessionId": "f3b04943-8ea8-422b-8990-dec3ca644c83",
"isCalendared": false
Expand Down
2 changes: 1 addition & 1 deletion web-client/integration-tests/dismissNOTTReminder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Dismiss NOTT reminder on calendared trial session within 30-35 day ran

expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions');

const trialSessionFormatted: any = runCompute(
const trialSessionFormatted = runCompute(
withAppContextDecorator(formattedTrialSessions),
{
state: cerebralTest.getState(),
Expand Down

0 comments on commit 843cc94

Please sign in to comment.