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

10525: Full Spectrum Docket Sorting TO TEST #5532

Merged
merged 27 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
23f7da2
10525: WIP use SortableHeader for DocketRecord table;
nechama-krigsman Nov 6, 2024
eafd624
10525: Update state with correct sort table information;
Nov 7, 2024
cfecd81
10525: WIP sort docket record table;
nechama-krigsman Nov 7, 2024
b4ae8ad
10525: maintain sort of docket entries on printable docket record;
nechama-krigsman Nov 8, 2024
961c2f8
Merge remote-tracking branch 'taxCourt/test' into 10525-test
Nov 8, 2024
7eeaee4
10525: Remove Comment;
Nov 8, 2024
274b66e
Merge branch '10525-story' into 10525-test
Nov 8, 2024
7a5aefd
10525: Add unit test to clearSortTableFiltersAction;
Nov 8, 2024
45175e8
Merge branch '10525-story' into 10525-test
Nov 8, 2024
252502f
10525: Add missing sort type to sortable header;
Nov 8, 2024
b78c0b9
10525: Remove unecessary test file;
Nov 8, 2024
442edb5
Merge branch '10525-story' into 10525-test
Nov 8, 2024
2a24b02
10525: Add custom root for sort table data in action;
Nov 11, 2024
76a8d0f
10525: Delete console log;
Nov 11, 2024
554add8
10525: Update typing;
Nov 11, 2024
4cdc8cc
10525: Fix cypress test to use header sort instead of dropdown sort;
Nov 11, 2024
3790c69
Merge branch '10525-story' into 10525-test
Nov 11, 2024
1cd7c30
10525: add default sort by date and secondary sort by index;
Nov 11, 2024
d1e0bf6
Merge branch '10525-story' into 10525-test
Nov 11, 2024
fa9bb7f
10525: set specific docket record table sort key;
nechama-krigsman Nov 11, 2024
cc3bcf6
Merge branch '10525-story' into 10525-test
nechama-krigsman Nov 11, 2024
f1cd634
10525: Add unit tests around new property;
nechama-krigsman Nov 11, 2024
93969d0
10525: Add unit tests around sorting entries when generating PDF;
nechama-krigsman Nov 11, 2024
5dab4e4
10525: Add unit tests sort fields when generating PDF;
nechama-krigsman Nov 11, 2024
ccfe29a
10525: Add unit tests on helper to assure entries are sorted correctl…
nechama-krigsman Nov 11, 2024
6984efe
Merge branch '10525-story' into 10525-test
nechama-krigsman Nov 11, 2024
b390d6d
Merge branch 'test' of https://github.com/ustaxcourt/ef-cms into 1052…
nechama-krigsman Nov 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ describe('Docket clerk views consolidated case', function () {
});

it('should persist the selected sort filter by navigating away from the tab', () => {
cy.get('select[name="docketRecordSort.111-19"]').should(
'have.value',
'byDate',
);
cy.get('select[name="docketRecordSort.111-19"]').select('Newest');
cy.get('[data-testid="descriptionDisplay-sortable-button"]')
.find('svg')
.invoke('attr', 'data-icon')
.should('equal', 'exchange-alt');

cy.get('[data-testid="descriptionDisplay-sortable-button"]').click();

cy.get('[data-testid="descriptionDisplay-sortable-button"]')
.find('svg')
.invoke('attr', 'data-icon')
.should('equal', 'long-arrow-alt-up');

cy.get('#tab-document-view').click();
cy.get('#tab-docket-sub-record').click();
cy.get('select[name="docketRecordSort.111-19"]').should(
'have.value',
'byDateDesc',
);

cy.get('[data-testid="descriptionDisplay-sortable-button"]')
.find('svg')
.invoke('attr', 'data-icon')
.should('equal', 'long-arrow-alt-up');
});

