diff --git a/.eslintrc.js b/.eslintrc.js index 2f4c522e66189a2febe623ad18950c04a278a676..d85ce97acd245a1f0aa77649004e879f1966034e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -87,9 +87,6 @@ module.exports = { rules: { 'jest/no-mocks-import': 0, - // Act warning -> should be fixed with "@testing-library/dom" v10 -> in another MR - 'testing-library/no-unnecessary-act': 0, - // For testing View components which renders other components -> implementation tests ? 'testing-library/no-container': 0, diff --git a/src/components/Action/ActionBegin/ActionBegin.spec.tsx b/src/components/Action/ActionBegin/ActionBegin.spec.tsx index 1b9a39cd673a8469b693c38b939c7dc41aaaac36..83e22e8c42c1dd2884bc003072d697ef4972090f 100644 --- a/src/components/Action/ActionBegin/ActionBegin.spec.tsx +++ b/src/components/Action/ActionBegin/ActionBegin.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -83,9 +83,7 @@ describe('ActionBegin component', () => { </Provider> ) await waitFor(() => null, { container }) - await act(async () => { - await userEvent.click(screen.getByText('action.apply')) - }) + await userEvent.click(screen.getByText('action.apply')) expect(await screen.findByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/Action/ActionCard/ActionCard.spec.tsx b/src/components/Action/ActionCard/ActionCard.spec.tsx index ff72792f0fd47ce97480d55aa72e01fc4533066e..d9a0dabf384a769eafd0cc91121f6b1f94acc334 100644 --- a/src/components/Action/ActionCard/ActionCard.spec.tsx +++ b/src/components/Action/ActionCard/ActionCard.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -43,9 +43,7 @@ describe('ActionCard component', () => { </Provider> ) await waitFor(() => null, { container }) - await act(async () => { - await userEvent.click(await screen.findByRole('button')) - }) + await userEvent.click(await screen.findByRole('button')) expect(await screen.findByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/Action/ActionChoose/ActionChoose.spec.tsx b/src/components/Action/ActionChoose/ActionChoose.spec.tsx index 4f556e86b365cccc6c3c1a0ec7349f66527c4972..b71221906dd5000d1e15c139f94dd4fa58342a5d 100644 --- a/src/components/Action/ActionChoose/ActionChoose.spec.tsx +++ b/src/components/Action/ActionChoose/ActionChoose.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -74,11 +74,7 @@ describe('ActionChoose component', () => { </Provider> ) await waitFor(() => null, { container }) - - await act(async () => { - await userEvent.click(await screen.findByText('action.other')) - }) - + await userEvent.click(await screen.findByText('action.other')) const list = container.getElementsByTagName('mock-ActionList')[0] expect(list).toBeInTheDocument() }) diff --git a/src/components/Action/ActionDone/ActionDone.spec.tsx b/src/components/Action/ActionDone/ActionDone.spec.tsx index f377200ae1ac9975b1c0611ae2401f70bda628eb..6a574b524fdb941af99e8dec01ff9478adff9570 100644 --- a/src/components/Action/ActionDone/ActionDone.spec.tsx +++ b/src/components/Action/ActionDone/ActionDone.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -35,9 +35,7 @@ describe('ActionDone component', () => { <ActionDone currentChallenge={userChallengeData[1]} /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('action.ok')) - }) + await userEvent.click(screen.getByText('action.ok')) expect(updateChallengeSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Action/ActionModal/ActionModal.spec.tsx b/src/components/Action/ActionModal/ActionModal.spec.tsx index 37e94eda6c1e803758c3574930f5a831d1fb9a30..087ae6d59a17c59a1bbe5bdcdaedea2de870b80c 100644 --- a/src/components/Action/ActionModal/ActionModal.spec.tsx +++ b/src/components/Action/ActionModal/ActionModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -49,9 +49,7 @@ describe('ActionModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('action_modal.accept')) - }) + await userEvent.click(screen.getByText('action_modal.accept')) expect(updateChallengeSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx b/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx index 08461a140dfbc447f5f3c4fb2f6410e0b76092d8..79f004bd58960ac78371b024b383bae0287c30d6 100644 --- a/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx +++ b/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { UserActionState } from 'enums' import { DateTime } from 'luxon' @@ -44,9 +44,7 @@ describe('ActionOnGoing component', () => { <ActionOnGoing userAction={userAction1} /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('action.details')) - }) + await userEvent.click(screen.getByText('action.details')) expect(screen.getByRole('dialog')).toBeTruthy() }) }) diff --git a/src/components/Analysis/Comparison/Comparison.spec.tsx b/src/components/Analysis/Comparison/Comparison.spec.tsx index da099dfcb1f40306c8d74b9599a1157a8317477f..32510ecd6645f4c96dd0d16d0e1a36c1b6039d9a 100644 --- a/src/components/Analysis/Comparison/Comparison.spec.tsx +++ b/src/components/Analysis/Comparison/Comparison.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { FluidType } from 'enums' import { PerformanceIndicator } from 'models' @@ -89,15 +89,11 @@ describe('Comparison component', () => { name: `analysis.compare.month_tab`, }) - await act(async () => { - await userEvent.click(yearlyButton) - expect(mockDispatch).toHaveBeenCalledWith(setPeriod('year')) - }) + await userEvent.click(yearlyButton) + expect(mockDispatch).toHaveBeenCalledWith(setPeriod('year')) - await act(async () => { - await userEvent.click(monthlyButton) - expect(mockDispatch).toHaveBeenCalledWith(setPeriod('month')) - }) + await userEvent.click(monthlyButton) + expect(mockDispatch).toHaveBeenCalledWith(setPeriod('month')) }) it('renders performance indicators', async () => { diff --git a/src/components/Analysis/Comparison/FluidPerformanceIndicator.spec.tsx b/src/components/Analysis/Comparison/FluidPerformanceIndicator.spec.tsx index 32487e9d45ea6dad7f55f3a589e9c9df973449b4..f1e7c08d2176ff38dc474e19bb5887eab7b333d8 100644 --- a/src/components/Analysis/Comparison/FluidPerformanceIndicator.spec.tsx +++ b/src/components/Analysis/Comparison/FluidPerformanceIndicator.spec.tsx @@ -1,5 +1,5 @@ import { AnyAction } from '@reduxjs/toolkit' -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { FluidType } from 'enums' import { DateTime } from 'luxon' @@ -64,9 +64,7 @@ describe('FluidPerformanceIndicator component', () => { screen.getByTestId('fluid-comparison-ELECTRICITY') ).toHaveTextContent('+10,00 % / avril 2024') - await act(async () => { - await userEvent.click(screen.getByRole('listitem')) - }) + await userEvent.click(screen.getByRole('listitem')) expect(mockedNavigate).toHaveBeenCalledWith('/consumption/electricity') expect(dispatchSpy).toHaveBeenCalledWith({ @@ -103,9 +101,7 @@ describe('FluidPerformanceIndicator component', () => { '-10,00 % / avril 2024' ) - await act(async () => { - await userEvent.click(screen.getByRole('listitem')) - }) + await userEvent.click(screen.getByRole('listitem')) expect(mockedNavigate).toHaveBeenCalledWith('/consumption/water') expect(dispatchSpy).toHaveBeenCalledWith({ diff --git a/src/components/Analysis/Comparison/TemperatureComparison.spec.tsx b/src/components/Analysis/Comparison/TemperatureComparison.spec.tsx index 4be5c05413861145c8ed46d2b6a3d9cdeba5d0a6..b976032d9f35d4b58ab4136655b72411a35a0174 100644 --- a/src/components/Analysis/Comparison/TemperatureComparison.spec.tsx +++ b/src/components/Analysis/Comparison/TemperatureComparison.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { DateTime } from 'luxon' import React from 'react' @@ -80,11 +80,9 @@ describe('TemperatureComparison component', () => { </Provider> ) await waitFor(() => container) - await act(async () => { - await userEvent.click( - screen.getByLabelText('analysis.temperature_comparison.info_button') - ) - }) + await userEvent.click( + screen.getByLabelText('analysis.temperature_comparison.info_button') + ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/Analysis/Comparison/TemperatureComparisonModal/TemperatureComparisonModal.spec.tsx b/src/components/Analysis/Comparison/TemperatureComparisonModal/TemperatureComparisonModal.spec.tsx index 783e566a34c6903a1c00b977362dbbc610f2c628..dd13f814d5e29ebc2164941ed1bd87cb6f93d758 100644 --- a/src/components/Analysis/Comparison/TemperatureComparisonModal/TemperatureComparisonModal.spec.tsx +++ b/src/components/Analysis/Comparison/TemperatureComparisonModal/TemperatureComparisonModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -26,9 +26,7 @@ describe('TemperatureComparisonModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) - }) + await userEvent.click(screen.getAllByRole('button')[0]) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Analysis/Comparison/__snapshots__/FluidPerformanceIndicator.spec.tsx.snap b/src/components/Analysis/Comparison/__snapshots__/FluidPerformanceIndicator.spec.tsx.snap index cd33f838a0aa60ee4ba4f9e03d8b45f8fd023f28..b1267a972d8fd158a90f9eb8c7b08d5da9d6e92e 100644 --- a/src/components/Analysis/Comparison/__snapshots__/FluidPerformanceIndicator.spec.tsx.snap +++ b/src/components/Analysis/Comparison/__snapshots__/FluidPerformanceIndicator.spec.tsx.snap @@ -106,7 +106,16 @@ exports[`FluidPerformanceIndicator component should render elec indicators corre /> <span class="MuiTouchRipple-root" - /> + > + <span + class="MuiTouchRipple-ripple MuiTouchRipple-rippleVisible" + style="width: 2.8284271247461903px; height: 2.8284271247461903px; top: -1.4142135623730951px; left: -1.4142135623730951px;" + > + <span + class="MuiTouchRipple-child MuiTouchRipple-childLeaving" + /> + </span> + </span> </button> </div> `; diff --git a/src/components/Analysis/ElecHalfHourMonthlyAnalysis/ElecHalfHourMonthlyAnalysis.spec.tsx b/src/components/Analysis/ElecHalfHourMonthlyAnalysis/ElecHalfHourMonthlyAnalysis.spec.tsx index 422d746bbd8837ba8bdd1bd60720b0bdc630def1..0ec1b37d9663f15f4235065156af2a3b3ba08016 100644 --- a/src/components/Analysis/ElecHalfHourMonthlyAnalysis/ElecHalfHourMonthlyAnalysis.spec.tsx +++ b/src/components/Analysis/ElecHalfHourMonthlyAnalysis/ElecHalfHourMonthlyAnalysis.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { PerformanceIndicator } from 'models' import React from 'react' @@ -103,11 +103,9 @@ describe('ElecHalfHourMonthlyAnalysis component', () => { await screen.findByLabelText( 'consumption.accessibility.button_previous_value' ) - await act(async () => { - await userEvent.click( - screen.getByLabelText('consumption.accessibility.button_previous_value') - ) - }) + await userEvent.click( + screen.getByLabelText('consumption.accessibility.button_previous_value') + ) expect(screen.getByText('special_elec.week')).toBeInTheDocument() }) diff --git a/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx b/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx index 1c8b8f3414a79c8d798a69a2dca9598cb1fc9ea7..9214bf6cf40face25243b703c497e40908571e24 100644 --- a/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx +++ b/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { FluidType } from 'enums' import React from 'react' @@ -59,25 +59,17 @@ describe('MaxConsumptionCard component', () => { ) // navigate next - await act(async () => { - await userEvent.click(nextButton) - }) + await userEvent.click(nextButton) expect(screen.getByText('FLUID.GAS.LABEL')).toBeInTheDocument() - await act(async () => { - await userEvent.click(nextButton) - }) + await userEvent.click(nextButton) expect(screen.getByText('FLUID.ELECTRICITY.LABEL')).toBeInTheDocument() // navigate prev - await act(async () => { - await userEvent.click(prevButton) - }) + await userEvent.click(prevButton) expect(screen.getByText('FLUID.GAS.LABEL')).toBeInTheDocument() - await act(async () => { - await userEvent.click(prevButton) - }) + await userEvent.click(prevButton) expect(screen.getByText('FLUID.ELECTRICITY.LABEL')).toBeInTheDocument() }) }) diff --git a/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx b/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx index 7cb6a06109365de9896a3718bc9331d70b7a8684..b18f888595a552c694c5afab6c02ad1a82919eea 100644 --- a/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx +++ b/src/components/Analysis/ProfileComparator/ProfileComparator.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -97,9 +97,7 @@ describe('AnalysisConsumption component', () => { expect(rows.length).toBe(4) expect(screen.getByTestId('iconGoToProfile')).toBeInTheDocument() expect(screen.queryByTestId('goToProfile')).not.toBeInTheDocument() - await act(async () => { - await userEvent.click(screen.getByTestId('iconGoToProfile')) - }) + await userEvent.click(screen.getByTestId('iconGoToProfile')) expect(mockedNavigate).toHaveBeenCalledWith('/profileType') }) }) diff --git a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx index f174bacde00861ab29e4f91befb7e4079148f24f..7512caeb425136e77c16b97f9b029381fc6b33ac 100644 --- a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx +++ b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import ChallengeCardDone from 'components/Challenge/ChallengeCardDone/ChallengeCardDone' import React from 'react' @@ -45,9 +45,7 @@ describe('ChallengeCardDone component', () => { </Provider> ) const resetButton = screen.getByText('challenge.card_done.reset_defi') - await act(async () => { - await userEvent.click(resetButton) - }) + await userEvent.click(resetButton) expect(mockDispatch).toHaveBeenCalledWith({ type: 'challenge/updateUserChallengeList', }) diff --git a/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx b/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx index 989c92034e5d09f8569b48831ba6376fb7f8d0c2..2f86bd92d4c4d1a861b125bad9f2d3286a04ce92 100644 --- a/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx +++ b/src/components/Challenge/ChallengeCardLast/ChallengeCardLast.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import ChallengeCardLast from './ChallengeCardLast' @@ -16,9 +16,7 @@ describe('ChallengeCardLast component', () => { global.open = jest.fn() render(<ChallengeCardLast />) - await act(async () => { - await userEvent.click(screen.getByText('challenge.card_last.button')) - }) + await userEvent.click(screen.getByText('challenge.card_last.button')) expect(window.open).toHaveBeenCalledTimes(1) expect(global.open).toHaveBeenCalledWith( `${__SAU_IDEA_DIRECT_LINK__}?version=0.0.0` diff --git a/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx b/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx index ac2f3a6cab54225ba47a8bc5579215a9e0631bbf..61b2d3e3a4cdbe5cf60fe5ad5d71c83809b88966 100644 --- a/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx +++ b/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { FluidState, FluidType } from 'enums' import React from 'react' @@ -39,11 +39,9 @@ describe('ChallengeCardUnlocked component', () => { <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('challenge.card_unlocked.button_launch') - ) - }) + await userEvent.click( + screen.getByText('challenge.card_unlocked.button_launch') + ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) @@ -64,11 +62,9 @@ describe('ChallengeCardUnlocked component', () => { <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('challenge.card_unlocked.button_launch') - ) - }) + await userEvent.click( + screen.getByText('challenge.card_unlocked.button_launch') + ) expect(screen.queryAllByRole('dialog').length).toBeFalsy() expect(mockStartUserChallenge).toHaveBeenCalledWith(userChallengeData[0]) }) diff --git a/src/components/Charts/Bar.spec.tsx b/src/components/Charts/Bar.spec.tsx index 92699761a995d28a1bb2f8df72239b084d4a11a0..f87d5d1d7b26eacbdc519c8abb28b9d2d34290ed 100644 --- a/src/components/Charts/Bar.spec.tsx +++ b/src/components/Charts/Bar.spec.tsx @@ -1,4 +1,4 @@ -import { act, render } from '@testing-library/react' +import { render } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { scaleLinear } from 'd3' import { FluidType, TimeStep } from 'enums' @@ -127,9 +127,7 @@ describe('Bar component test', () => { </svg> </Provider> ) - await act(async () => { - await userEvent.click(container.querySelector('rect') as Element) - }) + await userEvent.click(container.querySelector('rect') as Element) expect(setSelectedDateSpy).toHaveBeenCalledTimes(1) expect(setSelectedDateSpy).toHaveBeenCalledWith( graphData.actualData[0].date diff --git a/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx b/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx index 0d8be396b947acfd4f3ea589bacc19da9cabb42f..eb41fa2659e378b8d87fd4078973799fece58457 100644 --- a/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx +++ b/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import FormNavigation from './FormNavigation' @@ -15,15 +15,9 @@ describe('FormNavigation component', () => { disablePrevButton={false} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('profile_type.form.button_previous') - ) - }) + await userEvent.click(screen.getByText('profile_type.form.button_previous')) expect(mockHandlePrevious).toHaveBeenCalled() - await act(async () => { - await userEvent.click(screen.getByText('profile_type.form.button_next')) - }) + await userEvent.click(screen.getByText('profile_type.form.button_next')) expect(mockHandleNext).toHaveBeenCalled() }) }) diff --git a/src/components/Connection/ExpiredConsentModal/ExpiredConsentModal.spec.tsx b/src/components/Connection/ExpiredConsentModal/ExpiredConsentModal.spec.tsx index c50602afd0333899a595edeea61b110b58e4c025..4b1ecfae6c01ecc386c551f0e4d587427e5aa1d6 100644 --- a/src/components/Connection/ExpiredConsentModal/ExpiredConsentModal.spec.tsx +++ b/src/components/Connection/ExpiredConsentModal/ExpiredConsentModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { FluidType } from 'enums' import React from 'react' @@ -45,9 +45,7 @@ describe('ExpiredConsentModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('consent_outdated.go')) - }) + await userEvent.click(screen.getByText('consent_outdated.go')) expect(mockAppDispatch).toHaveBeenCalledTimes(1) expect(mockedNavigate).toHaveBeenCalledTimes(1) }) @@ -65,9 +63,7 @@ describe('ExpiredConsentModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('consent_outdated.yes')) - }) + await userEvent.click(screen.getByText('consent_outdated.yes')) expect(mockAppDispatch).toHaveBeenCalledTimes(1) expect(mockedNavigate).toHaveBeenCalledTimes(1) }) @@ -82,9 +78,7 @@ describe('ExpiredConsentModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('consent_outdated.no')) - }) + await userEvent.click(screen.getByText('consent_outdated.no')) expect(mockHandleCloseClick).toHaveBeenCalled() }) }) diff --git a/src/components/Connection/SGEConnect/SgeInit.spec.tsx b/src/components/Connection/SGEConnect/SgeInit.spec.tsx index 5bb551e8e671f95b1527a92b4623c5f29cafdd0e..94359bd560908f1538f634439fa24213c04f7ecb 100644 --- a/src/components/Connection/SGEConnect/SgeInit.spec.tsx +++ b/src/components/Connection/SGEConnect/SgeInit.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -27,9 +27,7 @@ describe('SgeInit component', () => { <SgeInit /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('auth.enedissgegrandlyon.connect')) - }) + await userEvent.click(screen.getByText('auth.enedissgegrandlyon.connect')) expect(mockedNavigate).toHaveBeenCalled() }) }) diff --git a/src/components/Connection/SGEConnect/StepAddress.spec.tsx b/src/components/Connection/SGEConnect/StepAddress.spec.tsx index 2c293656ea19209741e758188eb3268b36ed6c4d..8442690c836adefca6833b05c3cd38cf9552c723 100644 --- a/src/components/Connection/SGEConnect/StepAddress.spec.tsx +++ b/src/components/Connection/SGEConnect/StepAddress.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { mockSgeState } from 'tests/__mocks__/forms.mock' @@ -22,9 +22,7 @@ describe('StepAddress component', () => { const input = screen.getByRole('textbox', { name: 'auth.enedissgegrandlyon.address', }) - await act(async () => { - await userEvent.type(input, 't') - }) + await userEvent.type(input, 't') expect(mockHandleChange).toHaveBeenCalledWith('address', 't') }) it('should change zipCode value', async () => { @@ -34,9 +32,7 @@ describe('StepAddress component', () => { const input = screen.getByRole('spinbutton', { name: 'auth.enedissgegrandlyon.zipCode', }) - await act(async () => { - await userEvent.type(input, '1') - }) + await userEvent.type(input, '1') expect(mockHandleChange).toHaveBeenCalledWith('zipCode', '1', 5) }) @@ -47,9 +43,7 @@ describe('StepAddress component', () => { const input = screen.getByRole('textbox', { name: 'auth.enedissgegrandlyon.city', }) - await act(async () => { - await userEvent.type(input, 'c') - }) + await userEvent.type(input, 'c') expect(mockHandleChange).toHaveBeenCalledWith('city', 'c') }) }) diff --git a/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx b/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx index db0bb7e1d6909e0773a57d14d1a092b7840fb256..952ec45f9d0646df2d0dfe45a4627912bd174383 100644 --- a/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx +++ b/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { mockSgeState } from 'tests/__mocks__/forms.mock' @@ -21,25 +21,19 @@ describe('StepIdentityAndPdl component', () => { const firstNameInput = screen.getByRole('textbox', { name: 'auth.enedissgegrandlyon.firstName', }) - await act(async () => { - await userEvent.type(firstNameInput, 'n') - }) + await userEvent.type(firstNameInput, 'n') expect(mockHandleChange).toHaveBeenCalledWith('firstName', 'n') const lastNameInput = screen.getByRole('textbox', { name: 'auth.enedissgegrandlyon.lastName', }) - await act(async () => { - await userEvent.type(lastNameInput, 'n') - }) + await userEvent.type(lastNameInput, 'n') expect(mockHandleChange).toHaveBeenCalledWith('lastName', 'n') const pdlInput = screen.getByRole('spinbutton', { name: 'auth.enedissgegrandlyon.pdlLabel', }) - await act(async () => { - await userEvent.type(pdlInput, '0') - }) + await userEvent.type(pdlInput, '0') expect(mockHandleChange).toHaveBeenCalledWith('pdl', '0', 14) }) @@ -47,11 +41,9 @@ describe('StepIdentityAndPdl component', () => { render( <StepIdentityAndPdl sgeState={mockSgeState} onChange={mockHandleChange} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('auth.enedissgegrandlyon.pdlModal.title') - ) - }) + await userEvent.click( + screen.getByText('auth.enedissgegrandlyon.pdlModal.title') + ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) diff --git a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx index a270965bd3f07f817384b2ee62920df46f23bd5b..5ee8e21d1441a8d3d03d6fe2a31a7ac09f6c92ba 100644 --- a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { DataloadState, FluidType } from 'enums' import React from 'react' @@ -121,11 +121,9 @@ describe('DataloadNoValue component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('consumption_visualizer.missing_data') - ) - }) + await userEvent.click( + screen.getByText('consumption_visualizer.missing_data') + ) expect(mockDispatch).toHaveBeenCalledWith({ type: 'chart/setShowConnectionDetails', payload: true, diff --git a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx index 3661724c30e2e89bb0dd5b32c13c437fae2dfab4..e542e6c05384d6e29cb7bc54d90c3e81d7bb75b1 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { DataloadSectionType, FluidType } from 'enums' import { Dataload } from 'models' @@ -88,11 +88,9 @@ describe('DataloadSectionValue component', () => { toggleEstimationModal={mockToggleEstimationModal} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('consumption_visualizer.estimated') - ) - }) + await userEvent.click( + screen.getByText('consumption_visualizer.estimated') + ) expect(mockToggleEstimationModal).toHaveBeenCalled() }) }) diff --git a/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx b/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx index 4c6660d40956aaa653649e0b93d0064038c68592..b91c97ed18e5bd012fe66080be1e5efd9763f2c6 100644 --- a/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx +++ b/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { DataloadState, FluidType } from 'enums' import { DateTime } from 'luxon' @@ -199,11 +199,9 @@ describe('InfoDataConsumptionVisualizer component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('consumption_visualizer.last_available_data') - ) - }) + await userEvent.click( + screen.getByText('consumption_visualizer.last_available_data') + ) expect(mockAppDispatch).toHaveBeenCalled() }) @@ -218,11 +216,9 @@ describe('InfoDataConsumptionVisualizer component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('consumption_visualizer.why_no_data') - ) - }) + await userEvent.click( + screen.getByText('consumption_visualizer.why_no_data') + ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/CustomPopup/CustomPopupModal.spec.tsx b/src/components/CustomPopup/CustomPopupModal.spec.tsx index 5f3786a07ae9a3ee5fa7a06262232da12879cc40..c31b814860dda9edeb149ce119c456e070ffcd94 100644 --- a/src/components/CustomPopup/CustomPopupModal.spec.tsx +++ b/src/components/CustomPopup/CustomPopupModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { @@ -68,11 +68,9 @@ describe('CustomPopupModal component', () => { handleCloseClick={mockHandleClose} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('consumption.partner_issue_modal.ok') - ) - }) + await userEvent.click( + screen.getByText('consumption.partner_issue_modal.ok') + ) expect(mockHandleClose).toHaveBeenCalled() }) }) diff --git a/src/components/DateNavigator/DateNavigator.spec.tsx b/src/components/DateNavigator/DateNavigator.spec.tsx index 29f83296380f5c16c5c913ba90c6e36beba16723..986aaa40b0db9c9b5972a1de3fc3e46046e98fef 100644 --- a/src/components/DateNavigator/DateNavigator.spec.tsx +++ b/src/components/DateNavigator/DateNavigator.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { TimeStep } from 'enums' import { DateTime } from 'luxon' @@ -39,17 +39,13 @@ describe('DateNavigator component', () => { timeStep={TimeStep.MONTH} /> ) - await act(async () => { - await userEvent.click( - screen.getByLabelText('consumption.accessibility.button_previous_value') - ) - }) + await userEvent.click( + screen.getByLabelText('consumption.accessibility.button_previous_value') + ) expect(mockHandlePrevDate).toHaveBeenCalledTimes(1) - await act(async () => { - await userEvent.click( - screen.getByLabelText('consumption.accessibility.button_next_value') - ) - }) + await userEvent.click( + screen.getByLabelText('consumption.accessibility.button_next_value') + ) expect(mockHandleNextDate).toHaveBeenCalledTimes(1) }) diff --git a/src/components/Duel/DuelUnlocked/DuelUnlocked.spec.tsx b/src/components/Duel/DuelUnlocked/DuelUnlocked.spec.tsx index ac8509e849ed3878b23ce96f47f6d703ca926ec0..6175753f3c9c7e7e7973a782b46ab2c900a178c4 100644 --- a/src/components/Duel/DuelUnlocked/DuelUnlocked.spec.tsx +++ b/src/components/Duel/DuelUnlocked/DuelUnlocked.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { FluidType, UserChallengeUpdateFlag } from 'enums' import React from 'react' @@ -53,9 +53,7 @@ describe('DuelUnlocked component', () => { <DuelUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('duel.button_start')) - }) + await userEvent.click(screen.getByText('duel.button_start')) expect(mockUserChallengeUpdateFlag).toHaveBeenCalledWith( userChallengeData[0], UserChallengeUpdateFlag.DUEL_START diff --git a/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx b/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx index 20f5c94c90cbe9613cafdb70e5e70a8c4db99aff..b43a3c1ece6ceedcd74b308561b888302dc627dd 100644 --- a/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx +++ b/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import EcogestureEmptyList from './EcogestureEmptyList' @@ -31,11 +31,9 @@ describe('EcogestureEmptyList component', () => { openResetEcogestureModal={jest.fn()} /> ) - await act(async () => { - await userEvent.click( - screen.getByRole('button', { name: 'ecogesture.emptyList.btn1' }) - ) - }) + await userEvent.click( + screen.getByRole('button', { name: 'ecogesture.emptyList.btn1' }) + ) expect(mockChangeTab).toHaveBeenCalledTimes(1) }) it('should launch ecogesture form', async () => { @@ -47,11 +45,9 @@ describe('EcogestureEmptyList component', () => { openResetEcogestureModal={jest.fn()} /> ) - await act(async () => { - await userEvent.click( - screen.getByRole('button', { name: 'ecogesture.emptyList.btn2' }) - ) - }) + await userEvent.click( + screen.getByRole('button', { name: 'ecogesture.emptyList.btn2' }) + ) expect(mockedNavigate).toHaveBeenCalledWith('/ecogesture-form') }) it('should render doing text with empty list on completed selection', () => { diff --git a/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx b/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx index 78eeccdb511db00c61fe7ef87e1d59c900e48674..e5b578c55554a11511375a491fd086c38f56370f 100644 --- a/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx +++ b/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' import React from 'react' @@ -63,9 +63,7 @@ describe('EcogestureInitModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText(t('ecogesture.initModal.btn2'))) - }) + await userEvent.click(screen.getByText(t('ecogesture.initModal.btn2'))) expect(mockedNavigate).toHaveBeenCalledWith('/ecogesture-form?modal=false') expect(mockOnAccept).toHaveBeenCalled() }) @@ -83,9 +81,7 @@ describe('EcogestureInitModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText(t('ecogesture.initModal.btn1'))) - }) + await userEvent.click(screen.getByText(t('ecogesture.initModal.btn1'))) expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures') expect(mockOnClose).toHaveBeenCalled() }) diff --git a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx index 1e7f223c9b4436f8eb7dd1b6c1a7e9979d048c19..a11635a0814c48954f45a9944baf73cda645d8ec 100644 --- a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx +++ b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -59,12 +59,8 @@ describe('EcogesturesList component', () => { </BrowserRouter> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('ecogesture.MENU_TITLE')) - }) - await act(async () => { - await userEvent.click(screen.getAllByRole('menuitem')[1]) - }) + await userEvent.click(screen.getByText('ecogesture.MENU_TITLE')) + await userEvent.click(screen.getAllByRole('menuitem')[1]) expect(updateEcogestureFilter).toHaveBeenCalledTimes(1) }) @@ -81,9 +77,7 @@ describe('EcogesturesList component', () => { </BrowserRouter> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('ecogesture.button_selection')) - }) + await userEvent.click(screen.getByText('ecogesture.button_selection')) expect(mockedNavigate).toHaveBeenCalledWith('/ecogesture-selection') }) }) diff --git a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx index 7ae9d83388a642af0afa226befd9d44c17467d89..985e265f47af627be786f917745b0e5eb0eb4832 100644 --- a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import EcogestureNotFound from './EcogestureNotFound' @@ -22,9 +22,7 @@ describe('EcogestureNotFound component', () => { }) it('should click on button and be redirected', async () => { render(<EcogestureNotFound text="test" returnPage="ecogestures" />) - await act(async () => { - await userEvent.click(screen.getByText('error_page.back')) - }) + await userEvent.click(screen.getByText('error_page.back')) expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures') }) }) diff --git a/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx b/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx index a60db8c120a72cd988cd862249a154a3137b604d..7d13763d5173b8e38d8c1af479e72014810b4856 100644 --- a/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -49,11 +49,9 @@ describe('EcogestureFormSingleChoice component', () => { </Provider> ) await userEvent.click(screen.getAllByRole('radio')[0]) - await act(async () => { - await userEvent.click( - screen.getByLabelText('profile_type.accessibility.button_next') - ) - }) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_next') + ) expect(mockHandleNextStep).toHaveBeenCalledTimes(1) }) it('should go back', async () => { @@ -69,11 +67,9 @@ describe('EcogestureFormSingleChoice component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByLabelText('profile_type.accessibility.button_previous') - ) - }) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_previous') + ) expect(mockHandlePreviousStep).toHaveBeenCalledTimes(1) }) it('should keep previous answer', () => { diff --git a/src/components/EcogestureForm/EcogestureFormView.spec.tsx b/src/components/EcogestureForm/EcogestureFormView.spec.tsx index 82ec1fe642adf423f7ab5b75fac72f5635dbd77e..4475d9b9d1a2e9f07c81e0284af0e47b76a5bae2 100644 --- a/src/components/EcogestureForm/EcogestureFormView.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -69,12 +69,10 @@ describe('EcogestureFormView component', () => { <EcogestureFormView /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('radio')[0]) - await userEvent.click( - screen.getByLabelText('profile_type.accessibility.button_next') - ) - }) + await userEvent.click(screen.getAllByRole('radio')[0]) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_next') + ) expect( container.getElementsByClassName('ecogesture-form-single').length ).toBeTruthy() diff --git a/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx index f16ad9ebe3cb38245bf2122ed0ecb53da6539755..306dcebd02a81602a6166630a3374c241503d623 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { mockedEcogesturesData } from 'tests/__mocks__/ecogesturesData.mock' @@ -28,9 +28,7 @@ describe('EcogestureSelectionDetail component', () => { title={mockedEcogesturesData[0].shortName} /> ) - await act(async () => { - await userEvent.click(screen.getByText('ecogesture_modal.show_more')) - }) + await userEvent.click(screen.getByText('ecogesture_modal.show_more')) expect(screen.getByText('ecogesture_modal.show_less')).toBeInTheDocument() }) it('should call validate with objective to true', async () => { @@ -41,11 +39,9 @@ describe('EcogestureSelectionDetail component', () => { title={mockedEcogesturesData[0].shortName} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('ecogesture_selection.button_objective') - ) - }) + await userEvent.click( + screen.getByText('ecogesture_selection.button_objective') + ) expect(mockValidate).toHaveBeenCalledWith(true, false) }) @@ -57,11 +53,9 @@ describe('EcogestureSelectionDetail component', () => { title={mockedEcogesturesData[0].shortName} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('ecogesture_selection.button_doing') - ) - }) + await userEvent.click( + screen.getByText('ecogesture_selection.button_doing') + ) expect(mockValidate).toHaveBeenCalledWith(false, true) }) @@ -73,11 +67,9 @@ describe('EcogestureSelectionDetail component', () => { title={mockedEcogesturesData[0].shortName} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('ecogesture_selection.button_skip') - ) - }) + await userEvent.click( + screen.getByText('ecogesture_selection.button_skip') + ) expect(mockValidate).toHaveBeenCalledWith(false, false) }) }) diff --git a/src/components/EcogestureSelection/EcogestureSelectionEnd/EcogestureSelectionEnd.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionEnd/EcogestureSelectionEnd.spec.tsx index b17eb56aa8c598a687b102eb3b88085a36071122..a4c6b73ab2b42fc7293b5e868683b3cd7d75c38d 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionEnd/EcogestureSelectionEnd.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionEnd/EcogestureSelectionEnd.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import EcogestureSelectionEnd from './EcogestureSelectionEnd' @@ -21,9 +21,7 @@ describe('EcogestureSelectionEnd component', () => { it('should close modal and update profile', async () => { render(<EcogestureSelectionEnd />) - await act(async () => { - await userEvent.click(screen.getByText('ecogesture_selection.button_ok')) - }) + await userEvent.click(screen.getByText('ecogesture_selection.button_ok')) expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures?tab=0') }) }) diff --git a/src/components/EcogestureSelection/EcogestureSelectionModal/EcogestureSelectionModal.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionModal/EcogestureSelectionModal.spec.tsx index 6b72660464b8a92259ffd9acfa628856cec44276..f4a85b890e492e8bf6a992067af953f7297935dc 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionModal/EcogestureSelectionModal.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionModal/EcogestureSelectionModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import EcogestureSelectionModal from './EcogestureSelectionModal' @@ -22,11 +22,9 @@ describe('EcogestureInitModal component', () => { handleCloseClick={mockHandleClose} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('ecogesture_selection.selectionModal.button_close') - ) - }) + await userEvent.click( + screen.getByText('ecogesture_selection.selectionModal.button_close') + ) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/EcogestureSelection/EcogestureSelectionRestart/EcogestureSelectionRestart.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionRestart/EcogestureSelectionRestart.spec.tsx index e8f57688cdabd241c507f523ee6b74cb2ad9c6e4..6ddd00ef4900716ace91d0203f6fdb07b97256a4 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionRestart/EcogestureSelectionRestart.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionRestart/EcogestureSelectionRestart.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import EcogestureSelectionRestart from './EcogestureSelectionRestart' @@ -20,21 +20,17 @@ describe('EcogestureSelectionRestart component', () => { it('should call go to the ecogesture view when user click on the button', async () => { render(<EcogestureSelectionRestart listLength={10} restart={mockRestart} />) - await act(async () => { - await userEvent.click( - screen.getByText('ecogesture_selection.button_go_to_ecogesture') - ) - }) + await userEvent.click( + screen.getByText('ecogesture_selection.button_go_to_ecogesture') + ) expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures?tab=0') }) it('should call the restart when user click on the button', async () => { render(<EcogestureSelectionRestart listLength={10} restart={mockRestart} />) - await act(async () => { - await userEvent.click( - screen.getByText('ecogesture_selection.button_continue') - ) - }) + await userEvent.click( + screen.getByText('ecogesture_selection.button_continue') + ) expect(mockRestart).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Exploration/ExplorationFinished.spec.tsx b/src/components/Exploration/ExplorationFinished.spec.tsx index 8dc48fdbcde9eb7af951be0d7a5414cc81e3b824..05b28a78a917a090ee13a401c55fc6dbc91e2706 100644 --- a/src/components/Exploration/ExplorationFinished.spec.tsx +++ b/src/components/Exploration/ExplorationFinished.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -26,9 +26,7 @@ describe('ExplorationFinished', () => { expect( screen.getByText(userChallengeData[0].exploration.message_success) ).toBeInTheDocument() - await act(async () => { - await userEvent.click(screen.getByText('exploration.button_confirm')) - }) + await userEvent.click(screen.getByText('exploration.button_confirm')) expect(mockNavigate).toHaveBeenCalledWith(-1) }) }) diff --git a/src/components/Feedback/FeedbackModal.spec.tsx b/src/components/Feedback/FeedbackModal.spec.tsx index 2444ef63d92c6c1c0a76635f7474c207172fc39e..7b18719b571501e7377732c44ee9ccfcc791f78f 100644 --- a/src/components/Feedback/FeedbackModal.spec.tsx +++ b/src/components/Feedback/FeedbackModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import FeedbackModal from 'components/Feedback/FeedbackModal' import React from 'react' @@ -40,9 +40,7 @@ describe('FeedbackModal component', () => { <FeedbackModal /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('feedback.lets_go')) - }) + await userEvent.click(screen.getByText('feedback.lets_go')) expect(window.open).toHaveBeenCalledTimes(1) expect(global.open).toHaveBeenCalledWith(`${__SAU_LINK__}?version=0.0.0`) }) diff --git a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx index ab25fa0ef054088f668adbf8f7ec414cc5e77381..a636e9021f0866ea3735e28eb12e0e7eaff81ce7 100644 --- a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx +++ b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import TimeStepSelector from 'components/FluidChart/TimeStepSelector/TimeStepSelector' import { FluidType, TimeStep } from 'enums' @@ -69,9 +69,7 @@ describe('TimeStepSelector component', () => { <TimeStepSelector fluidType={FluidType.WATER} /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('listitem')[2]) - }) + await userEvent.click(screen.getAllByRole('listitem')[2]) expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.DAY) expect(setCurrentIndexSpy).toHaveBeenCalledTimes(1) @@ -91,9 +89,7 @@ describe('TimeStepSelector component', () => { <TimeStepSelector fluidType={FluidType.WATER} /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('timestep.today')) - }) + await userEvent.click(screen.getByText('timestep.today')) expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK) expect(setCurrentIndexSpy).toHaveBeenCalledTimes(1) diff --git a/src/components/Header/CozyBar.spec.tsx b/src/components/Header/CozyBar.spec.tsx index f8ecdef730022fd348c818dd48754893f69c73cc..31eeffaff78e7cc3a9788257e457a99fe0d9d35f 100644 --- a/src/components/Header/CozyBar.spec.tsx +++ b/src/components/Header/CozyBar.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import CozyBar from 'components/Header/CozyBar' import { ScreenType } from 'enums' @@ -44,11 +44,9 @@ describe('CozyBar component', () => { </Provider> ) expect(container).toMatchSnapshot() - await act(async () => { - await userEvent.click( - screen.getByLabelText('header.accessibility.button_back') - ) - }) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) expect(mockedNavigate).toHaveBeenCalled() }) @@ -60,11 +58,9 @@ describe('CozyBar component', () => { </Provider> ) expect(container).toMatchSnapshot() - await act(async () => { - await userEvent.click( - screen.getByLabelText('header.accessibility.button_back') - ) - }) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) expect(mockBackFunction).toHaveBeenCalled() }) }) @@ -76,11 +72,9 @@ describe('CozyBar component', () => { </Provider> ) const updateModalSpy = jest.spyOn(ModalAction, 'openFeedbackModal') - await act(async () => { - await userEvent.click( - screen.getByLabelText('header.accessibility.button_open_feedbacks') - ) - }) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_open_feedbacks') + ) expect(updateModalSpy).toHaveBeenCalledWith(true) }) diff --git a/src/components/Header/Header.spec.tsx b/src/components/Header/Header.spec.tsx index 2ce2ad0ad6c18cb997af2983b04980df8d14e8f4..4b4c86456dd0d7af9a3aefda5bc95f2ef1283136 100644 --- a/src/components/Header/Header.spec.tsx +++ b/src/components/Header/Header.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import Header from 'components/Header/Header' import { ScreenType } from 'enums' @@ -95,11 +95,9 @@ describe('Header component', () => { <Header desktopTitleKey="KEY" displayBackArrow={true} /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByLabelText('header.accessibility.button_back') - ) - }) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) expect(mockedNavigate).toHaveBeenCalled() }) @@ -114,11 +112,9 @@ describe('Header component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByLabelText('header.accessibility.button_back') - ) - }) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) expect(mockBack).toHaveBeenCalled() }) }) @@ -130,11 +126,9 @@ describe('Header component', () => { </Provider> ) const updateModalSpy = jest.spyOn(ModalAction, 'openFeedbackModal') - await act(async () => { - await userEvent.click( - screen.getByLabelText('header.accessibility.button_open_feedbacks') - ) - }) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_open_feedbacks') + ) expect(updateModalSpy).toHaveBeenCalledWith(true) }) }) diff --git a/src/components/Konnector/ConnectionNotFound/ConnectionNotFound.spec.tsx b/src/components/Konnector/ConnectionNotFound/ConnectionNotFound.spec.tsx index 72388b748c22057ec7520884c6de66ef07bdd6ba..547047dcc4a4dd2441bec532298a23a5f55fe152 100644 --- a/src/components/Konnector/ConnectionNotFound/ConnectionNotFound.spec.tsx +++ b/src/components/Konnector/ConnectionNotFound/ConnectionNotFound.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import ConnectionNotFound from './ConnectionNotFound' @@ -16,9 +16,7 @@ describe('ConnectionNotFound component test', () => { it('should open konnector url when button is clicked', async () => { global.open = jest.fn() render(<ConnectionNotFound konnectorSlug={konnectorSlug} />) - await act(async () => { - await userEvent.click(screen.getByText('konnector_form.button_install')) - }) + await userEvent.click(screen.getByText('konnector_form.button_install')) expect(global.open).toHaveBeenCalledWith( 'http://localhost/#/discover/enedissgegrandlyon', '_blank' diff --git a/src/components/Konnector/KonnectorModal.spec.tsx b/src/components/Konnector/KonnectorModal.spec.tsx index 32d0a9b8bad35cfaba93c98984b7e483e1d38bbc..9b9806b12c72ce2e1b10fc0a1640ab4f6724fdf9 100644 --- a/src/components/Konnector/KonnectorModal.spec.tsx +++ b/src/components/Konnector/KonnectorModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { FluidType, KonnectorError } from 'enums' import React from 'react' @@ -64,9 +64,7 @@ describe('KonnectorModal component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('konnector_modal.button_validate')) - }) + await userEvent.click(screen.getByText('konnector_modal.button_validate')) expect(mockHandleCloseClick).toHaveBeenCalled() }) it('should render login error', () => { diff --git a/src/components/Konnector/KonnectorModalFooter.spec.tsx b/src/components/Konnector/KonnectorModalFooter.spec.tsx index 42e3e61b7f0d93c4aaa63ae640775e09ce726a86..85b112936545a0fca39ac4dae645494a51cea7e9 100644 --- a/src/components/Konnector/KonnectorModalFooter.spec.tsx +++ b/src/components/Konnector/KonnectorModalFooter.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { ERROR_EVENT } from 'cozy-harvest-lib/dist/models/flowEvents' import { KonnectorError } from 'enums' @@ -105,9 +105,7 @@ describe('KonnectorModalFooter component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('konnector_modal.button_go')) - }) + await userEvent.click(screen.getByText('konnector_modal.button_go')) expect(mockDelete).toHaveBeenCalled() expect(mockedNavigate).toHaveBeenCalledTimes(1) }) @@ -124,9 +122,7 @@ describe('KonnectorModalFooter component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getByText('konnector_modal.button_go')) - }) + await userEvent.click(screen.getByText('konnector_modal.button_go')) expect(mockDelete).toHaveBeenCalled() expect(mockedNavigate).toHaveBeenCalledTimes(1) }) @@ -143,11 +139,7 @@ describe('KonnectorModalFooter component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('konnector_modal.button_check_info') - ) - }) + await userEvent.click(screen.getByText('konnector_modal.button_check_info')) expect(mockedNavigate).toHaveBeenCalledTimes(1) expect(mockDelete).toHaveBeenCalledTimes(0) }) diff --git a/src/components/Konnector/KonnectorViewerList.spec.tsx b/src/components/Konnector/KonnectorViewerList.spec.tsx index ec1693348682457abc3d37507be0785984157e98..a199d3f5bd640d26c29c9227502c78467885a487 100644 --- a/src/components/Konnector/KonnectorViewerList.spec.tsx +++ b/src/components/Konnector/KonnectorViewerList.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -28,11 +28,9 @@ describe('KonnectorViewerList component', () => { <KonnectorViewerList /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('konnector_options.label_connect_to_electricity') - ) - }) + await userEvent.click( + screen.getByText('konnector_options.label_connect_to_electricity') + ) expect(mockedNavigate).toHaveBeenCalled() }) }) diff --git a/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx b/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx index 56cd7cac4a4229f25e985ebecba5e9045cb9cbb4..1a9d02c1b20af8b9894ee526b474fbd713b75022 100644 --- a/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import ExportDoneModal from './exportDoneModal' @@ -27,9 +27,7 @@ describe('exportDoneModal component', () => { handleCloseClick={mockHandleClose} /> ) - await act(async () => { - await userEvent.click(screen.getByText('export.modal_done.button_close')) - }) + await userEvent.click(screen.getByText('export.modal_done.button_close')) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx b/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx index 8fe1bce5b001c91dc854b98722a482ba50a95be7..f2ccf3ef1377bbd5189e7bf5583dd99b61ec8b25 100644 --- a/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { allFluids } from 'utils/utils' @@ -27,11 +27,9 @@ describe('ExportLoadingModal component', () => { selectedFluids={allFluids} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('export.modal_loading.button_cancel') - ) - }) + await userEvent.click( + screen.getByText('export.modal_loading.button_cancel') + ) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx b/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx index a903a4151cdf312142c580be8e965d776c50966d..60f866d6ccd71827f65d5276cf4e78197e301ec6 100644 --- a/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import ExportStartModal from './exportStartModal' @@ -24,11 +24,7 @@ describe('exportStartModal component', () => { handleDownloadClick={jest.fn()} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('export.modal_start.button_cancel') - ) - }) + await userEvent.click(screen.getByText('export.modal_start.button_cancel')) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx index 1ecad5c9a8a396d1ab3087f8c050d4b78cb3a2ac..98c930c28da001585087f5422eb2b8fa329cb645 100644 --- a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx +++ b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import ProfileTypeOptions from 'components/Options/ProfileTypeOptions/ProfileTypeOptions' import { @@ -31,9 +31,7 @@ describe('ProfileTypeOptions component', () => { </Provider> ) expect(container.getElementsByClassName('profile-icon').length).toBeTruthy() - await act(async () => { - await userEvent.click(screen.getByText('profile_type.read_profile')) - }) + await userEvent.click(screen.getByText('profile_type.read_profile')) expect(mockedNavigate).toHaveBeenCalled() }) it('should be rendered when user complete profile type form', () => { diff --git a/src/components/Options/ReportOptions/ReportOptions.spec.tsx b/src/components/Options/ReportOptions/ReportOptions.spec.tsx index ff979961be610940b17fc79bc0c10b065714caaa..ed695a25b4f2497ee894d18549da35415483fd52 100644 --- a/src/components/Options/ReportOptions/ReportOptions.spec.tsx +++ b/src/components/Options/ReportOptions/ReportOptions.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import ReportOptions from 'components/Options/ReportOptions/ReportOptions' import React from 'react' @@ -41,9 +41,7 @@ describe('ReportOptions component', () => { <ReportOptions /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('checkbox')[0]) - }) + await userEvent.click(screen.getAllByRole('checkbox')[0]) expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendAnalysisNotification: false, @@ -59,9 +57,7 @@ describe('ReportOptions component', () => { <ReportOptions /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('checkbox')[0]) - }) + await userEvent.click(screen.getAllByRole('checkbox')[0]) expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendAnalysisNotification: true, @@ -80,9 +76,7 @@ describe('ReportOptions component', () => { </Provider> ) expect(screen.getAllByRole('checkbox')[1]).not.toBeChecked() - await act(async () => { - await userEvent.click(screen.getAllByRole('checkbox')[1]) - }) + await userEvent.click(screen.getAllByRole('checkbox')[1]) expect(updateProfileSpy).toHaveBeenCalledTimes(1) expect(updateProfileSpy).toHaveBeenCalledWith({ sendConsumptionAlert: true, diff --git a/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx b/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx index 9a9ac90550c1ace8b3d4adc06a97e27198e8eb61..e77db8515bbd5adb25400d8c0b94b4883e5e3a14 100644 --- a/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx +++ b/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import Unsubscribe from './Unsubscribe' @@ -20,9 +20,7 @@ describe('Unsubscribe component', () => { it('should click the subscribe button', async () => { const { container } = render(<Unsubscribe />) await waitFor(() => null, { container }) - await act(async () => { - await userEvent.click(screen.getByText('unsubscribe.button_subscribe')) - }) + await userEvent.click(screen.getByText('unsubscribe.button_subscribe')) expect(mockUpdateProfile).toHaveBeenCalled() // then should only display one button diff --git a/src/components/PartnerIssue/PartnerIssueModal.spec.tsx b/src/components/PartnerIssue/PartnerIssueModal.spec.tsx index 41789bf10ed7bf69f7abe1b9afc611921fb1f6a7..1e2788f24b42ba6659bf68a7571de5e7d1ca2cf5 100644 --- a/src/components/PartnerIssue/PartnerIssueModal.spec.tsx +++ b/src/components/PartnerIssue/PartnerIssueModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { FluidType } from 'enums' import React from 'react' @@ -49,11 +49,9 @@ describe('PartnerIssueModal component', () => { issuedFluid={FluidType.ELECTRICITY} /> ) - await act(async () => { - await userEvent.click( - screen.getByText('consumption.partner_issue_modal.ok') - ) - }) + await userEvent.click( + screen.getByText('consumption.partner_issue_modal.ok') + ) expect(mockHandleClose).toHaveBeenCalled() }) diff --git a/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx b/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx index 7c697496455ff16cdba2c8e3a05572b776a743a8..2c48d9bf8d7e2defbb4da9422de83e6ff33d474f 100644 --- a/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx +++ b/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -45,11 +45,9 @@ describe('ProfileTypeFinished component', () => { <ProfileTypeFinished profileType={mockProfileType} /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByLabelText('profile_type.accessibility.button_validate') - ) - }) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_validate') + ) expect(mockedNavigate).toHaveBeenCalledWith('/ecogesture-selection') }) }) diff --git a/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx b/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx index 11d1e2a39aea132089405f564acdd26a7a19ba40..23bf1373f5abf5ff653c33324513f48e18f2c5b8 100644 --- a/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx +++ b/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { UserChallengeUpdateFlag } from 'enums' import React from 'react' @@ -24,9 +24,7 @@ describe('QuizBegin component', () => { </Provider> ) expect(container.getElementsByClassName('quiz-icon')[0]).toBeInTheDocument() - await act(async () => { - await userEvent.click(screen.getByText('duel.button_start')) - }) + await userEvent.click(screen.getByText('duel.button_start')) expect(mockUserChallengeUpdateFlag).toHaveBeenCalledWith( userChallengeData[0], UserChallengeUpdateFlag.QUIZ_START diff --git a/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx b/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx index 64c31a9f68eaeba845876e8e4e4a7cc58ff0da9c..5a2787144a98612fe9f9c2a56c790bf25330c48b 100644 --- a/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx +++ b/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -29,9 +29,7 @@ describe('QuizFinish', () => { </Provider> ) expect(container.getElementsByClassName('quiz-icon')[0]).toBeInTheDocument() - await act(async () => { - await userEvent.click(screen.getByText('quiz.button_go_back')) - }) + await userEvent.click(screen.getByText('quiz.button_go_back')) expect(mockUserChallengeUpdateFlag).toHaveBeenCalled() expect(mockedNavigate).toHaveBeenCalledWith('/challenges') }) diff --git a/src/components/Quiz/QuizQuestion/QuizQuestionContent.spec.tsx b/src/components/Quiz/QuizQuestion/QuizQuestionContent.spec.tsx index 24613141899dab79b74d474a8f10ddae3f4a677a..9d922a93ba4aa9f417f110d2856c632f3db0dda3 100644 --- a/src/components/Quiz/QuizQuestion/QuizQuestionContent.spec.tsx +++ b/src/components/Quiz/QuizQuestion/QuizQuestionContent.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -53,9 +53,7 @@ describe('QuizQuestionContent component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) - }) + await userEvent.click(screen.getAllByRole('button')[0]) expect(mockedNavigate).toHaveBeenCalledWith('/challenges') }) }) diff --git a/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx b/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx index 9271ef602efce1995073d6e7612b0bebf283979a..11808e83dd887b29f6f23323047750891af52351 100644 --- a/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx +++ b/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -42,9 +42,7 @@ describe('QuizCustomQuestionContent component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) - }) + await userEvent.click(screen.getAllByRole('button')[0]) expect(mockHistoryPush).toHaveBeenCalledWith('/challenges') expect(screen.getByText(questionEntity.questionLabel)).toBeInTheDocument() expect(screen.getAllByRole('radio').length).toBe(3) @@ -60,10 +58,8 @@ describe('QuizCustomQuestionContent component', () => { /> </Provider> ) - await act(async () => { - await userEvent.click(screen.getAllByRole('radio')[0]) - await userEvent.click(screen.getByText('quiz.button_validate')) - }) + await userEvent.click(screen.getAllByRole('radio')[0]) + await userEvent.click(screen.getByText('quiz.button_validate')) expect(mockUpdateUserQuiz).toHaveBeenCalledWith( userChallengeData[0].quiz, questionEntity.answers[0].isTrue diff --git a/src/components/Splash/SplashScreenError.spec.tsx b/src/components/Splash/SplashScreenError.spec.tsx index 2aefa0711d893cb9594977a0c7f9e51014649ae5..fdc4e5fa594aaaf15732ef0aee420bf1b119dc23 100644 --- a/src/components/Splash/SplashScreenError.spec.tsx +++ b/src/components/Splash/SplashScreenError.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import { InitStepsErrors } from 'models/initialisationSteps.model' import React from 'react' @@ -24,9 +24,7 @@ describe('SplashScreenError component', () => { }) it('should reload the page', async () => { render(<SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />) - await act(async () => { - await userEvent.click(screen.getByRole('button')) - }) + await userEvent.click(screen.getByRole('button')) expect(window.location.reload).toHaveBeenCalled() }) }) diff --git a/src/components/Terms/TermsView.spec.tsx b/src/components/Terms/TermsView.spec.tsx index 0c9e0a9c5e324ea38e73d2918bd4f424bfc2aab5..ff62f04f70cfde21f034230478c353c830315083 100644 --- a/src/components/Terms/TermsView.spec.tsx +++ b/src/components/Terms/TermsView.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen, waitFor } from '@testing-library/react' +import { render, screen, waitFor } from '@testing-library/react' import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -51,13 +51,11 @@ describe('TermsView component', () => { <TermsView /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByRole('button', { - name: 'dataShare.validCGU_button', - }) - ) - }) + await userEvent.click( + screen.getByRole('button', { + name: 'dataShare.validCGU_button', + }) + ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) @@ -67,11 +65,9 @@ describe('TermsView component', () => { <TermsView /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByRole('button', { name: 'dataShare.validLegal_button' }) - ) - }) + await userEvent.click( + screen.getByRole('button', { name: 'dataShare.validLegal_button' }) + ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) it('should be unable to click "validate" button first then enable checkboxes and valid consent', async () => { @@ -90,11 +86,9 @@ describe('TermsView component', () => { expect(mockUpdateProfile).toHaveBeenCalledTimes(0) const [boxGCU, boxLegal] = screen.getAllByRole('checkbox') - await act(async () => { - await userEvent.click(boxGCU) - await userEvent.click(boxLegal) - await userEvent.click(acceptButton) - }) + await userEvent.click(boxGCU) + await userEvent.click(boxLegal) + await userEvent.click(acceptButton) expect(mockAppDispatch).toHaveBeenCalledTimes(4) }) diff --git a/src/components/WelcomeModal/WelcomeModal.spec.tsx b/src/components/WelcomeModal/WelcomeModal.spec.tsx index e40b1823b6d96712906210e93cf24dcdd9c5f6c5..7b61c549f3fd9680229cb3a1115dfc67ef6a5429 100644 --- a/src/components/WelcomeModal/WelcomeModal.spec.tsx +++ b/src/components/WelcomeModal/WelcomeModal.spec.tsx @@ -1,4 +1,4 @@ -import { act, render, screen } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' @@ -68,11 +68,9 @@ describe('WelcomeModal component', () => { <WelcomeModal open={true} /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getByText('onboarding.welcomeModal.button_valid') - ) - }) + await userEvent.click( + screen.getByText('onboarding.welcomeModal.button_valid') + ) expect(mockSendMail).toHaveBeenCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ isFirstConnection: false, @@ -88,13 +86,11 @@ describe('WelcomeModal component', () => { <WelcomeModal open={true} /> </Provider> ) - await act(async () => { - await userEvent.click( - screen.getAllByLabelText( - 'onboarding.welcomeModal.accessibility.button_valid' - )[0] - ) - }) + await userEvent.click( + screen.getAllByLabelText( + 'onboarding.welcomeModal.accessibility.button_valid' + )[0] + ) expect(mockSendMail).toHaveBeenCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ isFirstConnection: false,