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

10409 Trial Sessions Page: Calendared View #5319

Draft
wants to merge 107 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
bdc4a52
10409: Add new styling for trial sessions. Extract filters to its own…
Aug 30, 2024
f93ed2f
10409: Split out state for trialsessionPage into its own page container.
Aug 30, 2024
f364e4d
10409: Delete comment
Aug 30, 2024
16521db
10409: Wire up filters to state.
Sep 2, 2024
bf6bd5d
10409: Move filtering and formatting of trialSessions to helper inste…
Sep 2, 2024
ab196e6
10409: Add sorting
Sep 3, 2024
6cb5fde
10409: Add blue rows to display session weeks
Sep 3, 2024
f285df6
10409: organize functions
Sep 3, 2024
5962676
10409: Update Default state of filters
Sep 3, 2024
c857773
10409 fix radio buttons
Sep 3, 2024
e6d3dbb
10409 fix setTrialSessionsFiltersActions test
JayFlexy Sep 4, 2024
d9b8c41
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 4, 2024
2171a5f
10409: fix some tests, wip still figuring out purpose
JayFlexy Sep 5, 2024
df76cb5
10409 fix trialSessionsHelper.test.ts tests
JayFlexy Sep 5, 2024
17582f8
10409 add some tests for new table functionality
JayFlexy Sep 5, 2024
aa695c7
Merge branch '10409-story' of github.com:flexion/ef-cms into 10409-story
Sep 5, 2024
0176b22
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 5, 2024
21ea134
10409: Remove unused
Sep 5, 2024
fd8aaca
10409: Add tests for filtering trial sessions
Sep 5, 2024
e3ba313
10409: Move trial sessions filtering tests over to trialSessionsHelper
Sep 5, 2024
f4be15c
10409: Add filtering for unassigned judges
Sep 5, 2024
ef06474
10409 fix proceedingtype filter test
JayFlexy Sep 9, 2024
8c920aa
10409 fix type errors
JayFlexy Sep 9, 2024
e1ad6c0
10409: Update swing session calculation to decouple from trialsession…
Sep 9, 2024
6a2246b
10409: Update swing session helper. fix sorting
Sep 9, 2024
f92de66
10409: Remove formattedTrialSessions and split into trialSessionsPage…
Sep 9, 2024
a996881
10409: Update integration tests to reflect new trial sessions page state
Sep 9, 2024
14de069
10409: Update integration tests to reflect new trial sessions page state
Sep 9, 2024
0a8bc90
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 9, 2024
b3e05a3
10409: Update integration tests to reflect new trial sessions page state
Sep 10, 2024
bec2547
10409: Update integration tests to reflect new trial sessions page state
Sep 10, 2024
9237d95
10409: Remove validation before returning trial sessions.
Sep 10, 2024
f79288c
10409: Make a new trialSession before turning into DTO so the NOTT ca…
Sep 10, 2024
c85f58e
10409 calculate isStartDateWithinNOTTReminderRange
Sep 10, 2024
91c670c
10409 calculate thirtyDaysBeforeTrialFormatted instead of storing on …
Sep 10, 2024
3ed8edb
10409 always route the user to the new tab once they have created a t…
Sep 11, 2024
a7bf3dd
10409 add query params back when navigating to trial sessions
Sep 11, 2024
ac9d1f4
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 11, 2024
4451202
10409 look at calendared trial sessions after making one
Sep 11, 2024
b1a01da
10409: Reset state when a user signs out. Only show inactive judges o…
Sep 12, 2024
63cdd9b
10409: Update text
Sep 12, 2024
9f0c71d
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 12, 2024
102bdba
10409: Remove reset to base state
Sep 12, 2024
65da763
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 13, 2024
52349ba
10409: Update tests for legacy judges only showing on closed and all
Sep 13, 2024
b854269
10409: temp docs
Sep 13, 2024
4d40410
10409: WIP adding inputs for new select dropdowns on trial sessions
Sep 17, 2024
69ddc01
10409: WIP styling trial sessions date range
Sep 18, 2024
d498a9e
10409: Remove temp styling
Sep 18, 2024
d0ac90e
10409: WIP start adding options to trial sessions
Sep 18, 2024
e1f8cae
10409: add options to filter dropdowns;
nechama-krigsman Sep 18, 2024
16d090f
10409: WIP Converting judgeIds into a multi select
Sep 18, 2024
289d7fb
10409: WIP Converting TrialLocations into a multi select
Sep 18, 2024
8935f7b
10409: WIP Converting session types to multi select filter
Sep 18, 2024
f03ecee
10409: add clear trial session filter button;
nechama-krigsman Sep 19, 2024
f8f76ba
10409: disable clear filters button when no optional filters are sele…
nechama-krigsman Sep 19, 2024
276823e
10409: Remove console logs
Sep 19, 2024
9f3478b
10409: add filtering for trial start date range;
nechama-krigsman Sep 19, 2024
4a3d042
10409: Add functionality for reset filters
Sep 19, 2024
e266787
10409: fix warnings
Sep 19, 2024
242f458
10409: fix reseet filters on tab change
Sep 19, 2024
ae79b24
10409: add trial session count;
nechama-krigsman Sep 19, 2024
a5a4547
10409: wip
JayFlexy Sep 19, 2024
2fd8290
10409: Add pagination support for trial sessions
Sep 19, 2024
88ec347
10409: Change paginator location
Sep 19, 2024
da682b7
10409: Set page number whenever filters change
Sep 19, 2024
3cf8a3b
10409: display chevron on previous and next buttons; fix jumping colu…
nechama-krigsman Sep 20, 2024
478fd2c
10409: Add icons
Sep 20, 2024
ba8c182
10409: Fix grid styling for paginator
Sep 20, 2024
e11c403
10409: add onBlur event listener to DateRangePicker to handle validat…
nechama-krigsman Sep 20, 2024
5853672
10409: wip fixing unit tests
JayFlexy Sep 20, 2024
28eae57
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 20, 2024
2d84d96
Merge branch '10409-story' of github.com:flexion/ef-cms into 10409-story
Sep 20, 2024
3ae767d
10409: Add live validation for trial session dates
Sep 20, 2024
2080ede
10409: remove comment
Sep 20, 2024
092dbc9
10411: wip fixing tests
JayFlexy Sep 23, 2024
c1a68df
10409: only show single page paginator when fetching data per page;
nechama-krigsman Sep 23, 2024
7e4f101
10409: WIP trying to type selectsearch
Sep 23, 2024
2fc623f
10409: Type select search for trial sessions
Sep 23, 2024
cd05f0b
10409: Creaate new utils folder for trial sessions
Sep 23, 2024
5dc7ace
10409: Update custom case report to new selector
Sep 23, 2024
55f55a0
10409: WIP update primaryDocumentForm to new searchSelect
Sep 23, 2024
c38fe65
10409: more test fixes
JayFlexy Sep 23, 2024
bb2e7c2
10409: WIP update SessionAssignmentForm to new searchSelect
Sep 23, 2024
cbb979a
10409: WIP update CaseAssociationRequest to new searchSelect
Sep 24, 2024
8ad32e3
10409: WIP update CourtIssuedDocketEntry to new searchSelect
Sep 24, 2024
fffc0f0
10409: WIP update CourtIssuedDocketEntry to new searchSelect
Sep 24, 2024
79e9e6f
10409: WIP add isClearable to all select searches
Sep 24, 2024
f1326a9
10409: WIP update EditDocketEntryMetaFormCourtIssued to new searchSelect
Sep 24, 2024
b829294
10409: wip
JayFlexy Sep 24, 2024
5b75128
10409: WIP update EditDocketEntryMetaFormDocument to new searchSelect
Sep 24, 2024
58f0c6a
10409: WIP update PrimaryDocumentForm to new searchSelect
Sep 24, 2024
3a98fc5
10409: WIP Assign a value so that select search knows what value was …
Sep 24, 2024
bfe3a99
10409: WIP update CompleteDocumentTypeSelection to new searchSelect
Sep 24, 2024
32a47c7
10409: WIP update CompleteDocumentTypeSectionRemainder to new searchS…
Sep 24, 2024
6637312
Merge branch '10409-story' of github.com:flexion/ef-cms into 10409-story
Sep 24, 2024
7d8e835
10409: Delete old SelectSearch in favor of more generic select search
Sep 24, 2024
15d313b
10409: Delete old SelectSearch related functions
Sep 24, 2024
6071ea5
10409: Update selected paginator page to blue color;
Sep 24, 2024
6218987
10409: Add unassigned judge as an option;
Sep 24, 2024
24cd260
Merge branch 'staging' of github.com:ustaxcourt/ef-cms into 10409-story
Sep 24, 2024
10708a2
10409: WIP Add pagesize, fix tests
Sep 24, 2024
5cfb8f5
10409: fix unit tests in trialSessionsHelper;
nechama-krigsman Sep 24, 2024
72c10fd
10409: fix type errors;
nechama-krigsman Sep 24, 2024
660e804
10409: fix type errors;
nechama-krigsman Sep 24, 2024
afa89cc
10409: fix accessiblity tests;
nechama-krigsman Sep 24, 2024
f328a4e
10409: WIP Add data-testid to all select searchs
Sep 24, 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
26 changes: 26 additions & 0 deletions 10409_validation_delete_me.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Problem statement: How can we detect when making a validation changes to entities, we do not create invalid data in the database?

