Skip to content
Snippets Groups Projects
Commit 5f3901d0 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'lint/rtl-unnecessary-act' into 'dev'

lint(tests): remove unnecessary act

See merge request !1281
parents 0b202a71 29c4e95d
Branches
Tags
1 merge request!1281lint(tests): remove unnecessary act
import { act, render, screen } from '@testing-library/react' import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event' import { userEvent } from '@testing-library/user-event'
import React from 'react' import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
...@@ -42,9 +42,7 @@ describe('QuizCustomQuestionContent component', () => { ...@@ -42,9 +42,7 @@ describe('QuizCustomQuestionContent component', () => {
/> />
</Provider> </Provider>
) )
await act(async () => { await userEvent.click(screen.getAllByRole('button')[0])
await userEvent.click(screen.getAllByRole('button')[0])
})
expect(mockHistoryPush).toHaveBeenCalledWith('/challenges') expect(mockHistoryPush).toHaveBeenCalledWith('/challenges')
expect(screen.getByText(questionEntity.questionLabel)).toBeInTheDocument() expect(screen.getByText(questionEntity.questionLabel)).toBeInTheDocument()
expect(screen.getAllByRole('radio').length).toBe(3) expect(screen.getAllByRole('radio').length).toBe(3)
...@@ -60,10 +58,8 @@ describe('QuizCustomQuestionContent component', () => { ...@@ -60,10 +58,8 @@ describe('QuizCustomQuestionContent component', () => {
/> />
</Provider> </Provider>
) )
await act(async () => { await userEvent.click(screen.getAllByRole('radio')[0])
await userEvent.click(screen.getAllByRole('radio')[0]) await userEvent.click(screen.getByText('quiz.button_validate'))
await userEvent.click(screen.getByText('quiz.button_validate'))
})
expect(mockUpdateUserQuiz).toHaveBeenCalledWith( expect(mockUpdateUserQuiz).toHaveBeenCalledWith(
userChallengeData[0].quiz, userChallengeData[0].quiz,
questionEntity.answers[0].isTrue questionEntity.answers[0].isTrue
......
import { act, render, screen } from '@testing-library/react' import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event' import { userEvent } from '@testing-library/user-event'
import { InitStepsErrors } from 'models/initialisationSteps.model' import { InitStepsErrors } from 'models/initialisationSteps.model'
import React from 'react' import React from 'react'
...@@ -24,9 +24,7 @@ describe('SplashScreenError component', () => { ...@@ -24,9 +24,7 @@ describe('SplashScreenError component', () => {
}) })
it('should reload the page', async () => { it('should reload the page', async () => {
render(<SplashScreenError error={InitStepsErrors.CONSENT_ERROR} />) 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() expect(window.location.reload).toHaveBeenCalled()
}) })
}) })
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 { userEvent } from '@testing-library/user-event'
import React from 'react' import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
...@@ -51,13 +51,11 @@ describe('TermsView component', () => { ...@@ -51,13 +51,11 @@ describe('TermsView component', () => {
<TermsView /> <TermsView />
</Provider> </Provider>
) )
await act(async () => { await userEvent.click(
await userEvent.click( screen.getByRole('button', {
screen.getByRole('button', { name: 'dataShare.validCGU_button',
name: 'dataShare.validCGU_button', })
}) )
)
})
expect(screen.getByRole('dialog')).toBeInTheDocument() expect(screen.getByRole('dialog')).toBeInTheDocument()
}) })
...@@ -67,11 +65,9 @@ describe('TermsView component', () => { ...@@ -67,11 +65,9 @@ describe('TermsView component', () => {
<TermsView /> <TermsView />
</Provider> </Provider>
) )
await act(async () => { await userEvent.click(
await userEvent.click( screen.getByRole('button', { name: 'dataShare.validLegal_button' })
screen.getByRole('button', { name: 'dataShare.validLegal_button' }) )
)
})
expect(screen.getByRole('dialog')).toBeInTheDocument() expect(screen.getByRole('dialog')).toBeInTheDocument()
}) })
it('should be unable to click "validate" button first then enable checkboxes and valid consent', async () => { it('should be unable to click "validate" button first then enable checkboxes and valid consent', async () => {
...@@ -90,11 +86,9 @@ describe('TermsView component', () => { ...@@ -90,11 +86,9 @@ describe('TermsView component', () => {
expect(mockUpdateProfile).toHaveBeenCalledTimes(0) expect(mockUpdateProfile).toHaveBeenCalledTimes(0)
const [boxGCU, boxLegal] = screen.getAllByRole('checkbox') const [boxGCU, boxLegal] = screen.getAllByRole('checkbox')
await act(async () => { await userEvent.click(boxGCU)
await userEvent.click(boxGCU) await userEvent.click(boxLegal)
await userEvent.click(boxLegal) await userEvent.click(acceptButton)
await userEvent.click(acceptButton)
})
expect(mockAppDispatch).toHaveBeenCalledTimes(4) expect(mockAppDispatch).toHaveBeenCalledTimes(4)
}) })
......
import { act, render, screen } from '@testing-library/react' import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event' import userEvent from '@testing-library/user-event'
import React from 'react' import React from 'react'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
...@@ -68,11 +68,9 @@ describe('WelcomeModal component', () => { ...@@ -68,11 +68,9 @@ describe('WelcomeModal component', () => {
<WelcomeModal open={true} /> <WelcomeModal open={true} />
</Provider> </Provider>
) )
await act(async () => { await userEvent.click(
await userEvent.click( screen.getByText('onboarding.welcomeModal.button_valid')
screen.getByText('onboarding.welcomeModal.button_valid') )
)
})
expect(mockSendMail).toHaveBeenCalled() expect(mockSendMail).toHaveBeenCalled()
expect(updateProfileSpy).toHaveBeenCalledWith({ expect(updateProfileSpy).toHaveBeenCalledWith({
isFirstConnection: false, isFirstConnection: false,
...@@ -88,13 +86,11 @@ describe('WelcomeModal component', () => { ...@@ -88,13 +86,11 @@ describe('WelcomeModal component', () => {
<WelcomeModal open={true} /> <WelcomeModal open={true} />
</Provider> </Provider>
) )
await act(async () => { await userEvent.click(
await userEvent.click( screen.getAllByLabelText(
screen.getAllByLabelText( 'onboarding.welcomeModal.accessibility.button_valid'
'onboarding.welcomeModal.accessibility.button_valid' )[0]
)[0] )
)
})
expect(mockSendMail).toHaveBeenCalled() expect(mockSendMail).toHaveBeenCalled()
expect(updateProfileSpy).toHaveBeenCalledWith({ expect(updateProfileSpy).toHaveBeenCalledWith({
isFirstConnection: false, isFirstConnection: false,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment