From 83ef0ce2be6db7ed6f7c2a2f379ea5dea58baa55 Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Fri, 19 Apr 2024 13:53:10 +0000
Subject: [PATCH] test: replace getByRole methods

---
 .../MaxConsumptionCard.spec.tsx               |  9 ++++---
 .../ChallengeCardDone.spec.tsx                | 18 +++++--------
 .../ChallengeCardUnlocked.spec.tsx            |  6 +++--
 .../FormNavigation/FormNavigation.spec.tsx    |  7 ++---
 .../ExpiredConsentModal.spec.tsx              | 12 +++------
 .../SGEConnect/SgeConnectView.spec.tsx        | 12 ++++-----
 .../Connection/SGEConnect/SgeInit.spec.tsx    |  2 +-
 .../SGEConnect/StepConsent.spec.tsx           | 12 ++++-----
 .../SGEConnect/StepIdentityAndPdl.spec.tsx    |  7 +++--
 .../DataloadNoValue.spec.tsx                  |  4 ++-
 .../DataloadSectionValue.spec.tsx             |  4 ++-
 .../InfoDataConsumptionVisualizer.spec.tsx    | 14 ++++++----
 .../DateNavigator/DateNavigator.spec.tsx      | 20 +++++++++-----
 .../EcogestureEmptyList.spec.tsx              |  4 +--
 .../EcogestureInitModal.spec.tsx              |  4 +--
 .../EcogestureList/EcogestureList.spec.tsx    |  4 +--
 .../EcogestureNotFound.spec.tsx               |  2 +-
 .../Ecogesture/EcogestureTabsView.spec.tsx    |  8 +++---
 .../EcogestureFormSingleChoice.spec.tsx       | 10 ++++---
 .../EcogestureFormView.spec.tsx               | 26 +++++--------------
 .../EcogestureLaunchFormModal.spec.tsx        |  2 +-
 .../EcogestureSelectionDetail.spec.tsx        | 18 +++++++------
 .../EcogestureSelectionEnd.spec.tsx           |  2 +-
 .../EcogestureSelectionModal.spec.tsx         |  4 ++-
 .../EcogestureSelectionRestart.spec.tsx       |  8 ++++--
 .../Exploration/ExplorationFinished.spec.tsx  |  2 +-
 .../Feedback/FeedbackModal.spec.tsx           |  2 +-
 .../TimeStepSelector.spec.tsx                 |  2 +-
 src/components/Header/CozyBar.spec.tsx        | 12 ++++++---
 src/components/Header/Header.spec.tsx         | 14 +++++++---
 .../ConnectionNotFound.spec.tsx               |  2 +-
 .../Konnector/KonnectorModal.spec.tsx         |  2 +-
 src/components/Konnector/KonnectorModal.tsx   |  4 +--
 .../Konnector/KonnectorModalFooter.spec.tsx   | 26 ++++---------------
 .../Konnector/KonnectorViewerList.spec.tsx    |  4 ++-
 .../Modals/exportDoneModal.spec.tsx           |  2 +-
 .../Modals/exportLoadingModal.spec.tsx        |  4 ++-
 .../Modals/exportStartModal.spec.tsx          |  4 ++-
 .../ProfileTypeOptions.spec.tsx               |  2 +-
 .../Options/Unsubscribe/Unsubscribe.spec.tsx  |  3 +--
 .../PartnerIssue/PartnerIssueModal.spec.tsx   |  4 ++-
 .../ProfileTypeFinished.spec.tsx              |  4 ++-
 .../ProfileType/ProfileTypeView.spec.tsx      |  5 ++--
 .../Quiz/QuizBegin/QuizBegin.spec.tsx         |  2 +-
 .../Quiz/QuizFinish/QuizFinish.spec.tsx       |  2 +-
 .../QuizQuestionContentCustom.spec.tsx        |  2 +-
 src/components/Terms/TermsView.spec.tsx       |  4 ++-
 .../WelcomeModal/WelcomeModal.spec.tsx        | 10 +++++--
 48 files changed, 179 insertions(+), 158 deletions(-)

diff --git a/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx b/src/components/Analysis/MaxConsumptionCard/MaxConsumptionCard.spec.tsx
index 098ee3140..1c8b8f341 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 1b2f9d2ea..d62b47d36 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 9dae95a5e..89209571b 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 0584ba26a..0d8be396b 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 58c1ab6dc..a5edf1912 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 e0290c4a7..8cb9c8bb0 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 ce86c8ed7..5bb551e8e 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 ebca791ac..642ebccb3 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 833facf62..42846fe60 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 6994c6de2..a270965bd 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 d86e8db5d..3661724c3 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 d4aa9992c..4c6660d40 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 2ad781149..9d19aca38 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 1c4a13ebe..8c7af8fa4 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 a2abc6d04..f42e399cf 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 6ffa54719..bff4393a5 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 8edf29c77..2ca689938 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 4dceb4a19..92561d3dd 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 23585af98..ae223e032 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 32c980399..d3aac9ddd 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 91b74191f..23c365172 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 b46581bdb..5608a326d 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 fa12c6b0f..b17eb56aa 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 816790dae..6b7266046 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 6512e87b6..e8f57688c 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 903d26852..8dc48fdbc 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 d1ab681bc..d4b8e53a7 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 1492e2a2c..91673e4f6 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 4686fce25..960d68105 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 60d6586be..0e527784d 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 14ae6c3e8..72388b748 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 f453c7ea5..d3f7fbe83 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 5a16d77da..2cf2ede99 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 4b926d096..42e3e61b7 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 19b4ed1c4..d1b3e7928 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 c1641e0cf..56cd7cac4 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 3adc903b9..8fe1bce5b 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 05e7e8aa8..a903a4151 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 a7b953d89..1ecad5c9a 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 6586523d7..9a9ac9055 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 5a3967476..41789bf10 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 03c6f736f..129114f86 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 77e2baebe..8b836fb4d 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 8b3ffacff..ccaf243e8 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 75761dee6..9bac2567e 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 818bded68..5a3c5f3dc 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 8d4ae3d90..98d0aae76 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 0d7dade73..0db03efef 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({
-- 
GitLab