- Pull all validation rules into a single file, if they change in any way, a validation sweep must be run on the database
- Continue validating before we return inside all of our interactors but instead of exploding just silently log which entities are now invalid.
- On each deployment validate all data in the database.


Assumptions
- Not all business rules can or should live inside of the persistence layer.
- For example when a trialSession is calendared it should have a sessionType
- What is and what is not a valid entity can only be expressed inside of functions.
- Is it possible to tell if a function has been modified between different git commits?
- If it is a pure function that does not modify any external state


shared/src/business/entities/contacts/Contact.ts getValidationRules depends on instance.countryType


Thoughts
- If validation rules are expressed inside of functions it is impossible to tell if a function has changed its behavior from one release to another. If it is impossible to tell if validation rules have changed then maybe defensively checking if they have changed, and running a validation sweep on the DB is not the correct approach
- Another option is better warnings to devs about making validation changes.
- Another option is continue validating, but only log invalid values instead of throwing errors to reduce application impact.


Resources
- Validate at input time. Validate again before you put it in the database. And have database constraints to prevent bad input. And you can bet in spite of all that, bad data will still get into your database, so validate it again when you use it.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ describe('File Document Page - Petitioner Accessibility', () => {
it('should be free of a11y issues on step 2', () => {
loginAsPetitioner();
cy.visit('/case-detail/101-19/file-a-document');
cy.get('#document-type').click({ force: true });
cy.get('#document-type input')
.first()
.type('Motion for Leave to File Out of Time');
cy.get('#document-type #react-select-2-option-0').click({ force: true });
cy.get('#secondary-doc-secondary-document-type').click({ force: true });
cy.get('#secondary-doc-secondary-document-type input')
.first()
.type('Motion for Continuance');
cy.get(
'#secondary-doc-secondary-document-type #react-select-3-option-0',
).click({ force: true });
cy.get('[data-testid="document-type"]').click();
cy.get('[data-testid="document-type"]')
.contains('Motion for Leave to File Out of Time')
.click();

cy.get('[data-testid="secondary-doc-secondary-document-type"]').click();
cy.get('[data-testid="secondary-doc-secondary-document-type"]')
.contains('Motion for Continuance')
.click();

cy.get('#submit-document').click();
cy.get('#primaryDocument-certificateOfService-label').click();
cy.get('#primaryDocument-service-date-picker').should('exist');
Expand Down
6 changes: 0 additions & 6 deletions shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ export class TrialSessionInfoDTO {
public sessionStatus: string;
public swingSession?: boolean;
public dismissedAlertForNOTT?: boolean;
public isStartDateWithinNOTTReminderRange?: boolean;
public thirtyDaysBeforeTrialFormatted?: string;

constructor(rawTrialSession: RawTrialSession) {
this.estimatedEndDate = rawTrialSession.estimatedEndDate;
this.isCalendared = rawTrialSession.isCalendared;
this.judge = rawTrialSession.judge;
this.isStartDateWithinNOTTReminderRange =
rawTrialSession.isStartDateWithinNOTTReminderRange;
this.thirtyDaysBeforeTrialFormatted =
rawTrialSession.thirtyDaysBeforeTrialFormatted;
this.proceedingType = rawTrialSession.proceedingType;
this.sessionType = rawTrialSession.sessionType;
this.startDate = rawTrialSession.startDate;
Expand Down
2 changes: 1 addition & 1 deletion shared/src/business/entities/cases/CalendaredCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IrsPractitioner } from '../IrsPractitioner';
import { JoiValidationConstants } from '../JoiValidationConstants';
import { JoiValidationEntity } from '../JoiValidationEntity';
import { PrivatePractitioner } from '../PrivatePractitioner';
import { setPretrialMemorandumFiler } from '../../utilities/getFormattedTrialSessionDetails';
import { setPretrialMemorandumFiler } from '../../utilities/trialSession/getFormattedTrialSessionDetails';
import joi from 'joi';

export class CalendaredCase extends JoiValidationEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ describe('TrialSession entity', () => {
{ daysFromToday: 34, expectedOutput: true },
{ daysFromToday: 35, expectedOutput: false },
];
it('should set isStartDateWithinNOTTReminderRange to false when the trial session is not calendared', () => {
it('should return false when the trial session is not calendared', () => {
const trialSession = new TrialSession({
...MOCK_TRIAL_REGULAR,
isCalendared: false,
});

expect(trialSession.isStartDateWithinNOTTReminderRange).toBe(false);
expect(
TrialSession.isStartDateWithinNOTTReminderRange({
isCalendared: trialSession.isCalendared,
startDate: trialSession.startDate,
}),
).toBe(false);
});

tests.forEach(({ daysFromToday, expectedOutput }) => {
it(`should set isStartDateWithinNOTTReminderRange to ${expectedOutput} when the trial session is calendared and the start date is ${daysFromToday} days from today`, () => {
it(`should return ${expectedOutput} when the trial session is calendared and the start date is ${daysFromToday} days from today`, () => {
const thirtyDaysFromToday = today.plus({ ['days']: daysFromToday });

const trialSession = new TrialSession({
Expand All @@ -39,9 +44,12 @@ describe('TrialSession entity', () => {
startDate: thirtyDaysFromToday,
});

expect(trialSession.isStartDateWithinNOTTReminderRange).toBe(
expectedOutput,
);
expect(
TrialSession.isStartDateWithinNOTTReminderRange({
isCalendared: trialSession.isCalendared,
startDate: trialSession.startDate,
}),
).toBe(expectedOutput);
});
});
});
Expand Down

This file was deleted.

61 changes: 27 additions & 34 deletions shared/src/business/entities/trialSessions/TrialSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export class TrialSession extends JoiValidationEntity {
public irsCalendarAdministratorInfo?: RawIrsCalendarAdministratorInfo;
public isCalendared: boolean;
public isClosed?: boolean;
public isStartDateWithinNOTTReminderRange?: boolean;
public joinPhoneNumber?: string;
public judge?: TJudge;
public maxCases?: number;
Expand All @@ -107,7 +106,6 @@ export class TrialSession extends JoiValidationEntity {
public swingSessionId?: string;
public term: string;
public termYear: string;
public thirtyDaysBeforeTrialFormatted?: string;
public trialClerk?: TTrialClerk;
public trialLocation?: string;
public trialSessionId?: string;
Expand Down Expand Up @@ -198,12 +196,6 @@ export class TrialSession extends JoiValidationEntity {
};
}

if (rawSession.isCalendared && rawSession.startDate) {
this.setNoticeOfTrialReminderAlert();
} else {
this.isStartDateWithinNOTTReminderRange = false;
}

if (rawSession.trialClerk && rawSession.trialClerk.name) {
this.trialClerk = {
name: rawSession.trialClerk.name,
Expand All @@ -216,6 +208,33 @@ export class TrialSession extends JoiValidationEntity {
return sessionScope === TRIAL_SESSION_SCOPE_TYPES.standaloneRemote;
}

static isStartDateWithinNOTTReminderRange({
isCalendared,
startDate,
}: {
isCalendared?: boolean;
startDate?: string;
}): boolean {
if (!isCalendared || !startDate) {
return false;
}

const formattedStartDate = formatDateString(startDate, FORMATS.MMDDYY);
const trialStartDateString = prepareDateFromString(
formattedStartDate,
FORMATS.MMDDYY,
);

return isTodayWithinGivenInterval({
intervalEndDate: trialStartDateString.minus({
['days']: 24, // luxon's interval end date is not inclusive
}),
intervalStartDate: trialStartDateString.minus({
['days']: 34,
}),
});
}

static validationRules = {
COMMON: {
address1: JoiValidationConstants.STRING.max(100).allow('').optional(),
Expand Down Expand Up @@ -406,32 +425,6 @@ export class TrialSession extends JoiValidationEntity {
return skPrefix;
}

setNoticeOfTrialReminderAlert() {
const formattedStartDate = formatDateString(this.startDate, FORMATS.MMDDYY);
const trialStartDateString: any = prepareDateFromString(
formattedStartDate,
FORMATS.MMDDYY,
);

this.isStartDateWithinNOTTReminderRange = isTodayWithinGivenInterval({
intervalEndDate: trialStartDateString.minus({
['days']: 24, // luxon's interval end date is not inclusive
}),
intervalStartDate: trialStartDateString.minus({
['days']: 34,
}),
});

const thirtyDaysBeforeTrialInclusive: any = trialStartDateString.minus({
['days']: 29,
});

this.thirtyDaysBeforeTrialFormatted = formatDateString(
thirtyDaysBeforeTrialInclusive,
FORMATS.MMDDYY,
);
}

setAsCalendared() {
this.isCalendared = true;
this.sessionStatus = SESSION_STATUS_TYPES.open;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { JoiValidationConstants } from '@shared/business/entities/JoiValidationConstants';
import { JoiValidationEntity } from '../JoiValidationEntity';
import joi from 'joi';

export class TrialSessionsPageValidation extends JoiValidationEntity {
public endDate: string;
public startDate: string;

constructor(rawProps) {
super('TrialSessionsPageValidation');
this.endDate = rawProps.endDate;
this.startDate = rawProps.startDate;
}

getValidationRules() {
return {
endDate: joi
.alternatives()
.conditional('startDate', {
is: JoiValidationConstants.ISO_DATE.exist().not(null),
otherwise: JoiValidationConstants.ISO_DATE,
then: JoiValidationConstants.ISO_DATE.min(
joi.ref('startDate'),
).description(
'The end date search filter must be of valid date format and greater than or equal to the start date',
),
})
.messages({
'*': 'Enter date in format MM/DD/YYYY.',
'date.min': 'End date cannot be prior to start date.',
}),
startDate: JoiValidationConstants.ISO_DATE.description(
'The start date to search by, which cannot be greater than the current date, and is required when there is an end date provided',
).messages({
'*': 'Enter date in format MM/DD/YYYY.',
}),
};
}
}
2 changes: 1 addition & 1 deletion shared/src/business/test/createTestApplicationContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
compareCasesByDocketNumber,
formatCaseForTrialSession,
getFormattedTrialSessionDetails,
} from '@shared/business/utilities/getFormattedTrialSessionDetails';
} from '@shared/business/utilities/trialSession/getFormattedTrialSessionDetails';
import {
compareISODateStrings,
compareStrings,
Expand Down
2 changes: 1 addition & 1 deletion shared/src/business/utilities/DateHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
* @returns {string} a formatted date string
*/
export const formatDateString = (
dateString: string,
dateString: string | undefined,
formatArg: TimeFormatNames | TimeFormats = FORMATS.ISO,
): string => {
if (!dateString) return '';
Expand Down Expand Up @@ -608,7 +608,7 @@
const todayDate = formatNow(FORMATS.YYYYMMDD);
const dateLessthanOrEqualToToday = dateString <= todayDate;
// console.log(`dateInputValid: ${dateInputValid}`);
// console.log(`dateLessthanOrEqualToToday: ${dateLessthanOrEqualToToday}`);

Check warning on line 611 in shared/src/business/utilities/DateHandler.ts

View workflow job for this annotation

GitHub Actions / Lint

You have a misspelled word: Lessthan on Comment

Check warning on line 611 in shared/src/business/utilities/DateHandler.ts

View workflow job for this annotation

GitHub Actions / Lint

You have a misspelled word: Lessthan on Comment
return dateInputValid && dateLessthanOrEqualToToday;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { applicationContext } from '../test/createTestApplicationContext';
import {
compareCasesByDocketNumber,
compareCasesByDocketNumberFactory,
Expand Down Expand Up @@ -58,7 +57,6 @@ describe('getFormattedTrialSessionDetails.compareCasesByDocketNumberFactory', ()
it('101-19 should come before 102-19', () => {
const result = compareCasesByDocketNumberFactory({
allCases: [],
applicationContext,
})(
{
docketNumber: '101-19',
Expand All @@ -79,7 +77,6 @@ describe('getFormattedTrialSessionDetails.compareCasesByDocketNumberFactory', ()
it('190-07 should come before 102-19', () => {
const result = compareCasesByDocketNumberFactory({
allCases: [],
applicationContext,
})(
{
docketNumber: '190-07',
Expand All @@ -94,7 +91,6 @@ describe('getFormattedTrialSessionDetails.compareCasesByDocketNumberFactory', ()
it('102-19 should equal 102-19', () => {
const result = compareCasesByDocketNumberFactory({
allCases: [],
applicationContext,
})(
{
docketNumber: '102-19',
Expand All @@ -115,7 +111,6 @@ describe('getFormattedTrialSessionDetails.compareCasesByDocketNumberFactory', ()
it('103-19 should come after 102-19', () => {
const result = compareCasesByDocketNumberFactory({
allCases: [],
applicationContext,
})(
{
docketNumber: '103-19',
Expand Down Expand Up @@ -163,7 +158,6 @@ describe('getFormattedTrialSessionDetails.compareCasesByDocketNumberFactory', ()
leadDocketNumber: '101-20',
},
],
applicationContext,
}),
);

Expand Down Expand Up @@ -207,7 +201,6 @@ describe('getFormattedTrialSessionDetails.compareCasesByDocketNumberFactory', ()
cases.sort(
compareCasesByDocketNumberFactory({
allCases: [],
applicationContext,
}),
);

Expand Down
Loading
Loading