Skip to content

Commit

Permalink
Merge pull request #5592 from flexion/10525-test-bugfix
Browse files Browse the repository at this point in the history
10525: Fix minor PDF generated UI fix + back merge;
  • Loading branch information
nechama-krigsman authored Nov 25, 2024
2 parents 0620e69 + 7b22236 commit 438df35
Show file tree
Hide file tree
Showing 29 changed files with 5,036 additions and 7,203 deletions.
12,006 changes: 4,885 additions & 7,121 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions shared/src/business/entities/EntityConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import courtIssuedEventCodesJson from '../../tools/courtIssuedEventCodes.json';
import externalFilingEventsJson from '../../tools/externalFilingEvents.json';
import internalFilingEventsJson from '../../tools/internalFilingEvents.json';

export const KEYS = {
DOCKET_RECORD_TABLE_SORT: 'DOCKET_RECORD_TABLE_SORT',
export const STATE_KEYS = {
DOCKET_RECORD_TABLE_SORT:
'DOCKET_RECORD_TABLE_SORT' as 'DOCKET_RECORD_TABLE_SORT',
};

export const DEBOUNCE_TIME_MILLISECONDS = 500;
Expand Down
14 changes: 14 additions & 0 deletions shared/src/business/entities/trialSessions/SpecialTrialSessions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type SpecialTrialSession = {
userId: string;
trialSessionId: string;
};

export type SpecialTrialSessionKey = {
pk: string;
sk: string;
};

export type TrialSessionWorkingCopyNotes = {
sessionNotes: string;
trialSessionId: string;
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
SpecialTrialSession,
TrialSessionWorkingCopyNotes,
} from '@shared/business/entities/trialSessions/SpeciailTrialSessions';
} from '@shared/business/entities/trialSessions/SpecialTrialSessions';
import { post } from '../requests';

export const getBulkSpecialTrialSessionCopyNotesInteractor = (
Expand Down
3 changes: 0 additions & 3 deletions tmp.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,39 @@ describe('generateDocketRecordPdfInteractor', () => {
},
]);
});

