Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10076: DOD #10115

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5a14018
10076: Refactor calculating if document meets visibility policy chang…
rachelschneiderman Jul 28, 2023
bb1d90b
10076: Refactoring format public docket entries for readability
rachelschneiderman Jul 28, 2023
a0fbd81
10076: Call new method for determining visibility, DRYing up code
rachelschneiderman Jul 28, 2023
da23f14
10076: Call new method for determining visibility, DRYing up code
rachelschneiderman Jul 28, 2023
44b2a25
Merge branch '10076-dod-refactoring' of https://github.com/flexion/ef…
rachelschneiderman Jul 28, 2023
6f00157
10076: Helper no longer exports this unneeded property, remove from test
rachelschneiderman Jul 28, 2023
6adf96f
10076: More cleanup and readability refactoring
rachelschneiderman Jul 28, 2023
cf5fd6d
Merge branch 'staging' of https://github.com/ustaxcourt/ef-cms into 1…
rachelschneiderman Jul 31, 2023
b05e850
10076: Set event code to MISCL when document has been lodged
rachelschneiderman Jul 31, 2023
e12b2ca
10076 - Call DocketEntry method
rachelschneiderman Jul 31, 2023
16cd417
10076 - add unit tests
rachelschneiderman Jul 31, 2023
ccf3d1b
10076: Set filings and proceedings correctly for public docket entries
rachelschneiderman Jul 31, 2023
59027a3
10076 - fix test
rachelschneiderman Jul 31, 2023
00d61ab
10076: fixing type errors
rachelschneiderman Jul 31, 2023
021e3de
10076: Fixing more type errors
rachelschneiderman Jul 31, 2023
4e96265
Merge branch 'staging' of https://github.com/ustaxcourt/ef-cms into 1…
rachelschneiderman Jul 31, 2023
925576f
10076: Cerebral demands we name state state and not statePublic or an…
rachelschneiderman Jul 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ module.exports = {
'semibold',
'seriatim',
'serverless',
'servable',
'servoss',
'sisqo',
'skipnav',
Expand Down
12 changes: 5 additions & 7 deletions shared/src/authorization/getUserPermissions.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { ROLES } from '../business/entities/EntityConstants';
import { ROLE_PERMISSIONS } from './authorizationClientService';
import { docketClerk1User } from '../test/mockUsers';
import { getUserPermissions } from './getUserPermissions';

describe('getUserPermissions', () => {
it('returns an object containing ROLE_PERMISSIONS and a boolean value based on the given user role', () => {
const user = {
role: ROLES.docketClerk,
};
const permissions = getUserPermissions(docketClerk1User);

const permissions = getUserPermissions(user);
const permissionsKeys = Object.keys(permissions);
const permissionsKeys = Object.keys(permissions!);
expect(permissionsKeys.length).toEqual(
Object.keys(ROLE_PERMISSIONS).length,
);
expect(typeof permissions[permissionsKeys[0]]).toEqual('boolean');
expect(typeof permissions![permissionsKeys[0]]).toEqual('boolean');
});

it('returns undefined when a user is not provided', () => {
const permissions = getUserPermissions();

expect(permissions).toEqual(undefined);
});
});
4 changes: 3 additions & 1 deletion shared/src/authorization/getUserPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { ROLE_PERMISSIONS, isAuthorized } from './authorizationClientService';
* @param {object} user the user to check for authorization
* @returns {object|void} ROLE_PERMISSIONS keys with boolean value based on user role
*/
export const getUserPermissions = user => {
export const getUserPermissions = (
user?: RawUser | RawPractitioner | RawIrsPractitioner,
) => {
if (user) {
const permissions = {};
Object.keys(ROLE_PERMISSIONS).forEach(key => {
Expand Down
14 changes: 7 additions & 7 deletions shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import {
} from '../../entities/trialSessions/TrialSession';

export class TrialSessionInfoDTO {
public estimatedEndDate: string;
public estimatedEndDate?: string;
public isCalendared: boolean;
public judge: TJudge;
public judge?: TJudge;
public proceedingType: string;
public sessionType: string;
public startDate: string;
public startTime: string;
public startTime?: string;
public term: string;
public termYear: string;
public trialLocation: string;
public trialSessionId: string;
public noticeIssuedDate: string;
public trialLocation?: string;
public trialSessionId?: string;
public noticeIssuedDate?: string;
public sessionScope: string;
public sessionStatus: string;
public swingSession: boolean;
public swingSession?: boolean;
public dismissedAlertForNOTT?: boolean;
public isStartDateWithinNOTTReminderRange?: boolean;
public thirtyDaysBeforeTrialFormatted?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocketEntry } from './DocketEntry';
import { MOCK_DOCUMENTS } from '../../test/mockDocuments';
import { MOCK_DOCUMENTS } from '../../test/mockDocketEntry';
import { NOTICE_OF_CHANGE_CONTACT_INFORMATION_MAP } from './EntityConstants';
import { applicationContext } from '../test/createTestApplicationContext';

Expand Down
23 changes: 23 additions & 0 deletions shared/src/business/entities/DocketEntry.isMinuteEntry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { DocketEntry } from './DocketEntry';
import { MINUTE_ENTRIES_MAP } from './EntityConstants';
import { applicationContext } from '../test/createTestApplicationContext';

describe('isMinuteEntry', () => {
it('should return true when the docketEntry eventCode is in the list of minute entries', () => {
const minuteEntry = new DocketEntry(
{ eventCode: MINUTE_ENTRIES_MAP.captionOfCaseIsAmended.eventCode },
{ applicationContext },
);

expect(DocketEntry.isMinuteEntry(minuteEntry)).toBe(true);
});

it('should return false when the docketEntry eventCode is NOT in the list of minute entries', () => {
const orderDocketEntry = new DocketEntry(
{ eventCode: 'O' }, // O is the event code for orders, they are NOT minute entries
{ applicationContext },
);

expect(DocketEntry.isMinuteEntry(orderDocketEntry)).toBe(false);
});
});
32 changes: 32 additions & 0 deletions shared/src/business/entities/DocketEntry.isUnservable.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { DocketEntry } from './DocketEntry';
import { MINUTE_ENTRIES_MAP, UNSERVABLE_EVENT_CODES } from './EntityConstants';
import { applicationContext } from '../test/createTestApplicationContext';

describe('isUnservable', () => {
it('should return true when the docketEntry eventCode is in the list of minute entries', () => {
const minuteEntry = new DocketEntry(
{ eventCode: MINUTE_ENTRIES_MAP.captionOfCaseIsAmended.eventCode },
{ applicationContext },
);

expect(DocketEntry.isUnservable(minuteEntry)).toBe(true);
});

it('should return true when the docketEntry event code is in the list of unservable event codes', () => {
const unservableDocketEntry = new DocketEntry(
{ eventCode: UNSERVABLE_EVENT_CODES[0] },
{ applicationContext },
);

expect(DocketEntry.isUnservable(unservableDocketEntry)).toBe(true);
});

it('should return false when the docketEntry event code is NOT in the list of unservable event codes and it is NOT a minute entry', () => {
const servableDocketEntry = new DocketEntry(
{ eventCode: 'O' }, // O is the Order event code, Orders are servable and NOT minute entries
{ applicationContext },
);

expect(DocketEntry.isUnservable(servableDocketEntry)).toBe(false);
});
});
32 changes: 22 additions & 10 deletions shared/src/business/entities/DocketEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DOCUMENT_NOTICE_EVENT_CODES,
DOCUMENT_PROCESSING_STATUS_OPTIONS,
EXTERNAL_DOCUMENT_TYPES,
MINUTE_ENTRIES_MAP,
NOTICE_OF_CHANGE_CONTACT_INFORMATION_EVENT_CODES,
PARTIES_CODES,
PRACTITIONER_ASSOCIATION_DOCUMENT_TYPES,
Expand All @@ -21,7 +22,6 @@ import {
} from '../utilities/DateHandler';

export class DocketEntry extends JoiValidationEntity {
public entityName: string;
public action?: string;
public additionalInfo?: string;
public additionalInfo2?: string;
Expand Down Expand Up @@ -83,17 +83,17 @@ export class DocketEntry extends JoiValidationEntity {
public strickenAt?: string;
public trialLocation?: string;
public supportingDocument?: string;
public userId: string;
public userId?: string;
public privatePractitioners?: any[];
public servedParties?: any[];
public signedAt?: string;
public draftOrderState: object;
public stampData: object;
public draftOrderState?: object;
public stampData!: object;
public isDraft?: boolean;
public redactionAcknowledgement?: boolean;
public judge?: string;
public judgeUserId?: string;
public pending: boolean;
public pending?: boolean;
public previousDocument?: {
docketEntryId: string;
documentTitle: string;
Expand Down Expand Up @@ -123,6 +123,7 @@ export class DocketEntry extends JoiValidationEntity {
},
) {
super('DocketEntry');

if (!applicationContext) {
throw new TypeError('applicationContext must be defined');
}
Expand Down Expand Up @@ -439,11 +440,7 @@ export class DocketEntry extends JoiValidationEntity {
);
}

/**
* Determines if the docket entry is a court issued document
* @returns {Boolean} true if the docket entry is a court issued document, false otherwise
*/
isCourtIssued() {
isCourtIssued(): boolean {
return DocketEntry.isCourtIssued(this.eventCode);
}

Expand Down Expand Up @@ -539,9 +536,24 @@ export class DocketEntry extends JoiValidationEntity {
};
}

static isMinuteEntry(rawDocketEntry: RawDocketEntry): boolean {
const MINUTE_ENTRIES_EVENT_CODES = Object.keys(MINUTE_ENTRIES_MAP).map(
key => MINUTE_ENTRIES_MAP[key].eventCode,
);

return MINUTE_ENTRIES_EVENT_CODES.includes(rawDocketEntry.eventCode);
}

static isServed(rawDocketEntry: RawDocketEntry): boolean {
return !!rawDocketEntry.servedAt || !!rawDocketEntry.isLegacyServed;
}

static isUnservable(rawDocketEntry: RawDocketEntry): boolean {
return (
DocketEntry.isMinuteEntry(rawDocketEntry) ||
UNSERVABLE_EVENT_CODES.includes(rawDocketEntry.eventCode)
);
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions shared/src/business/entities/EntityConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ export const PUBLIC_DOCKET_RECORD_FILTER_OPTIONS = omit(
DOCKET_RECORD_FILTER_OPTIONS,
['exhibits'],
);
export const FILTER_OPTIONS = Object.values(
PUBLIC_DOCKET_RECORD_FILTER_OPTIONS,
);
export type PUBLIC_DOCKET_RECORD_FILTER = (typeof FILTER_OPTIONS)[number];

// TODO: should come from internal or external filing event
export const INITIAL_DOCUMENT_TYPES = {
Expand Down
23 changes: 18 additions & 5 deletions shared/src/business/entities/Statistic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('Statistic', () => {
'applicationContext must be defined',
);
});

describe('validation', () => {
it("fails validation if a yearOrPeriod is not 'year' or 'period'", () => {
const statistic = new Statistic(
Expand All @@ -16,8 +17,9 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeFalsy();
expect(Object.keys(statistic.getFormattedValidationErrors())).toContain(
expect(Object.keys(statistic.getFormattedValidationErrors()!)).toContain(
'yearOrPeriod',
);
});
Expand All @@ -39,6 +41,7 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeTruthy();
});

Expand All @@ -59,8 +62,9 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeFalsy();
expect(Object.keys(statistic.getFormattedValidationErrors())).toEqual([
expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([
'irsDeficiencyAmount',
'irsTotalPenalties',
'year',
Expand All @@ -78,6 +82,7 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeFalsy();
expect(statistic.getFormattedValidationErrors()).toMatchObject({
lastDateOfPeriod: (
Expand All @@ -103,8 +108,9 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeFalsy();
expect(Object.keys(statistic.getFormattedValidationErrors())).toEqual([
expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([
'year',
]);
});
Expand All @@ -127,6 +133,7 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeTruthy();
});

Expand All @@ -149,6 +156,7 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeTruthy();
});

Expand All @@ -171,8 +179,9 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeFalsy();
expect(Object.keys(statistic.getFormattedValidationErrors())).toEqual([
expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([
'determinationDeficiencyAmount',
]);
});
Expand All @@ -196,8 +205,9 @@ describe('Statistic', () => {
},
{ applicationContext },
);

expect(statistic.isValid()).toBeFalsy();
expect(Object.keys(statistic.getFormattedValidationErrors())).toEqual([
expect(Object.keys(statistic.getFormattedValidationErrors()!)).toEqual([
'determinationTotalPenalties',
]);
});
Expand Down Expand Up @@ -258,6 +268,7 @@ describe('Statistic', () => {
applicationContext,
rawPenalty: MOCK_PENALTY_WITH_STATISTIC_ID,
});

expect(statistic.penalties.length).toEqual(penaltyArrayLength + 1);
expect(statistic.penalties[1]).toEqual(MOCK_PENALTY_WITH_STATISTIC_ID);
});
Expand Down Expand Up @@ -313,6 +324,7 @@ describe('Statistic', () => {
statisticId,
},
];

expect(preItemizationStatistic.penalties).toEqual([
expect.objectContaining(expectedPenalties[0]),
expect.objectContaining(expectedPenalties[1]),
Expand Down Expand Up @@ -340,6 +352,7 @@ describe('Statistic', () => {
statisticId,
},
];

expect(preItemizationStatistic.penalties).toEqual([
expect.objectContaining(expectedPenalties[0]),
]);
Expand Down
3 changes: 2 additions & 1 deletion shared/src/business/entities/User.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe('User entity', () => {
phone: '1234567890',
},
});
expect(user.contact.phone).toEqual('123-456-7890');

expect(user.contact!.phone).toEqual('123-456-7890');
});

it('Creates a valid petitioner user without address2 or address3', () => {
Expand Down
6 changes: 3 additions & 3 deletions shared/src/business/entities/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export class User extends JoiValidationEntity {
public pendingEmailVerificationToken?: string;
public email: string;
public name: string;
public pendingEmail: string;
public pendingEmail?: string;
public role: string;
public token: string;
public token?: string;
public userId: string;
public isUpdatingInformation: string;
public isUpdatingInformation?: boolean;
public contact?: {
address1: string;
address2: string;
Expand Down
Loading
Loading