]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16948 Buttons have same name but different actions
authorMathieu Suen <mathieu.suen@sonarsource.com>
Fri, 7 Oct 2022 09:17:39 +0000 (11:17 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 7 Oct 2022 20:03:00 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx
server/sonar-web/src/main/js/components/SourceViewer/components/LineSCM.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index dfbffaf2828d525ed3ffc5c137faf040fe0ff3c8..60a824117f53224890b16dfbe40060375ad9e6a2 100644 (file)
@@ -186,7 +186,8 @@ it('should show SCM information', async () => {
   ).toBeInTheDocument();
   await user.click(
     firstRowScreen.getByRole('button', {
-      name: 'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info'
+      name:
+        'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info.1'
     })
   );
 
@@ -210,48 +211,49 @@ it('should show SCM information', async () => {
   // SCM with no date
   row = await screen.findByRole('row', { name: /\* mailto:info AT sonarsource DOT com$/ });
   expect(row).toBeInTheDocument();
-  const thirdRowScreen = within(row);
+  const fourthRowScreen = within(row);
   await user.click(
-    thirdRowScreen.getByRole('button', {
-      name: 'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info'
+    fourthRowScreen.getByRole('button', {
+      name:
+        'source_viewer.author_X.stas.vilchik@sonarsource.com, source_viewer.click_for_scm_info.4'
     })
   );
 
   expect(
-    await thirdRowScreen.findByRole('heading', { level: 4, name: 'author' })
+    await fourthRowScreen.findByRole('heading', { level: 4, name: 'author' })
   ).toBeInTheDocument();
   expect(
-    thirdRowScreen.queryByRole('heading', {
+    fourthRowScreen.queryByRole('heading', {
       level: 4,
       name: 'source_viewer.tooltip.scm.commited_on'
     })
   ).not.toBeInTheDocument();
   expect(
-    thirdRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
+    fourthRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
   ).toBeInTheDocument();
 
   // SCM with no date no author
   row = await screen.findByRole('row', { name: /\* 5$/ });
   expect(row).toBeInTheDocument();
-  const fourthRowScreen = within(row);
-  expect(fourthRowScreen.getByText('…')).toBeInTheDocument();
+  const fithRowScreen = within(row);
+  expect(fithRowScreen.getByText('…')).toBeInTheDocument();
   await user.click(
-    fourthRowScreen.getByRole('button', {
-      name: 'source_viewer.click_for_scm_info'
+    fithRowScreen.getByRole('button', {
+      name: 'source_viewer.click_for_scm_info.5'
     })
   );
 
   expect(
-    fourthRowScreen.queryByRole('heading', { level: 4, name: 'author' })
+    fithRowScreen.queryByRole('heading', { level: 4, name: 'author' })
   ).not.toBeInTheDocument();
   expect(
-    fourthRowScreen.queryByRole('heading', {
+    fithRowScreen.queryByRole('heading', {
       level: 4,
       name: 'source_viewer.tooltip.scm.commited_on'
     })
   ).not.toBeInTheDocument();
   expect(
-    fourthRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
+    fithRowScreen.getByRole('heading', { level: 4, name: 'source_viewer.tooltip.scm.revision' })
   ).toBeInTheDocument();
 
   // No SCM Popup
index c06c6e41c5edfa8f0f67db5f9a46988e99f8ffb4..d50554a67dd95338012d5483ab37fd2fa7f3e437 100644 (file)
@@ -20,7 +20,7 @@
 import * as React from 'react';
 import Dropdown from '../../../components/controls/Dropdown';
 import { PopupPlacement } from '../../../components/ui/popups';
-import { translate, translateWithParameters } from '../../../helpers/l10n';
+import { translateWithParameters } from '../../../helpers/l10n';
 import { SourceLine } from '../../../types/types';
 import { ButtonPlain } from '../../controls/buttons';
 import SCMPopup from './SCMPopup';
@@ -39,7 +39,7 @@ export function LineSCM({ line, previousLine }: LineSCMProps) {
   );
 
   if (hasPopup) {
-    let ariaLabel = translate('source_viewer.click_for_scm_info');
+    let ariaLabel = translateWithParameters('source_viewer.click_for_scm_info', line.line);
     if (line.scmAuthor) {
       ariaLabel = `${translateWithParameters(
         'source_viewer.author_X',
index cf9c7de65beb34c01b898bd16a2cf09f3216c7a1..735c071564ada7de350ffd59cbafce9239e624c1 100644 (file)
@@ -2868,7 +2868,7 @@ source_viewer.covered=Covered by the following tests
 source_viewer.not_covered=Not covered by tests
 source_viewer.conditions=conditions
 source_viewer.line_X=Line: {0}
-source_viewer.click_for_scm_info=Click to see SCM information
+source_viewer.click_for_scm_info=Click to see SCM information for line {0}
 source_viewer.author_X=Author: {0}
 source_viewer.click_to_copy_filepath=Click to copy the filepath to clipboard