diff --git a/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx b/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx index 098ee31407b05bd54d157602076284e341516dc8..1c8b8f3414a79c8d798a69a2dca9598cb1fc9ea7 100644 --- a/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx +++ b/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx @@ -35,9 +35,12 @@ describe('MaxConsumptionCard component', () => { </Provider> ) await waitFor(() => null, { container }) - const [prevButton, nextButton] = screen.getAllByRole('button') - expect(prevButton).toBeDisabled() - expect(nextButton).toBeDisabled() + expect( + screen.getByLabelText('consumption.accessibility.button_previous_value') + ).toBeDisabled() + expect( + screen.getByLabelText('consumption.accessibility.button_next_value') + ).toBeDisabled() }) it('should be rendered with several fluids and click navigate between fluid', async () => { const { container } = render( diff --git a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx index 1b2f9d2eae765da5f7caf69cd1ebcbc74b67efa3..d62b47d36700bfebc8cddf816d03ef991ab9ba93 100644 --- a/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx +++ b/src/components/Challenge/ChallengeCardDone/ChallengeCardDone.spec.tsx @@ -65,10 +65,8 @@ describe('ChallengeCardDone component', () => { <ChallengeCardDone userChallenge={userChallengeData[0]} /> </Provider> ) - const resetButton = screen.getByRole('button', { - name: 'challenge.card_done.reset_defi', - }) - expect(resetButton).toHaveProperty('disabled') + const resetBtn = screen.getByLabelText('challenge.card_done.reset_defi') + expect(resetBtn).toHaveProperty('disabled') expect(mockDispatch).toHaveBeenCalledTimes(0) expect(mockUpdateUserChallenge).toHaveBeenCalledTimes(0) }) @@ -78,10 +76,8 @@ describe('ChallengeCardDone component', () => { <ChallengeCardDone userChallenge={userChallengeData[1]} /> </Provider> ) - const resetButton = screen.getByRole('button', { - name: 'challenge.card_done.reset_defi', - }) - expect(resetButton).toHaveClass('btnPrimaryNegative') + const resetBtn = screen.getByLabelText('challenge.card_done.reset_defi') + expect(resetBtn).toHaveClass('btnPrimaryNegative') }) it('should be secondary button is challenge is won', async () => { render( @@ -89,10 +85,8 @@ describe('ChallengeCardDone component', () => { <ChallengeCardDone userChallenge={userChallengeData[0]} /> </Provider> ) - const resetButton = screen.getByRole('button', { - name: 'challenge.card_done.reset_defi', - }) - expect(resetButton).toHaveClass('btnSecondary') + const resetBtn = screen.getByLabelText('challenge.card_done.reset_defi') + expect(resetBtn).toHaveClass('btnSecondary') }) }) }) diff --git a/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx b/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx index 9dae95a5e0d3387e6deb963948d6dadb053c08d6..89209571b601b886564d81ed83d6821e989b787f 100644 --- a/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx +++ b/src/components/Challenge/ChallengeCardUnlocked/ChallengeCardUnlocked.spec.tsx @@ -84,7 +84,9 @@ describe('ChallengeCardUnlocked component', () => { <ChallengeCardUnlocked userChallenge={userChallengeData[0]} /> </Provider> ) - const resetButton = screen.getByRole('button') - expect(resetButton).toHaveAttribute('disabled') + const launchBtn = screen.getByLabelText( + 'challenge.accessibility.button_launch' + ) + expect(launchBtn).toHaveAttribute('disabled') }) }) diff --git a/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx b/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx index 0584ba26ad02520ecf428b1d02aaa8fd35d0e689..0d8be396b947acfd4f3ea589bacc19da9cabb42f 100644 --- a/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx +++ b/src/components/CommonKit/FormNavigation/FormNavigation.spec.tsx @@ -15,13 +15,14 @@ describe('FormNavigation component', () => { disablePrevButton={false} /> ) - const [prevButton, nextButton] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(prevButton) + await userEvent.click( + screen.getByText('profile_type.form.button_previous') + ) }) expect(mockHandlePrevious).toHaveBeenCalled() await act(async () => { - await userEvent.click(nextButton) + 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 58c1ab6dc9a835d6d0aab431d46c9b9f0f439d49..a5edf19121aeb28e37bb93818c5d2b77a684d0a2 100644 --- a/src/components/Connection/ExpiredConsentModal/ExpiredConsentModal.spec.tsx +++ b/src/components/Connection/ExpiredConsentModal/ExpiredConsentModal.spec.tsx @@ -46,9 +46,7 @@ describe('ExpiredConsentModal component', () => { </Provider> ) await act(async () => { - await userEvent.click( - screen.getByRole('button', { name: 'consent_outdated.go' }) - ) + await userEvent.click(screen.getByText('consent_outdated.go')) }) expect(mockAppDispatch).toHaveBeenCalledTimes(1) expect(mockedNavigate).toHaveBeenCalledTimes(1) @@ -68,9 +66,7 @@ describe('ExpiredConsentModal component', () => { </Provider> ) await act(async () => { - await userEvent.click( - screen.getByRole('button', { name: 'consent_outdated.go' }) - ) + await userEvent.click(screen.getByText('consent_outdated.yes')) }) expect(mockAppDispatch).toHaveBeenCalledTimes(1) expect(mockedNavigate).toHaveBeenCalledTimes(1) @@ -87,9 +83,7 @@ describe('ExpiredConsentModal component', () => { </Provider> ) await act(async () => { - await userEvent.click( - screen.getByRole('button', { name: 'consent_outdated.later' }) - ) + await userEvent.click(screen.getByText('consent_outdated.no')) }) expect(mockHandleCloseClick).toHaveBeenCalled() }) diff --git a/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx b/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx index e0290c4a7fe8b19f3376b524466eb8822dab23c6..8cb9c8bb0363de72c8d0abfff8243b9301abce37 100644 --- a/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx +++ b/src/components/Connection/SGEConnect/SgeConnectView.spec.tsx @@ -45,12 +45,12 @@ describe('SgeConnectView component', () => { screen.getByText('auth.enedissgegrandlyon.identityTitle') ).toBeInTheDocument() - const prevButton = screen.getByRole('button', { - name: 'profile_type.accessibility.button_previous', - }) - const nextButton = screen.getByRole('button', { - name: 'profile_type.accessibility.button_next', - }) + const prevButton = screen.getByLabelText( + 'profile_type.accessibility.button_previous' + ) + const nextButton = screen.getByLabelText( + 'profile_type.accessibility.button_next' + ) expect(prevButton).toBeDisabled() expect(nextButton).toBeDisabled() }) diff --git a/src/components/Connection/SGEConnect/SgeInit.spec.tsx b/src/components/Connection/SGEConnect/SgeInit.spec.tsx index ce86c8ed7187de1611899e17e18822ea377f9f84..5bb551e8e671f95b1527a92b4623c5f29cafdd0e 100644 --- a/src/components/Connection/SGEConnect/SgeInit.spec.tsx +++ b/src/components/Connection/SGEConnect/SgeInit.spec.tsx @@ -28,7 +28,7 @@ describe('SgeInit component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click(screen.getByText('auth.enedissgegrandlyon.connect')) }) expect(mockedNavigate).toHaveBeenCalled() }) diff --git a/src/components/Connection/SGEConnect/StepConsent.spec.tsx b/src/components/Connection/SGEConnect/StepConsent.spec.tsx index ebca791acb68896b788aee05439f6c553790e861..642ebccb39727a42e96b8fc4a45b59f19bb2d2d4 100644 --- a/src/components/Connection/SGEConnect/StepConsent.spec.tsx +++ b/src/components/Connection/SGEConnect/StepConsent.spec.tsx @@ -24,15 +24,15 @@ describe('StepConsent component', () => { onChange={mockHandleChange} /> ) - const consentCheckbox = screen.getByRole('checkbox', { - name: 'auth.enedissgegrandlyon.consentCheck1', - }) + const consentCheckbox = screen.getByLabelText( + 'auth.enedissgegrandlyon.consentCheck1' + ) await userEvent.click(consentCheckbox) expect(mockHandleChange).toHaveBeenCalledWith('dataConsent', true) - const pdlCheckbox = screen.getByRole('checkbox', { - name: 'auth.enedissgegrandlyon.consentCheck2', - }) + const pdlCheckbox = screen.getByLabelText( + 'auth.enedissgegrandlyon.consentCheck2' + ) await userEvent.click(pdlCheckbox) expect(mockHandleChange).toHaveBeenCalledWith('pdlConfirm', true) }) diff --git a/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx b/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx index 833facf6236beabdd56ce1519e39d1b42a748d74..42846fe60b69c7bbe8b135ec64e32e4bf1b00e53 100644 --- a/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx +++ b/src/components/Connection/SGEConnect/StepIdentityAndPdl.spec.tsx @@ -56,11 +56,10 @@ describe('StepIdentityAndPdl component', () => { onChange={mockHandleChange} /> ) - const pdlModalButton = screen.getByRole('button', { - name: 'auth.enedissgegrandlyon.pdlModal.title', - }) await act(async () => { - await userEvent.click(pdlModalButton) + 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 6994c6de28036a47ae215b162bece51aedba4ae7..a270965bd3f07f817384b2ee62920df46f23bd5b 100644 --- a/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadNoValue.spec.tsx @@ -122,7 +122,9 @@ describe('DataloadNoValue component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click( + screen.getByText('consumption_visualizer.missing_data') + ) }) expect(mockDispatch).toHaveBeenCalledWith({ type: 'chart/setShowConnectionDetails', diff --git a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx index d86e8db5d2c95ba24408df2ff5950d04f2cac1c8..3661724c30e2e89bb0dd5b32c13c437fae2dfab4 100644 --- a/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx +++ b/src/components/ConsumptionVisualizer/DataloadSectionValue.spec.tsx @@ -89,7 +89,9 @@ describe('DataloadSectionValue component', () => { /> ) await act(async () => { - await userEvent.click(screen.getByRole('button')) + 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 d4aa9992cfdf208adfe638cac8ac532142b25222..4c6660d40956aaa653649e0b93d0064038c68592 100644 --- a/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx +++ b/src/components/ConsumptionVisualizer/InfoDataConsumptionVisualizer.spec.tsx @@ -189,7 +189,7 @@ describe('InfoDataConsumptionVisualizer component', () => { }) it('should click on last valid data date and move to it', async () => { - const mockDataLoad = { ...baseDataLoad, state: DataloadState.EMPTY } + const mockDataLoad = { ...baseDataLoad, state: DataloadState.UPCOMING } render( <Provider store={store}> <InfoDataConsumptionVisualizer @@ -200,9 +200,11 @@ describe('InfoDataConsumptionVisualizer component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click( + screen.getByText('consumption_visualizer.last_available_data') + ) }) - expect(screen.getByRole('dialog')).toBeInTheDocument() + expect(mockAppDispatch).toHaveBeenCalled() }) it('should click to display NoDataModal', async () => { @@ -217,8 +219,10 @@ describe('InfoDataConsumptionVisualizer component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click( + screen.getByText('consumption_visualizer.why_no_data') + ) }) - expect(mockAppDispatch).toHaveBeenCalled() + expect(screen.getByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/DateNavigator/DateNavigator.spec.tsx b/src/components/DateNavigator/DateNavigator.spec.tsx index 2ad781149818e2afb06e6a05a387736069f90143..9d19aca3820b73cde756941e61b9b8c4535196ce 100644 --- a/src/components/DateNavigator/DateNavigator.spec.tsx +++ b/src/components/DateNavigator/DateNavigator.spec.tsx @@ -44,13 +44,16 @@ describe('DateNavigator component', () => { timeStep={TimeStep.MONTH} /> ) - const [prevIcon, nextIcon] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(prevIcon) + await userEvent.click( + screen.getByLabelText('consumption.accessibility.button_previous_value') + ) }) expect(mockHandlePrevDate).toHaveBeenCalledTimes(1) await act(async () => { - await userEvent.click(nextIcon) + await userEvent.click( + screen.getByLabelText('consumption.accessibility.button_next_value') + ) }) expect(mockHandleNextDate).toHaveBeenCalledTimes(1) }) @@ -66,8 +69,13 @@ describe('DateNavigator component', () => { timeStep={TimeStep.MONTH} /> ) - const [prevIcon, nextButton] = screen.getAllByRole('button') - expect(prevIcon).toBeDisabled() - expect(nextButton).toBeDisabled() + const prev = screen.queryByLabelText( + 'consumption.accessibility.button_previous_value' + ) + const next = screen.queryByLabelText( + 'consumption.accessibility.button_next_value' + ) + expect(prev).toBeDisabled() + expect(next).toBeDisabled() }) }) diff --git a/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx b/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx index 1c4a13ebee50d6e91291503b856d451e4fe83912..8c7af8fa436ff6f007d0c6531447e7591056a068 100644 --- a/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx +++ b/src/components/Ecogesture/EcogestureEmptyList/EcogestureEmptyList.spec.tsx @@ -32,7 +32,7 @@ describe('EcogestureEmptyList component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click(screen.getByLabelText('ecogesture.emptyList.btn1')) }) expect(mockChangeTab).toHaveBeenCalledTimes(1) }) @@ -46,7 +46,7 @@ describe('EcogestureEmptyList component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click(screen.getByLabelText('ecogesture.emptyList.btn2')) }) expect(mockedNavigate).toHaveBeenCalledWith('/ecogesture-form') }) diff --git a/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx b/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx index a2abc6d04310407832ce386f17237b90c7169bcd..f42e399cf57084624bb061cff2dc17dae592fb1e 100644 --- a/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx +++ b/src/components/Ecogesture/EcogestureInitModal/EcogestureInitModal.spec.tsx @@ -25,7 +25,7 @@ describe('EcogestureInitModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[2]) + await userEvent.click(screen.getByText('ecogesture.initModal.btn1')) }) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) @@ -38,7 +38,7 @@ describe('EcogestureInitModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click(screen.getByText('ecogesture.initModal.btn2')) }) expect(mockHandleLaunchForm).toHaveBeenCalledTimes(1) }) diff --git a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx index 6ffa5471989aed0d41a2a142cd0bb893aae0cff6..bff4393a53fdfed61b124c92955352205e7fd2a0 100644 --- a/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx +++ b/src/components/Ecogesture/EcogestureList/EcogestureList.spec.tsx @@ -61,7 +61,7 @@ describe('EcogesturesList component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click(screen.getByText('ecogesture.MENU_TITLE')) }) await act(async () => { await userEvent.click(screen.getAllByRole('menuitem')[1]) @@ -83,7 +83,7 @@ describe('EcogesturesList component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + 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 8edf29c77b74d32afaa735c7c804b78b166ba00e..2ca68993812bf704ba4c9caa6ca2024f649beb1b 100644 --- a/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx +++ b/src/components/Ecogesture/EcogestureNotFound/EcogestureNotFound.spec.tsx @@ -23,7 +23,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.getByRole('button')) + await userEvent.click(screen.getByText('error_page.back')) }) expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures') }) diff --git a/src/components/Ecogesture/EcogestureTabsView.spec.tsx b/src/components/Ecogesture/EcogestureTabsView.spec.tsx index 4dceb4a19d0335aa6281f0c100fbc673b2c847d5..92561d3dd52cca64fe62f0a3cb25b666ad025e39 100644 --- a/src/components/Ecogesture/EcogestureTabsView.spec.tsx +++ b/src/components/Ecogesture/EcogestureTabsView.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 EcogestureTabsView from 'components/Ecogesture/EcogestureTabsView' import { Ecogesture } from 'models' @@ -77,8 +77,10 @@ describe('EcogestureView component', () => { ) expect(screen.getByRole('dialog')).toBeInTheDocument() - await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await waitFor(async () => { + await userEvent.click( + screen.getByLabelText('feedback.accessibility.button_close') + ) }) expect(updateProfileSpy).toHaveBeenCalledWith({ haveSeenEcogestureModal: true, diff --git a/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx b/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx index 23585af984f327d0f5992dd5f05312c9337adb95..ae223e032303b4dcde387af005696795ed5240cd 100644 --- a/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormSingleChoice/EcogestureFormSingleChoice.spec.tsx @@ -49,9 +49,10 @@ describe('EcogestureFormSingleChoice component', () => { </Provider> ) await userEvent.click(screen.getAllByRole('radio')[0]) - const [, next] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(next) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_next') + ) }) expect(mockHandleNextStep).toHaveBeenCalledTimes(1) }) @@ -68,9 +69,10 @@ describe('EcogestureFormSingleChoice component', () => { /> </Provider> ) - const [prev] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(prev) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_previous') + ) }) expect(mockHandlePreviousStep).toHaveBeenCalledTimes(1) }) diff --git a/src/components/EcogestureForm/EcogestureFormView.spec.tsx b/src/components/EcogestureForm/EcogestureFormView.spec.tsx index 32c980399a654fbc21f0f43c2c3940fe01219cdc..d3aac9ddd9e08290b52c0a27f5dc03d1ec67bb5f 100644 --- a/src/components/EcogestureForm/EcogestureFormView.spec.tsx +++ b/src/components/EcogestureForm/EcogestureFormView.spec.tsx @@ -71,29 +71,14 @@ describe('EcogestureFormView component', () => { ) await act(async () => { await userEvent.click(screen.getAllByRole('radio')[0]) - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_next') + ) }) expect( container.getElementsByClassName('ecogesture-form-single').length ).toBeTruthy() }) - it('should go to previous step', async () => { - const { container } = render( - <Provider store={store}> - <EcogestureFormView /> - </Provider> - ) - - const [, next] = screen.getAllByRole('button') - await act(async () => { - await userEvent.click(screen.getAllByRole('radio')[0]) - await userEvent.click(next) - }) - - expect( - container.getElementsByClassName('ecogesture-form-single').length - ).toBeTruthy() - }) it('should handle form end', async () => { mockAppDispatch.mockReturnValue(jest.fn()) @@ -115,7 +100,8 @@ describe('EcogestureFormView component', () => { <EcogestureFormView /> </Provider> ) - const [prev] = screen.getAllByRole('button') - expect(prev).toBeDisabled() + expect( + screen.getByLabelText('profile_type.accessibility.button_previous') + ).toBeDisabled() }) }) diff --git a/src/components/EcogestureForm/EcogestureLaunchFormModal/EcogestureLaunchFormModal.spec.tsx b/src/components/EcogestureForm/EcogestureLaunchFormModal/EcogestureLaunchFormModal.spec.tsx index 91b74191f49685b5e60965438098ba52b86214b2..23c3651722ed024a9587a7de8950a35c3174c697 100644 --- a/src/components/EcogestureForm/EcogestureLaunchFormModal/EcogestureLaunchFormModal.spec.tsx +++ b/src/components/EcogestureForm/EcogestureLaunchFormModal/EcogestureLaunchFormModal.spec.tsx @@ -22,7 +22,7 @@ describe('EcogestureLaunchFormModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click(screen.getByText('ecogesture.initModal.btn2')) }) expect(mockHandleClose).toHaveBeenCalledTimes(1) }) diff --git a/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx b/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx index b46581bdbc35cd960868c03ae0d093f57e620480..5608a326dbb4161f40386bff9d8e374be2603b14 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionDetail/EcogestureSelectionDetail.spec.tsx @@ -33,32 +33,34 @@ describe('EcogestureSelectionDetail component', () => { }) it('should toggle more details', async () => { - const [showMore] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(showMore) + 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 () => { - const [, objective] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(objective) + await userEvent.click( + screen.getByText('ecogesture_selection.button_objective') + ) }) expect(mockValidate).toHaveBeenCalledWith(true, false) }) it('should call validate with doing to true', async () => { - const [, , doing] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(doing) + await userEvent.click( + screen.getByText('ecogesture_selection.button_doing') + ) }) expect(mockValidate).toHaveBeenCalledWith(false, true) }) it('should call validate with objective and doing to false', async () => { - const [, , , skip] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(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 fa12c6b0fc983509acaee214ad3da7a4daf390bf..b17eb56aa8c598a687b102eb3b88085a36071122 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionEnd/EcogestureSelectionEnd.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionEnd/EcogestureSelectionEnd.spec.tsx @@ -22,7 +22,7 @@ describe('EcogestureSelectionEnd component', () => { it('should close modal and update profile', async () => { render(<EcogestureSelectionEnd />) await act(async () => { - await userEvent.click(screen.getByRole('button')) + 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 816790dae934dbf4730e98dcd6ac8288937f7831..6b72660464b8a92259ffd9acfa628856cec44276 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionModal/EcogestureSelectionModal.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionModal/EcogestureSelectionModal.spec.tsx @@ -23,7 +23,9 @@ describe('EcogestureInitModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 6512e87b69ca56cb4bd2766dc4734ccc9f813eec..e8f57688cdabd241c507f523ee6b74cb2ad9c6e4 100644 --- a/src/components/EcogestureSelection/EcogestureSelectionRestart/EcogestureSelectionRestart.spec.tsx +++ b/src/components/EcogestureSelection/EcogestureSelectionRestart/EcogestureSelectionRestart.spec.tsx @@ -21,7 +21,9 @@ 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.getAllByRole('button')[0]) + await userEvent.click( + screen.getByText('ecogesture_selection.button_go_to_ecogesture') + ) }) expect(mockedNavigate).toHaveBeenCalledWith('/ecogestures?tab=0') }) @@ -29,7 +31,9 @@ describe('EcogestureSelectionRestart component', () => { 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.getAllByRole('button')[1]) + 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 903d268524541f31782be197158de9410f6745f8..8dc48fdbcde9eb7af951be0d7a5414cc81e3b824 100644 --- a/src/components/Exploration/ExplorationFinished.spec.tsx +++ b/src/components/Exploration/ExplorationFinished.spec.tsx @@ -27,7 +27,7 @@ describe('ExplorationFinished', () => { screen.getByText(userChallengeData[0].exploration.message_success) ).toBeInTheDocument() await act(async () => { - await userEvent.click(screen.getByRole('button')) + 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 d1ab681bc0c716709e79d611af1e92478585ebaf..d4b8e53a77fbdfcd0a68e8f904621914dbaef3c8 100644 --- a/src/components/Feedback/FeedbackModal.spec.tsx +++ b/src/components/Feedback/FeedbackModal.spec.tsx @@ -39,7 +39,7 @@ describe('FeedbackModal component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[2]) + 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 1492e2a2cc24a3d5b45611d598ab8e3ebf2997b5..91673e4f66235d9212d9dced10cabb021fbb674f 100644 --- a/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx +++ b/src/components/FluidChart/TimeStepSelector/TimeStepSelector.spec.tsx @@ -88,7 +88,7 @@ describe('TimeStepSelector component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click(screen.getByText('timestep.today')) }) expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1) expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK) diff --git a/src/components/Header/CozyBar.spec.tsx b/src/components/Header/CozyBar.spec.tsx index 4686fce253c292042027cf974c975d192817acb4..960d681051bc836eac1b1681b6c5615d73a58b05 100644 --- a/src/components/Header/CozyBar.spec.tsx +++ b/src/components/Header/CozyBar.spec.tsx @@ -45,7 +45,9 @@ describe('CozyBar component', () => { ) expect(container).toMatchSnapshot() await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) }) expect(mockedNavigate).toHaveBeenCalled() }) @@ -59,7 +61,9 @@ describe('CozyBar component', () => { ) expect(container).toMatchSnapshot() await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) }) expect(mockBackFunction).toHaveBeenCalled() }) @@ -73,7 +77,9 @@ describe('CozyBar component', () => { ) const updateModalSpy = jest.spyOn(ModalAction, 'openFeedbackModal') await act(async () => { - await userEvent.click(screen.getByRole('button')) + 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 60d6586be036eaa60c1824483de524ffb4568083..0e527784ddfeb7dc0be86ec364b97319f86e6830 100644 --- a/src/components/Header/Header.spec.tsx +++ b/src/components/Header/Header.spec.tsx @@ -33,7 +33,7 @@ describe('Header component', () => { ) expect(screen.getByText(key)).toBeInTheDocument() expect( - screen.getByRole('button', { name: 'header.accessibility.button_back' }) + screen.getByLabelText('header.accessibility.button_back') ).toBeInTheDocument() }) it('should NOT display back button when displayBackArrow is false', async () => { @@ -57,7 +57,9 @@ describe('Header component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) }) expect(mockedNavigate).toHaveBeenCalled() }) @@ -73,7 +75,9 @@ describe('Header component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click( + screen.getByLabelText('header.accessibility.button_back') + ) }) expect(mockBack).toHaveBeenCalled() }) @@ -87,7 +91,9 @@ describe('Header component', () => { ) const updateModalSpy = jest.spyOn(ModalAction, 'openFeedbackModal') await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 14ae6c3e8857d1357ba005074ac29d7632f5a8f6..72388b748c22057ec7520884c6de66ef07bdd6ba 100644 --- a/src/components/Konnector/ConnectionNotFound/ConnectionNotFound.spec.tsx +++ b/src/components/Konnector/ConnectionNotFound/ConnectionNotFound.spec.tsx @@ -17,7 +17,7 @@ describe('ConnectionNotFound component test', () => { global.open = jest.fn() render(<ConnectionNotFound konnectorSlug={konnectorSlug} />) await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click(screen.getByText('konnector_form.button_install')) }) expect(global.open).toHaveBeenCalledWith( 'http://localhost/#/discover/enedissgegrandlyon', diff --git a/src/components/Konnector/KonnectorModal.spec.tsx b/src/components/Konnector/KonnectorModal.spec.tsx index f453c7ea54190d40e4f90e0aa72d9a856256baa4..d3f7fbe830276eb3a1094476d6b55d6ce5d6a24e 100644 --- a/src/components/Konnector/KonnectorModal.spec.tsx +++ b/src/components/Konnector/KonnectorModal.spec.tsx @@ -68,7 +68,7 @@ describe('KonnectorModal component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click(screen.getByText('konnector_modal.button_validate')) }) expect(mockHandleCloseClick).toHaveBeenCalled() }) diff --git a/src/components/Konnector/KonnectorModal.tsx b/src/components/Konnector/KonnectorModal.tsx index 5a16d77dacd514d8f523ed62f8f31082e32d05b4..2cf2ede9993268e238fb3f6e47cc010694af9fbf 100644 --- a/src/components/Konnector/KonnectorModal.tsx +++ b/src/components/Konnector/KonnectorModal.tsx @@ -67,7 +67,7 @@ const KonnectorModal = ({ <div className="kmodal-waiting-text text-18-italic"> {shuffledWaitingTexts.map((text, idx) => ( <div - key={text.second} + key={idx} className={classNames('waiting-text', { ['show']: idx === index % shuffledWaitingTexts.length, })} @@ -88,7 +88,7 @@ const KonnectorModal = ({ ) : ( firstConnectionWaitingTexts.map((text, idx) => ( <div - key={text.second} + key={idx} className={classNames('waiting-text', { ['show']: idx === index % firstConnectionWaitingTexts.length, })} diff --git a/src/components/Konnector/KonnectorModalFooter.spec.tsx b/src/components/Konnector/KonnectorModalFooter.spec.tsx index 4b926d09676c019e16631adfbbb2e8c531a7f2b0..42e3e61b7f0d93c4aaa63ae640775e09ce726a86 100644 --- a/src/components/Konnector/KonnectorModalFooter.spec.tsx +++ b/src/components/Konnector/KonnectorModalFooter.spec.tsx @@ -92,24 +92,6 @@ describe('KonnectorModalFooter component', () => { ).toBeInTheDocument() }) - it('should close the modal', async () => { - render( - <Provider store={store}> - <KonnectorModalFooter - state={ERROR_EVENT} - error={KonnectorError.LOGIN_FAILED} - handleCloseClick={mockClose} - handleAccountDeletion={mockDelete} - account={null} - isUpdating={false} - /> - </Provider> - ) - await act(async () => { - await userEvent.click(screen.getByRole('button')) - }) - expect(mockClose).toHaveBeenCalled() - }) it('should go back to login', async () => { render( <Provider store={store}> @@ -124,7 +106,7 @@ describe('KonnectorModalFooter component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click(screen.getByText('konnector_modal.button_go')) }) expect(mockDelete).toHaveBeenCalled() expect(mockedNavigate).toHaveBeenCalledTimes(1) @@ -143,7 +125,7 @@ describe('KonnectorModalFooter component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click(screen.getByText('konnector_modal.button_go')) }) expect(mockDelete).toHaveBeenCalled() expect(mockedNavigate).toHaveBeenCalledTimes(1) @@ -162,7 +144,9 @@ describe('KonnectorModalFooter component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + 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 19b4ed1c4f1a44560dd9f3d7721cba0af944f963..d1b3e7928c956e147b4925c503bd2f3710306cce 100644 --- a/src/components/Konnector/KonnectorViewerList.spec.tsx +++ b/src/components/Konnector/KonnectorViewerList.spec.tsx @@ -29,7 +29,9 @@ describe('KonnectorViewerList component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 c1641e0cff8e7b7257607c0bf28d426172defc21..56cd7cac4a4229f25e985ebecba5e9045cb9cbb4 100644 --- a/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportDoneModal.spec.tsx @@ -28,7 +28,7 @@ describe('exportDoneModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 3adc903b9f6b676ace0e2abb5588592cd5080bdb..8fe1bce5b001c91dc854b98722a482ba50a95be7 100644 --- a/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportLoadingModal.spec.tsx @@ -28,7 +28,9 @@ describe('ExportLoadingModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 05e7e8aa883f9561b098f9010d0aa960f3862bb1..a903a4151cdf312142c580be8e965d776c50966d 100644 --- a/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx +++ b/src/components/Options/ExportData/Modals/exportStartModal.spec.tsx @@ -25,7 +25,9 @@ describe('exportStartModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 a7b953d8941ae0ea616893516c5b44aa7135bc89..1ecad5c9a8a396d1ab3087f8c050d4b78cb3a2ac 100644 --- a/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx +++ b/src/components/Options/ProfileTypeOptions/ProfileTypeOptions.spec.tsx @@ -32,7 +32,7 @@ describe('ProfileTypeOptions component', () => { ) expect(container.getElementsByClassName('profile-icon').length).toBeTruthy() await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click(screen.getByText('profile_type.read_profile')) }) expect(mockedNavigate).toHaveBeenCalled() }) diff --git a/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx b/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx index 6586523d7cfee6f99417417ab73e69e0331dd298..9a9ac90550c1ace8b3d4adc06a97e27198e8eb61 100644 --- a/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx +++ b/src/components/Options/Unsubscribe/Unsubscribe.spec.tsx @@ -20,9 +20,8 @@ describe('Unsubscribe component', () => { it('should click the subscribe button', async () => { const { container } = render(<Unsubscribe />) await waitFor(() => null, { container }) - const [subscribeBtn] = screen.getAllByRole('button') await act(async () => { - await userEvent.click(subscribeBtn) + await userEvent.click(screen.getByText('unsubscribe.button_subscribe')) }) expect(mockUpdateProfile).toHaveBeenCalled() diff --git a/src/components/PartnerIssue/PartnerIssueModal.spec.tsx b/src/components/PartnerIssue/PartnerIssueModal.spec.tsx index 5a39674762a0a580ce5d3c2a1c45763344de19cc..41789bf10ed7bf69f7abe1b9afc611921fb1f6a7 100644 --- a/src/components/PartnerIssue/PartnerIssueModal.spec.tsx +++ b/src/components/PartnerIssue/PartnerIssueModal.spec.tsx @@ -50,7 +50,9 @@ describe('PartnerIssueModal component', () => { /> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + 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 03c6f736ff395a62d58ca0f0b22fe011ab9367de..129114f86fac29eaba1d227ef002015e062b966e 100644 --- a/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx +++ b/src/components/ProfileType/ProfileTypeFinished/ProfileTypeFinished.spec.tsx @@ -46,7 +46,9 @@ describe('ProfileTypeFinished component', () => { </Provider> ) await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click( + screen.getByLabelText('profile_type.accessibility.button_validate') + ) }) expect(mockedNavigate).toHaveBeenCalledWith('/ecogesture-selection') }) diff --git a/src/components/ProfileType/ProfileTypeView.spec.tsx b/src/components/ProfileType/ProfileTypeView.spec.tsx index 77e2baebe8ea29e3184babe0745fed2a83d520ec..8b836fb4d73b0243f9c2b20f044efaca51ed26da 100644 --- a/src/components/ProfileType/ProfileTypeView.spec.tsx +++ b/src/components/ProfileType/ProfileTypeView.spec.tsx @@ -35,7 +35,8 @@ describe('ProfileTypeView component', () => { <ProfileTypeView /> </Provider> ) - const [prev] = screen.getAllByRole('button') - expect(prev).toBeDisabled() + expect( + screen.getByLabelText('profile_type.accessibility.button_previous') + ).toBeDisabled() }) }) diff --git a/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx b/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx index 8b3ffacff4e0885a9e84d88f4700e89c1116f096..ccaf243e83620d21cffe47d48d5bc75187afdb2a 100644 --- a/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx +++ b/src/components/Quiz/QuizBegin/QuizBegin.spec.tsx @@ -24,7 +24,7 @@ describe('QuizBegin component', () => { ) expect(container.getElementsByClassName('quiz-icon')[0]).toBeInTheDocument() await act(async () => { - await userEvent.click(screen.getByRole('button')) + await userEvent.click(screen.getByText('duel.button_start')) }) expect(mockUserChallengeUpdateFlag).toHaveBeenCalledWith( userChallengeData[0], diff --git a/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx b/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx index 75761dee69cfe5c01204824c20b2eee0cbd600fd..9bac2567e4a78b44b8dcf3cf0ee6234b2e75df6e 100644 --- a/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx +++ b/src/components/Quiz/QuizFinish/QuizFinish.spec.tsx @@ -29,7 +29,7 @@ describe('QuizFinish', () => { ) expect(container.getElementsByClassName('quiz-icon')[0]).toBeInTheDocument() await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click(screen.getByText('quiz.button_go_back')) }) expect(mockUserChallengeUpdateFlag).toHaveBeenCalled() expect(mockedNavigate).toHaveBeenCalledWith('/challenges') diff --git a/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx b/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx index 818bded68e14a7f471837513b91daef3aebc2703..5a3c5f3dc6117b1546bd6c73ad10765b158f530e 100644 --- a/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx +++ b/src/components/Quiz/QuizQuestion/QuizQuestionContentCustom.spec.tsx @@ -77,7 +77,7 @@ describe('QuizCustomQuestionContent component', () => { ) await act(async () => { await userEvent.click(screen.getAllByRole('radio')[0]) - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click(screen.getByText('quiz.button_validate')) }) expect(mockUpdateUserQuiz).toHaveBeenCalledWith( userChallengeData[0].quiz, diff --git a/src/components/Terms/TermsView.spec.tsx b/src/components/Terms/TermsView.spec.tsx index 8d4ae3d90c4ce4b2ec99932ab76e316c2cdfa551..98d0aae76563e2cabe38caf2240088104e408396 100644 --- a/src/components/Terms/TermsView.spec.tsx +++ b/src/components/Terms/TermsView.spec.tsx @@ -49,7 +49,9 @@ describe('TermsView component', () => { ) await waitFor(() => null, { container }) - const acceptButton = screen.getAllByRole('button')[2] + const acceptButton = screen.getByLabelText( + 'dataShare.accessibility.button_accept' + ) expect(acceptButton).toBeDisabled() expect(mockUpdateProfile).toHaveBeenCalledTimes(0) diff --git a/src/components/WelcomeModal/WelcomeModal.spec.tsx b/src/components/WelcomeModal/WelcomeModal.spec.tsx index 0d7dade73dcdd8dd2dc0293f17c02c0b9acd2901..0db03efefffaf7fdb00de4e109c994f91f473d99 100644 --- a/src/components/WelcomeModal/WelcomeModal.spec.tsx +++ b/src/components/WelcomeModal/WelcomeModal.spec.tsx @@ -71,7 +71,9 @@ describe('WelcomeModal component', () => { }) it('should send mail and update profile when user click on the ok button', async () => { await act(async () => { - await userEvent.click(screen.getAllByRole('button')[1]) + await userEvent.click( + screen.getByText('onboarding.welcomeModal.button_valid') + ) }) expect(mockSendMail).toHaveBeenCalled() expect(updateProfileSpy).toHaveBeenCalledWith({ @@ -84,7 +86,11 @@ describe('WelcomeModal component', () => { it('should send mail and update profile when modal is closed by user', async () => { await act(async () => { - await userEvent.click(screen.getAllByRole('button')[0]) + await userEvent.click( + screen.getAllByLabelText( + 'onboarding.welcomeModal.accessibility.button_valid' + )[0] + ) }) expect(mockSendMail).toHaveBeenCalled() expect(updateProfileSpy).toHaveBeenCalledWith({