it('should default numberOfPages to 0 to correctly sort the docket entries', async () => {
caseDetail.docketEntries = [
{ index: 1, isOnDocketRecord: true, numberOfPages: 1 },
{ index: 2, isOnDocketRecord: true, numberOfPages: 3 },
{ index: 3, isOnDocketRecord: true, numberOfPages: undefined },
];

await generateDocketRecordPdfInteractor(
applicationContext,
{
docketNumber: caseDetail.docketNumber,
docketRecordTableSort: {
sortField: 'numberOfPages',
sortOrder: 'asc',
},
isIndirectlyAssociated: true,
} as any,
mockPetitionerUser,
);

const docketRecordCalls =
applicationContext.getDocumentGenerators().docketRecord.mock.calls;
expect(docketRecordCalls.length).toEqual(1);

const {
data: { entries },
} = docketRecordCalls[0][0];
expect(entries).toMatchObject([
{ index: 3, isOnDocketRecord: true, numberOfPages: 0 },
{ index: 1, isOnDocketRecord: true, numberOfPages: 1 },
{ index: 2, isOnDocketRecord: true, numberOfPages: 3 },
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ export const generateDocketRecordPdfInteractor = async (
docketRecordSort,
});

formattedCaseDetail.formattedDocketEntries =
formattedCaseDetail.formattedDocketEntries.map(docketEntry => ({
...docketEntry,
numberOfPages: docketEntry.numberOfPages || 0,
}));

const sortedDocketEntries = sortDocketEntryTable(
formattedCaseDetail.formattedDocketEntries,
docketRecordTableSort && docketRecordTableSort.sortField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
SpecialTrialSession,
SpecialTrialSessionKey,
TrialSessionWorkingCopyNotes,
} from '@shared/business/entities/trialSessions/SpeciailTrialSessions';
} from '@shared/business/entities/trialSessions/SpecialTrialSessions';
import { UnauthorizedError } from '@web-api/errors/errors';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TDynamoRecord } from '../dynamoTypes';
import { TrialSessionWorkingCopyNotes } from '@shared/business/entities/trialSessions/SpeciailTrialSessions';
import { TrialSessionWorkingCopyNotes } from '@shared/business/entities/trialSessions/SpecialTrialSessions';
import { batchGet } from '../../dynamodbClientService';

export const getBulkTrialSessionWorkingCopies = async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ClientPublicApplicationContext } from '@web-client/applicationContextPublic';
import { KEYS } from '@shared/business/entities/EntityConstants';
import { STATE_KEYS } from '@shared/business/entities/EntityConstants';
import { state } from '@web-client/presenter/app-public.cerebral';
/**
* invokes the generate public docket record endpoint to get back the pdf url
Expand All @@ -13,10 +13,10 @@ export const generatePublicDocketRecordPdfUrlAction = async ({
}: ActionProps<{}, ClientPublicApplicationContext>) => {
const docketNumber = get(state.caseDetail.docketNumber);
const docketRecordSortField = get(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
);
const docketRecordSortOrder = get(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder,
);

const { url } = await applicationContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SESSION_TYPES } from '@shared/business/entities/EntityConstants';
import {
SpecialTrialSession,
TrialSessionWorkingCopyNotes,
} from '@shared/business/entities/trialSessions/SpeciailTrialSessions';
} from '@shared/business/entities/trialSessions/SpecialTrialSessions';
const getSpecialTrialSessions = trialSessions =>
trialSessions
.filter(trialSession => trialSession.sessionType === SESSION_TYPES.special)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KEYS } from '@shared/business/entities/EntityConstants';
import { STATE_KEYS } from '@shared/business/entities/EntityConstants';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
import { generateDocketRecordPdfUrlAction } from './generateDocketRecordPdfUrlAction';
import { presenter } from '../presenter-mock';
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('generateDocketRecordPdfUrlAction', () => {
caseDetail: {
docketNumber: '123-45',
},
[KEYS.DOCKET_RECORD_TABLE_SORT]: {
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {
sortField: 'sortField_test',
sortOrder: 'sortOrder_test',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KEYS } from '@shared/business/entities/EntityConstants';
import { STATE_KEYS } from '@shared/business/entities/EntityConstants';
import { state } from '@web-client/presenter/app.cerebral';
/**
* get the pdf file and pdf blob url from the passed in htmlString
Expand All @@ -18,10 +18,10 @@ export const generateDocketRecordPdfUrlAction = async ({
);

const docketRecordSortField = get(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
);
const docketRecordSortOrder = get(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder,
);

const { isAssociated } = props;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { KEYS } from '@shared/business/entities/EntityConstants';
import { STATE_KEYS } from '@shared/business/entities/EntityConstants';
import { state } from '@web-client/presenter/app.cerebral';

export const setDefaultDocketEntriesTableSortAction = ({
store,
}: ActionProps) => {
store.set(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
'sortingFilingDate',
);
store.set(state[KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder, 'asc');
store.set(state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder, 'asc');
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('setTableSortConfigurationAction', () => {
props: { sortField: 'createdAt', sortOrder: ASCENDING },
state: {
tableSort: {
sortField: 'recievedAt',
sortField: 'receivedAt',
sortOrder: DESCENDING,
},
},
Expand All @@ -24,9 +24,13 @@ describe('setTableSortConfigurationAction', () => {
});

it('should set the field to sort and the sort order in the correct root', async () => {
const TEST_ROOT = 'TEST_ROOT';
const STATE_KEY = 'STATE_KEY';
const { state } = await runAction(setTableSortConfigurationAction, {
props: { root: TEST_ROOT, sortField: 'createdAt', sortOrder: ASCENDING },
props: {
sortField: 'createdAt',
sortOrder: ASCENDING,
stateKey: STATE_KEY,
},
state: {
tableSort: {
sortField: 'recievedAt',
Expand All @@ -35,7 +39,7 @@ describe('setTableSortConfigurationAction', () => {
},
});

expect(state[TEST_ROOT]).toEqual({
expect(state[STATE_KEY]).toEqual({
sortField: 'createdAt',
sortOrder: ASCENDING,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export const setTableSortConfigurationAction = ({
}: ActionProps<{
sortField: string;
sortOrder: 'asc' | 'desc';
root?: string;
stateKey?: string;
}>) => {
const { root, sortField, sortOrder } = props;
const { sortField, sortOrder, stateKey } = props;

const ROOT = root || 'tableSort';
store.set(state[ROOT].sortField, sortField);
store.set(state[ROOT].sortOrder, sortOrder);
const STATE_KEY = stateKey || 'tableSort';
store.set(state[STATE_KEY].sortField, sortField);
store.set(state[STATE_KEY].sortOrder, sortOrder);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
AMICUS_BRIEF_EVENT_CODE,
DOCKET_ENTRY_SEALED_TO_TYPES,
DOCUMENT_PROCESSING_STATUS_OPTIONS,
KEYS,
PARTIES_CODES,
POLICY_DATE_IMPACTED_EVENTCODES,
PUBLIC_DOCKET_RECORD_FILTER_OPTIONS,
ROLES,
STATE_KEYS,
STIPULATED_DECISION_EVENT_CODE,
UNSERVABLE_EVENT_CODES,
} from '@shared/business/entities/EntityConstants';
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('publicCaseDetailHelper', () => {
sessionMetadata: {
docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments,
},
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
};
});

Expand Down Expand Up @@ -255,7 +255,7 @@ describe('publicCaseDetailHelper', () => {
});

it('should be sorted newer to older when sort order is by date desc', () => {
state[KEYS.DOCKET_RECORD_TABLE_SORT] = {
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT] = {
sortField: 'sortingFilingDate',
sortOrder: 'desc',
};
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('publicCaseDetailHelper', () => {
const result = runCompute(publicCaseDetailHelper, {
state: {
caseDetail,
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
sessionMetadata: {
docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.orders,
},
Expand All @@ -407,7 +407,7 @@ describe('publicCaseDetailHelper', () => {
const result = runCompute(publicCaseDetailHelper, {
state: {
caseDetail,
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
sessionMetadata: {
docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.motions,
},
Expand All @@ -424,7 +424,7 @@ describe('publicCaseDetailHelper', () => {
const result = runCompute(publicCaseDetailHelper, {
state: {
caseDetail,
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
sessionMetadata: {
docketRecordFilter:
PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments,
Expand Down Expand Up @@ -1425,7 +1425,7 @@ describe('publicCaseDetailHelper', () => {
canAllowPrintableDocketRecord: true,
docketEntries: [],
},
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
sessionMetadata: {
docketRecordFilter:
PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments,
Expand All @@ -1442,7 +1442,7 @@ describe('publicCaseDetailHelper', () => {
canAllowPrintableDocketRecord: false,
docketEntries: [],
},
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
sessionMetadata: {
docketRecordFilter:
PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments,
Expand Down Expand Up @@ -1484,7 +1484,7 @@ describe('formatDocketEntryOnDocketRecord', () => {
mockCase = cloneDeep(MOCK_CASE);
state = {
caseDetail: mockCase,
[KEYS.DOCKET_RECORD_TABLE_SORT]: {},
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {},
sessionMetadata: {
docketRecordFilter: PUBLIC_DOCKET_RECORD_FILTER_OPTIONS.allDocuments,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable complexity */
import {
ALLOWLIST_FEATURE_FLAGS,
KEYS,
PUBLIC_DOCKET_RECORD_FILTER,
PUBLIC_DOCKET_RECORD_FILTER_OPTIONS,
ROLES,
STATE_KEYS,
} from '../../../../../shared/src/business/entities/EntityConstants';
import { ClientApplicationContext } from '@web-client/applicationContext';
import { DocketEntry } from '../../../../../shared/src/business/entities/DocketEntry';
Expand Down Expand Up @@ -180,7 +180,9 @@ export const publicCaseDetailHelper = (
const { canAllowPrintableDocketRecord, docketEntries, isSealed } = rawCase;

const isTerminalUser = get(state.isTerminalUser);
const { sortField, sortOrder } = get(state[KEYS.DOCKET_RECORD_TABLE_SORT]);
const { sortField, sortOrder } = get(
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT],
);

