Skip to content

Commit

Permalink
Merge pull request #5542 from flexion/10460-story
Browse files Browse the repository at this point in the history
10460 story
  • Loading branch information
jimlerza authored Nov 15, 2024
2 parents 4dd6155 + 6a54b31 commit 4d7be07
Show file tree
Hide file tree
Showing 39 changed files with 1,882 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cypress/local-only/support/pages/public/advanced-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const searchForOrderByJudge = judge => {
};

export const publicHeader = () => {
return cy.get('h1.header-welcome-public');
return cy.get('div.header-welcome-public');
};

export const petitionHyperlink = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { selectTypeaheadInput } from '../../../../../helpers/components/typeAhead/select-typeahead-input';

describe('Public Trial Sessions', () => {
beforeEach(() => {
cy.visit('/trial-sessions');
});

it('should display table filters correctly', () => {
cy.get('[data-testid="proceeding-type-filter"]').should('be.visible');
cy.get('[data-testid="session-type-filter"]').should('be.visible');
cy.get('[data-testid="location-filter"]').should('be.visible');
cy.get('[data-testid="judge-filter"]').should('be.visible');

cy.get('[data-testid="remote-proceedings-card"]').should('be.visible');
cy.get('[data-testid="remote-proceedings-card"]')
.find('a')
.should('have.length', 2);

cy.get('[data-testid="trial-sessions-reset-filters-button"]').should(
'be.disabled',
);
});

it('should enable the reset filters button if there are any filters aplied', () => {
cy.get('[data-testid="trial-sessions-reset-filters-button"]').should(
'be.disabled',
);

cy.get('[data-testid="In Person-proceeding-label"]').click();

cy.get('[data-testid="trial-sessions-reset-filters-button"]').should(
'be.enabled',
);
});

it('should display Pill Button for every dropdown filter selected', () => {
const SESSION_TYPE = 'Regular';
selectTypeaheadInput('sessionTypes-filter-select', SESSION_TYPE);
cy.get(`[data-testid="sessionTypes-${SESSION_TYPE}-pill-button"]`);

const LOCATION = 'Mobile, Alabama';
selectTypeaheadInput('locations-filter-select', LOCATION);
cy.get(`[data-testid="locations-${LOCATION}-pill-button"]`);

const JUDGE = 'Buch';
selectTypeaheadInput('judges-filter-select', JUDGE);
cy.get(`[data-testid="judges-${JUDGE}-pill-button"]`);

cy.get(`[data-testid="sessionTypes-${SESSION_TYPE}-pill-button"]`)
.find('button')
.click();
cy.get(`[data-testid="sessionTypes-${SESSION_TYPE}-pill-button"]`).should(
'not.exist',
);

cy.get(`[data-testid="locations-${LOCATION}-pill-button"]`)
.find('button')
.click();
cy.get(`[data-testid="locations-${LOCATION}-pill-button"]`).should(
'not.exist',
);

cy.get(`[data-testid="judges-${JUDGE}-pill-button"]`)
.find('button')
.click();
cy.get(`[data-testid="judges-${JUDGE}-pill-button"]`).should('not.exist');
});
});
11 changes: 11 additions & 0 deletions shared/src/proxies/trialSessions/getPublicTrialSessionsProxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO';
import { get } from '@shared/proxies/requests';

export const getPublicTrialSessionsInteractor = (
applicationContext,
): Promise<TrialSessionInfoDTO[]> => {
return get({
applicationContext,
endpoint: '/public-api/trial-sessions',
});
};
12 changes: 12 additions & 0 deletions shared/src/proxies/users/getPublicUsersInSectionProxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { RawUser } from '@shared/business/entities/User';
import { get } from '../requests';

export const getPublicUsersInSectionInteractor = (
applicationContext,
{ section }: { section: string },
): Promise<RawUser[]> => {
return get({
applicationContext,
endpoint: `/public-api/sections/${section}/users`,
});
};
13 changes: 13 additions & 0 deletions web-api/src/app-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ import { getPublicCaseExistsLambda } from './lambdas/public-api/getPublicCaseExi
import { getPublicCaseLambda } from './lambdas/public-api/getPublicCaseLambda';
import { getPublicDocumentDownloadUrlLambda } from './lambdas/public-api/getPublicDocumentDownloadUrlLambda';
import { getPublicJudgesLambda } from './lambdas/public-api/getPublicJudgesLambda';
import { getPublicTrialSessionsLambda } from '@web-api/lambdas/trialSessions/getPublicTrialSessionsLambda';
import { getUsersInSectionLambda } from '@web-api/lambdas/users/getUsersInSectionLambda';
import { ipLimiter } from './middleware/ipLimiter';
import { opinionPublicSearchLambda } from './lambdas/public-api/opinionPublicSearchLambda';
import { orderPublicSearchLambda } from './lambdas/public-api/orderPublicSearchLambda';
Expand Down Expand Up @@ -178,6 +180,17 @@ app.get('/public-api/judges', lambdaWrapper(getPublicJudgesLambda));
);
}

