diff --git a/cypress/local-only/tests/integration/trialSession/trial-sessions-filtering.cy.ts b/cypress/local-only/tests/integration/trialSession/trial-sessions-filtering.cy.ts index 1a209ed09f8..96cbbf0cadc 100644 --- a/cypress/local-only/tests/integration/trialSession/trial-sessions-filtering.cy.ts +++ b/cypress/local-only/tests/integration/trialSession/trial-sessions-filtering.cy.ts @@ -41,6 +41,7 @@ describe('trial sessions filtering', () => { tabName: 'new', trialLocation, }); + cy.get(`[data-testid="trial-sessions-row-${trialSessionId}"]`).should( 'exist', ); @@ -84,6 +85,7 @@ describe('trial sessions filtering', () => { tabName: 'calendared', trialLocation, }); + cy.get(`[data-testid="trial-sessions-row-${trialSessionId}"]`).should( 'exist', ); @@ -111,6 +113,7 @@ describe('trial sessions filtering', () => { tabName: 'calendared', trialLocation, }); + cy.get(`[data-testid="trial-sessions-row-${trialSessionId}"]`).should( 'exist', ); @@ -119,12 +122,14 @@ describe('trial sessions filtering', () => { setTrialSessionFilters({ judge, proceedingType, + resetFilters: true, sessionStatus: 'All', sessionType, startDate, tabName: 'calendared', trialLocation, }); + cy.get(`[data-testid="trial-sessions-row-${trialSessionId}"]`).should( 'exist', ); @@ -136,12 +141,14 @@ describe('trial sessions filtering', () => { function setTrialSessionFilters({ judge, proceedingType, + resetFilters, sessionStatus, sessionType, startDate, tabName, trialLocation, }: { + resetFilters?: boolean; tabName: 'calendared' | 'new'; proceedingType: string; startDate: string; @@ -151,6 +158,9 @@ function setTrialSessionFilters({ sessionStatus?: string; }) { cy.get(`[data-testid="${tabName}-trial-sessions-tab"]`).click(); + if (resetFilters) { + cy.get('[data-testid="trial-session-reset-filter-button"]').click(); + } if (sessionStatus) { cy.get(`[data-testid="sessionStatus-${sessionStatus}"]`).click(); } diff --git a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts index e4bc058c404..250cd31f2a8 100644 --- a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts @@ -5,7 +5,7 @@ import { runAction } from '@web-client/presenter/test.cerebral'; describe('resetTrialSessionsFiltersAction', () => { it('should reset the trialSessions filters', async () => { const result = await runAction(resetTrialSessionsFiltersAction, { - state: {}, + state: { trialSessionsPage: { filters: { currentTab: 'new' } } }, }); expect(result.state.trialSessionsPage.filters).toEqual( diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 21601220856..b7d9e612bb0 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -28,6 +28,7 @@ export const TrialSessions = connect( sequences.resetTrialSessionsFiltersSequence, showModal: state.modal.showModal, trialSessionsHelper: state.trialSessionsHelper, + trialSessionsPageFilters: state.trialSessionsPage.filters, }, function TrialSessions({ openCreateTermModalSequence, @@ -35,6 +36,7 @@ export const TrialSessions = connect( resetTrialSessionsFiltersSequence, showModal, trialSessionsHelper, + trialSessionsPageFilters, }) { return ( <> @@ -83,12 +85,17 @@ export const TrialSessions = connect( )} { - resetTrialSessionsFiltersSequence({ currentTab: tabName }); + if (tabName === trialSessionsPageFilters.currentTab) { + return; + } + resetTrialSessionsFiltersSequence({ + currentTab: tabName, + }); }} > {trialSessionsHelper.showNewTrialSession && ( @@ -399,6 +406,7 @@ const TrialSessionFilters = connect(