diff --git a/src/components/Consumption/ConsumptionView.spec.tsx b/src/components/Consumption/ConsumptionView.spec.tsx index be7f28bdca9c621575343253669b666284cdf617..df06f2717b0bf44e39fe5f28ffb5fcb91dcfc621 100644 --- a/src/components/Consumption/ConsumptionView.spec.tsx +++ b/src/components/Consumption/ConsumptionView.spec.tsx @@ -74,6 +74,7 @@ describe('ConsumptionView component', () => { <ConsumptionView fluidType={FluidType.ELECTRICITY} /> </Provider> ) + await waitFor(() => null, { container }) expect(container.getElementsByTagName('mock-cozybar')[0]).toBeTruthy() expect(container.getElementsByTagName('mock-header')[0]).toBeTruthy() expect(container.getElementsByTagName('mock-dateNavigator')[0]).toBeTruthy() @@ -84,7 +85,7 @@ describe('ConsumptionView component', () => { ).toBeTruthy() }) - it('should set CurrentTimeStep to WEEK when fluid != ELECTRICITY and timeStep = HALF_AN_HOUR', () => { + it('should set CurrentTimeStep to WEEK when fluid != ELECTRICITY and timeStep = HALF_AN_HOUR', async () => { const store = createMockEcolyoStore({ chart: { ...mockChartState, @@ -97,16 +98,17 @@ describe('ConsumptionView component', () => { }, modal: mockModalState, }) - render( + const { container } = render( <Provider store={store}> <ConsumptionView fluidType={FluidType.GAS} /> </Provider> ) + await waitFor(() => null, { container }) expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK) }) - it('should render konnector list when no fluid is connected', () => { + it('should render konnector list when no fluid is connected', async () => { const store = createMockEcolyoStore({ chart: mockChartStateShowOffline, global: { @@ -121,6 +123,7 @@ describe('ConsumptionView component', () => { <ConsumptionView fluidType={FluidType.MULTIFLUID} /> </Provider> ) + await waitFor(() => null, { container }) expect( container.getElementsByTagName('mock-consumptionDetails')[0] ).toBeTruthy() @@ -233,7 +236,7 @@ describe('ConsumptionView component', () => { ).toBeInTheDocument() }) }) - it('should show expired modal when a GRDF consent is expired', () => { + it('should show expired modal when a GRDF consent is expired', async () => { const updatedStatus = mockInitialEcolyoState.global.fluidStatus updatedStatus[0] = mockExpiredGas const store = createMockEcolyoStore({ @@ -245,14 +248,15 @@ describe('ConsumptionView component', () => { }, modal: mockModalState, }) - render( + const { container } = render( <Provider store={store}> <ConsumptionView fluidType={FluidType.GAS} /> </Provider> ) + await waitFor(() => null, { container }) expect(screen.getByText('consent_outdated.title.2')).toBeInTheDocument() }) - it('should show expired modal when a Enedis consent is expired', () => { + it('should show expired modal when a Enedis consent is expired', async () => { const updatedStatus = mockInitialEcolyoState.global.fluidStatus updatedStatus[0] = mockExpiredElec const store = createMockEcolyoStore({ @@ -264,11 +268,12 @@ describe('ConsumptionView component', () => { }, modal: mockModalState, }) - render( + const { container } = render( <Provider store={store}> <ConsumptionView fluidType={FluidType.ELECTRICITY} /> </Provider> ) + await waitFor(() => null, { container }) expect(screen.getByText('consent_outdated.title.0')).toBeInTheDocument() }) it('should render customPopup Modal', async () => { @@ -285,11 +290,12 @@ describe('ConsumptionView component', () => { }, }) mockUpdateProfile.mockResolvedValue(mockTestProfile1) - render( + const { container } = render( <Provider store={store}> <ConsumptionView fluidType={FluidType.ELECTRICITY} /> </Provider> ) + await waitFor(() => null, { container }) expect(screen.getByRole('dialog')).toBeInTheDocument() }) it('should render releaseNotesModal if releaseNotes.show is true', async () => { @@ -306,11 +312,12 @@ describe('ConsumptionView component', () => { modal: mockModalState, }) mockUpdateProfile.mockResolvedValue(mockTestProfile1) - render( + const { container } = render( <Provider store={store}> <ConsumptionView fluidType={FluidType.ELECTRICITY} /> </Provider> ) + await waitFor(() => null, { container }) expect(screen.getByRole('dialog')).toBeInTheDocument() }) })