{
app.get(
'/public-api/trial-sessions',
lambdaWrapper(getPublicTrialSessionsLambda),
);
app.get(
'/public-api/sections/:section/users',
lambdaWrapper(getUsersInSectionLambda),
);
}

/**
* Feature flags
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import { getPublicTrialSessionsInteractor } from '@web-api/business/useCases/trialSessions/getPublicTrialSessionsInteractor';

describe('getPublicTrialSessionsInteractor', () => {
beforeEach(() => {
applicationContext
.getPersistenceGateway()
.getTrialSessions.mockReturnValue(MOCK_TRIAL_SESSIONS);
});

it('should return open trial sessions', async () => {
const result = await getPublicTrialSessionsInteractor(applicationContext);
expect(result.every(session => session.sessionStatus === 'Open')).toBe(
true,
);
});
});

const MOCK_TRIAL_SESSIONS = [
{
caseOrder: [],
createdAt: '2019-11-02T05:00:00.000Z',
gsi1pk: 'trial-session-catalog',
isCalendared: true,
judge: { name: 'Cohen', userId: 'dabbad04-18d0-43ec-bafb-654e83405416' },
maxCases: 30,
pk: 'trial-session|0d943468-bc2e-4631-84e3-b084cf5b1fbb',
proceedingType: 'In Person',
sessionStatus: 'Open',
sessionType: 'Special',
sk: 'trial-session|0d943468-bc2e-4631-84e3-b084cf5b1fbb',
startDate: '2019-12-02T05:00:00.000Z',
startTime: '21:00',
status: 'Closed',
term: 'Fall',
termYear: '2019',
trialLocation: 'Denver, Colorado',
trialSessionId: '0d943468-bc2e-4631-84e3-b084cf5b1fbb',
},
{
caseOrder: [],
createdAt: '2020-10-25T05:00:00.000Z',
gsi1pk: 'trial-session-catalog',
isCalendared: true,
judge: { name: 'Colvin', userId: 'dabbad00-18d0-43ec-bafb-654e83405416' },
maxCases: 100,
pk: 'trial-session|111ac21b-99f9-4321-98c8-b95db00af96b',
proceedingType: 'Remote',
sessionScope: 'Standalone Remote',
sessionStatus: 'Open',
sessionType: 'Special',
sk: 'trial-session|111ac21b-99f9-4321-98c8-b95db00af96b',
startDate: '2020-11-25T05:00:00.000Z',
startTime: '13:00',
term: 'Fall',
termYear: '2020',
trialLocation: 'Standalone Remote',
trialSessionId: '111ac21b-99f9-4321-98c8-b95db00af96b',
},
{
caseOrder: [],
createdAt: '2020-10-02T05:00:00.000Z',
gsi1pk: 'trial-session-catalog',
isCalendared: false,
judge: { name: 'Cohen', userId: 'dabbad04-18d0-43ec-bafb-654e83405416' },
maxCases: 8,
pk: 'trial-session|149159ca-f4a1-4b2b-bc24-bd1fbe6defdc',
proceedingType: 'In Person',
sessionStatus: 'New',
sessionType: 'Regular',
sk: 'trial-session|149159ca-f4a1-4b2b-bc24-bd1fbe6defdc',
startDate: '2020-12-02T05:00:00.000Z',
startTime: '09:00',
term: 'Fall',
termYear: '2020',
trialLocation: 'Birmingham, Alabama',
trialSessionId: '149159ca-f4a1-4b2b-bc24-bd1fbe6defdc',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ServerApplicationContext } from '@web-api/applicationContext';
import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession';
import { TrialSessionInfoDTO } from '../../../../../shared/src/business/dto/trialSessions/TrialSessionInfoDTO';

export const getPublicTrialSessionsInteractor = async (
applicationContext: ServerApplicationContext,
): Promise<TrialSessionInfoDTO[]> => {
const trialSessions = await applicationContext
.getPersistenceGateway()
.getTrialSessions({
applicationContext,
});

return trialSessions
.map(t => new TrialSession(t).toRawObject())
.map(trialSession => new TrialSessionInfoDTO(trialSession))
.filter(trialSession => trialSession.sessionStatus === 'Open');
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getUsersInSectionInteractor = async (
rolePermission = ROLE_PERMISSIONS.GET_USERS_IN_SECTION;
}

if (!isAuthorized(authorizedUser, rolePermission)) {
if (!!authorizedUser && !isAuthorized(authorizedUser, rolePermission)) {
throw new UnauthorizedError('Unauthorized');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { genericHandler } from '@web-api/genericHandler';
import { getPublicTrialSessionsInteractor } from '@web-api/business/useCases/trialSessions/getPublicTrialSessionsInteractor';

export const getPublicTrialSessionsLambda = event =>
genericHandler(event, async ({ applicationContext }) => {
return await getPublicTrialSessionsInteractor(applicationContext);
});
4 changes: 4 additions & 0 deletions web-client/src/appPublic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { faArrowAltCircleLeft as faArrowAltCircleLeftRegular } from '@fortawesom
import { faExclamation } from '@fortawesome/free-solid-svg-icons/faExclamation';
import { faExclamationCircle } from '@fortawesome/free-solid-svg-icons/faExclamationCircle';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons/faExclamationTriangle';
import { faLink } from '@fortawesome/free-solid-svg-icons/faLink';
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
import { faTimesCircle as faTimesCircleRegular } from '@fortawesome/free-regular-svg-icons/faTimesCircle';
import { faUser } from '@fortawesome/free-regular-svg-icons/faUser';
import { isFunction, mapValues } from 'lodash';
Expand Down Expand Up @@ -66,6 +68,8 @@ const appPublic = {
faFileAltSolid,
faLock,
faLongArrowAltUp,
faLink,
faTimes,
faPrint,
faFilePdf,
faSearch,
Expand Down
4 changes: 4 additions & 0 deletions web-client/src/applicationContextPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import { getPublicCaseInteractor } from '../../shared/src/proxies/getPublicCaseP
import { getPublicJudgesInteractor } from '../../shared/src/proxies/public/getPublicJudgesProxy';
import { getPublicPractitionerByBarNumberInteractor } from '@shared/proxies/public/getPublicPractitionerByBarNumberProxy';
import { getPublicPractitionersByNameInteractor } from '@shared/proxies/public/getPublicPractitionersByNameProxy';
import { getPublicTrialSessionsInteractor } from '@shared/proxies/trialSessions/getPublicTrialSessionsProxy';
import { getPublicUsersInSectionInteractor } from '@shared/proxies/users/getPublicUsersInSectionProxy';
import { getSealedDocketEntryTooltip } from '../../shared/src/business/utilities/getSealedDocketEntryTooltip';
import { getTodaysOpinionsInteractor } from '../../shared/src/proxies/public/getTodaysOpinionsProxy';
import { getTodaysOrdersInteractor } from '../../shared/src/proxies/public/getTodaysOrdersProxy';
Expand Down Expand Up @@ -115,6 +117,8 @@ const allUseCases = {
getPublicJudgesInteractor,
getTodaysOpinionsInteractor,
getTodaysOrdersInteractor,
getTrialSessionsInteractor: getPublicTrialSessionsInteractor,
getUsersInSectionInteractor: getPublicUsersInSectionInteractor,
opinionPublicSearchInteractor,
orderPublicSearchInteractor,
removeItemInteractor,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DateTime } from 'luxon';
import { runAction } from '@web-client/presenter/test.cerebral';
import { setTimeStampAction } from '@web-client/presenter/actions/TrialSession/setTimeStampAction';

describe('setTimeStampAction', () => {
it('should set time stamp', async () => {
const propertyName = 'FetchedTrialSessions';
const result = await runAction(setTimeStampAction({ propertyName }), {});

const expectedDate = DateTime.now().setZone('America/New_York').toISODate();

expect(result.state[propertyName].toISODate()).toEqual(expectedDate);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { DateTime } from 'luxon';
import { state } from '@web-client/presenter/app.cerebral';

export const setTimeStampAction =
({ propertyName }: { propertyName: string }) =>
({ store }: ActionProps) => {
store.set(state[propertyName], DateTime.now().setZone('America/New_York'));
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { PublicClientState } from '@web-client/presenter/state-public';
import { resetPublicTrialSessionDataAction } from '@web-client/presenter/actions/resetPublicTrialSessionDataAction';
import { runAction } from '@web-client/presenter/test.cerebral';

describe('resetPublicTrialSessionDataAction', () => {
it('should reset trial session data', async () => {
const result = await runAction<void, PublicClientState>(
resetPublicTrialSessionDataAction,
{
state: {
publicTrialSessionData: { id: 123 },
},
},
);

expect(result.state.publicTrialSessionData).toEqual({});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { state } from '@web-client/presenter/app-public.cerebral';

export const resetPublicTrialSessionDataAction = ({ store }: ActionProps) => {
store.set(state.publicTrialSessionData, {});
};
Loading

0 comments on commit 4d7be07

Please sign in to comment.