it('should persist the populated consolidated cases in the overview tab when petitioner counsel is added to parties', () => {
Expand Down
17 changes: 13 additions & 4 deletions shared/src/business/entities/EntityConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ 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 DEBOUNCE_TIME_MILLISECONDS = 500;

interface FilingEvent {
Expand Down Expand Up @@ -1654,10 +1658,15 @@ export const DOCKET_ENTRY_SEALED_TO_TYPES = {
export const ASCENDING: 'asc' = 'asc';
export const DESCENDING: 'desc' = 'desc';

export const CHRONOLOGICALLY_ASCENDING = 'Oldest to newest';
export const CHRONOLOGICALLY_DESCENDING = 'Newest to oldest';
export const ALPHABETICALLY_ASCENDING = 'In A-Z ascending order';
export const ALPHABETICALLY_DESCENDING = 'In Z-A descending order';
export const SORT_ASCENDING_TEXT = {
date: 'Oldest to newest',
string: 'In A-Z ascending order',
};

export const SORT_DESCENDING_TEXT = {
date: 'Newest to oldest',
string: 'In Z-A descending order',
};

export const PRACTITIONER_DOCUMENT_TYPES_MAP = {
APPLICATION_PACKAGE: 'Application Package',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,24 @@ describe('formatDocketEntry', () => {
},
);
});

describe('sortingFilingDate', () => {
it('should set the property "sortingFilingDate" correctly using filingDate', () => {
const result = formatDocketEntry(applicationContext, {
createdAt: '2020-03-01T21:40:46.415Z',
filingDate: '2019-03-01T21:40:46.415Z',
isOnDocketRecord: true,
isUnservable: true,
});
expect(result.sortingFilingDate).toEqual('20190301');
});
it('should set the property "sortingFilingDate" correctly using createdAt', () => {
const result = formatDocketEntry(applicationContext, {
createdAt: '2020-03-01T21:40:46.415Z',
filingDate: '2019-03-01T21:40:46.415Z',
isOnDocketRecord: false,
});
expect(result.sortingFilingDate).toEqual('20200301');
});
});
});
6 changes: 6 additions & 0 deletions shared/src/business/utilities/getFormattedCaseDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,16 @@ export const formatDocketEntry = (applicationContext, docketEntry) => {
formattedEntry.createdAtFormatted = applicationContext
.getUtilities()
.formatDateString(formattedEntry.filingDate, 'MMDDYY');
formattedEntry.sortingFilingDate = applicationContext
.getUtilities()
.formatDateString(formattedEntry.filingDate, 'YYYYMMDD_NUMERIC');
} else {
formattedEntry.createdAtFormatted = applicationContext
.getUtilities()
.formatDateString(formattedEntry.createdAt, 'MMDDYY');
formattedEntry.sortingFilingDate = applicationContext
.getUtilities()
.formatDateString(formattedEntry.createdAt, 'YYYYMMDD_NUMERIC');
}

formattedEntry.filingsAndProceedings =
Expand Down
2 changes: 2 additions & 0 deletions shared/src/proxies/generateDocketRecordPdfProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const generateDocketRecordPdfInteractor = (
{
docketNumber,
docketRecordSort,
docketRecordTableSort,
includePartyDetail,
isIndirectlyAssociated,
},
Expand All @@ -22,6 +23,7 @@ export const generateDocketRecordPdfInteractor = (
body: {
docketNumber,
docketRecordSort,
docketRecordTableSort,
includePartyDetail,
isIndirectlyAssociated,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,82 @@ describe('generateDocketRecordPdfInteractor', () => {

expect(result).toEqual(mockPdfUrlAndID);
});

describe('sorting', () => {
it('should pass in entries sorted by the provided property and orderType "asc"', async () => {
caseDetail.docketEntries = [
{
eventCode: 'D',
isOnDocketRecord: true,
},
{ eventCode: 'B', isOnDocketRecord: true },
{ eventCode: 'C', isOnDocketRecord: true },
{ eventCode: 'A', isOnDocketRecord: true },
];

await generateDocketRecordPdfInteractor(
applicationContext,
{
docketNumber: caseDetail.docketNumber,
docketRecordTableSort: { sortField: 'eventCode', 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([
{
eventCode: 'A',
},
{ eventCode: 'B' },
{ eventCode: 'C' },
{ eventCode: 'D' },
]);
});

it('should pass in entries sorted by the provided property and orderType "des"', async () => {
caseDetail.docketEntries = [
{
eventCode: 'D',
isOnDocketRecord: true,
},
{ eventCode: 'B', isOnDocketRecord: true },
{ eventCode: 'C', isOnDocketRecord: true },
{ eventCode: 'A', isOnDocketRecord: true },
];

await generateDocketRecordPdfInteractor(
applicationContext,
{
docketNumber: caseDetail.docketNumber,
docketRecordTableSort: { sortField: 'eventCode', sortOrder: 'desc' },
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([
{ eventCode: 'D' },
{ eventCode: 'C' },
{ eventCode: 'B' },
{
eventCode: 'A',
},
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import { ServerApplicationContext } from '@web-api/applicationContext';
import { UnauthorizedError } from '@web-api/errors/errors';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { getCaseCaptionMeta } from '../../../../shared/src/business/utilities/getCaseCaptionMeta';
import { sortDocketEntryTable } from '@web-client/presenter/computeds/formattedDocketEntries';

export const generateDocketRecordPdfInteractor = async (
applicationContext: ServerApplicationContext,
{
docketNumber,
docketRecordSort,
docketRecordTableSort,
includePartyDetail = false,
isIndirectlyAssociated = false,
}: {
docketNumber: string;
docketRecordSort?: string;
docketRecordTableSort?: { sortField: string; sortOrder: string };
includePartyDetail: boolean;
isIndirectlyAssociated?: boolean;
},
Expand Down Expand Up @@ -71,7 +74,6 @@ export const generateDocketRecordPdfInteractor = async (
} else {
caseEntity = new Case(caseSource, { authorizedUser });
}

const formattedCaseDetail = applicationContext
.getUtilities()
.getFormattedCaseDetail({
Expand All @@ -81,6 +83,14 @@ export const generateDocketRecordPdfInteractor = async (
docketRecordSort,
});

const sortedDocketEntries = sortDocketEntryTable(
formattedCaseDetail.docketEntries,
docketRecordTableSort && docketRecordTableSort.sortField,
docketRecordTableSort && docketRecordTableSort.sortOrder,
);

formattedCaseDetail.formattedDocketEntries = sortedDocketEntries;

formattedCaseDetail.petitioners.forEach(petitioner => {
petitioner.counselDetails = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { clearDocketRecordTableSortAction } from '@web-client/presenter/actions/clearDocketRecordTableSortAction';
import { runAction } from '@web-client/presenter/test.cerebral';

describe('clearDocketRecordTableSortAction', () => {
it('should clear docket record table sort', async () => {
const { state } = await runAction(clearDocketRecordTableSortAction, {
state: {
DOCKET_RECORD_TABLE_SORT: {
sortField: 'TEST_sortField',
sortOrder: 'TEST_sortOrder',
},
},
});

expect(state['DOCKET_RECORD_TABLE_SORT'].sortField).toEqual(undefined);
expect(state['DOCKET_RECORD_TABLE_SORT'].sortOrder).toEqual(undefined);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { KEYS } from '@shared/business/entities/EntityConstants';
import { state } from '@web-client/presenter/app.cerebral';

export const clearDocketRecordTableSortAction = ({ store }: ActionProps) => {
store.unset(state[KEYS.DOCKET_RECORD_TABLE_SORT].sortField);
store.unset(state[KEYS.DOCKET_RECORD_TABLE_SORT].sortOrder);
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { 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 @@ -105,4 +106,37 @@ describe('generateDocketRecordPdfUrlAction', () => {
isIndirectlyAssociated: false,
});
});

it('should call the interactor with the correct table sort information from state', async () => {
await runAction(generateDocketRecordPdfUrlAction, {
modules: {
presenter,
},
props: {
contentHtml:
'<!doctype html><html><head></head><body>Hello World</body></html>',
docketNumber: '123-45',
isAssociated: false,
},
state: {
caseDetail: {
docketNumber: '123-45',
},
[KEYS.DOCKET_RECORD_TABLE_SORT]: {
sortField: 'sortField_test',
sortOrder: 'sortOrder_test',
},
},
});

expect(
applicationContext.getUseCases().generateDocketRecordPdfInteractor.mock
.calls[0][1],
).toMatchObject({
docketRecordTableSort: {
sortField: 'sortField_test',
sortOrder: 'sortOrder_test',
},
});
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { 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 @@ -15,6 +16,14 @@ export const generateDocketRecordPdfUrlAction = async ({
const docketRecordSort = get(
state.sessionMetadata.docketRecordSort[caseDetail.docketNumber],
);

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

const { isAssociated } = props;

let includePartyDetail = false;
Expand All @@ -29,6 +38,10 @@ export const generateDocketRecordPdfUrlAction = async ({
.generateDocketRecordPdfInteractor(applicationContext, {
docketNumber: caseDetail.docketNumber,
docketRecordSort,
docketRecordTableSort: {
sortField: docketRecordSortField,
sortOrder: docketRecordSortOrder,
},
includePartyDetail,
isIndirectlyAssociated,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,22 @@ describe('setTableSortConfigurationAction', () => {
sortOrder: ASCENDING,
});
});

it('should set the field to sort and the sort order in the correct root', async () => {
const TEST_ROOT = 'TEST_ROOT';
const { state } = await runAction(setTableSortConfigurationAction, {
props: { root: TEST_ROOT, sortField: 'createdAt', sortOrder: ASCENDING },
state: {
tableSort: {
sortField: 'recievedAt',
sortOrder: DESCENDING,
},
},
});

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

const ROOT = root || 'tableSort';
store.set(state[ROOT].sortField, sortField);
store.set(state[ROOT].sortOrder, sortOrder);
};
Loading
Loading