const { docketRecordFilter } = get(state.sessionMetadata);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
ALLOWLIST_FEATURE_FLAGS,
DOCKET_ENTRY_SEALED_TO_TYPES,
DOCKET_RECORD_FILTER_OPTIONS,
KEYS,
ROLES,
STATE_KEYS,
} from '../../../../shared/src/business/entities/EntityConstants';
import { MOCK_CASE } from '../../../../shared/src/test/mockCase';
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext';
Expand Down Expand Up @@ -1171,7 +1171,7 @@ describe('formattedDocketEntries', () => {
...MOCK_CASE,
docketEntries: TEST_DOCKET_ENTRIES,
},
[KEYS.DOCKET_RECORD_TABLE_SORT]: {
[STATE_KEYS.DOCKET_RECORD_TABLE_SORT]: {
sortField: 'testProp',
sortOrder: 'desc',
},
Expand Down
8 changes: 4 additions & 4 deletions web-client/src/presenter/computeds/formattedDocketEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ClientApplicationContext } from '@web-client/applicationContext';
import { DocketEntry } from '@shared/business/entities/DocketEntry';
import { Get } from 'cerebral';
import { KEYS } from '@shared/business/entities/EntityConstants';
import { STATE_KEYS } from '@shared/business/entities/EntityConstants';
import { computeIsNotServedDocument } from '@shared/business/utilities/getFormattedCaseDetail';
import { sortBy } from 'lodash';
import { state } from '@web-client/presenter/app.cerebral';
Expand Down Expand Up @@ -215,10 +215,10 @@ export const formattedDocketEntries = (
}

const docketRecordSortField = get(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortField,
);
const docketRecordSortOrder = get(
state[KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder,
state[STATE_KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder,
);

const DOCUMENT_VISIBILITY_POLICY_CHANGE_DATE = get(
Expand Down Expand Up @@ -318,7 +318,7 @@ export const formattedDocketEntries = (

export function sortDocketEntryTable<T>(
docketEntries: (T & { sortingFilingDate: string | undefined })[] = [],
docketRecordSortField: keyof T | undefined,
docketRecordSortField: string | undefined,
docketRecordSortOrder: 'asc' | 'desc' | undefined,
): T[] {
if (!docketRecordSortField || !docketRecordSortOrder) {
Expand Down
Loading

0 comments on commit 438df35

Please sign in to comment.