]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20814 Adding specific arialabel for branch rows
authorRevanshu Paliwal <revanshu.paliwal@sonarsource.com>
Tue, 24 Oct 2023 08:37:32 +0000 (10:37 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 25 Oct 2023 20:02:59 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/projectNewCode/components/BranchListRow.tsx
server/sonar-web/src/main/js/apps/projectNewCode/components/__tests__/ProjectNewCodeDefinitionApp-it.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 54083c5a365c27be03c996e2df1e556201be7c68..f11c9f61c043af192e58f6cf2c03e439e7c86c85 100644 (file)
@@ -130,14 +130,18 @@ export default function BranchListRow(props: BranchListRowProps) {
         {!branch.newCodePeriod && (
           <InteractiveIcon
             Icon={PencilIcon}
-            aria-label={translate('edit')}
+            aria-label={translateWithParameters('branch_list.edit_for_x', branch.name)}
             onClick={() => props.onOpenEditModal(branch)}
             className="sw-mr-2"
             size="small"
           />
         )}
         {branch.newCodePeriod && (
-          <ActionsDropdown allowResizing id="new-code-action">
+          <ActionsDropdown
+            allowResizing
+            id="new-code-action"
+            ariaLabel={translateWithParameters('branch_list.show_actions_for_x', branch.name)}
+          >
             <Tooltip
               overlay={
                 isCompliant ? null : translate('project_baseline.compliance.warning.title.project')
index 1a633c223e24290da4ce93903e04d32552e46319..2141a6d96532f858fe36f93ff155af8ddc6119d9 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { act, within } from '@testing-library/react';
+import { act } from '@testing-library/react';
 import userEvent from '@testing-library/user-event';
 import { first, last } from 'lodash';
 import selectEvent from 'react-select-event';
@@ -183,7 +183,7 @@ it('renders correctly branch modal', async () => {
   });
   await ui.appIsLoaded();
 
-  await ui.openBranchSettingModal('main branches.main_branch branch_list.default_setting');
+  await ui.openBranchSettingModal('main');
 
   expect(ui.specificAnalysisRadio.query()).not.toBeInTheDocument();
 });
@@ -194,20 +194,21 @@ it('can set a previous version setting for branch', async () => {
     featureList: [Feature.BranchSupport],
   });
   await ui.appIsLoaded();
-  await ui.setBranchPreviousVersionSetting('main branches.main_branch branch_list.default_setting');
+  await ui.setBranchPreviousVersionSetting('main');
 
   expect(
-    within(byRole('table').get()).getByText('new_code_definition.previous_version'),
-  ).toBeInTheDocument();
+    byRole('table').byRole('cell', { name: 'branch_list.default_setting' }).getAll(),
+  ).toHaveLength(2);
+  expect(byRole('table').byText('new_code_definition.previous_version').get()).toBeInTheDocument();
 
-  await user.click(await ui.branchActionsButton().find());
+  await user.click(await ui.branchActionsButton('main').find());
 
   expect(ui.resetToDefaultButton.get()).toBeInTheDocument();
   await user.click(ui.resetToDefaultButton.get());
 
   expect(
-    first(within(byRole('table').get()).getAllByText('branch_list.default_setting')),
-  ).toBeInTheDocument();
+    byRole('table').byRole('cell', { name: 'branch_list.default_setting' }).getAll(),
+  ).toHaveLength(3);
 });
 
 it('can set a number of days setting for branch', async () => {
@@ -217,14 +218,9 @@ it('can set a number of days setting for branch', async () => {
   });
   await ui.appIsLoaded();
 
-  await ui.setBranchNumberOfDaysSetting(
-    'main branches.main_branch branch_list.default_setting',
-    '15',
-  );
+  await ui.setBranchNumberOfDaysSetting('main', '15');
 
-  expect(
-    within(byRole('table').get()).getByText('new_code_definition.number_days: 15'),
-  ).toBeInTheDocument();
+  expect(byRole('table').byText('new_code_definition.number_days: 15').get()).toBeInTheDocument();
 });
 
 it('cannot set a specific analysis setting for branch', async () => {
@@ -241,11 +237,7 @@ it('cannot set a specific analysis setting for branch', async () => {
   });
   await ui.appIsLoaded();
 
-  await user.click(
-    await byRole('row', { name: /main branches.main_branch/ })
-      .byLabelText('menu')
-      .find(),
-  );
+  await user.click(await byLabelText('branch_list.show_actions_for_x.main').find());
   await user.click(await byRole('menuitem', { name: 'edit' }).find());
   expect(ui.specificAnalysisRadio.get()).toBeChecked();
   expect(ui.specificAnalysisRadio.get()).toHaveClass('disabled');
@@ -261,10 +253,7 @@ it('can set a reference branch setting for branch', async () => {
   });
   await ui.appIsLoaded();
 
-  await ui.setBranchReferenceToBranchSetting(
-    'main branches.main_branch branch_list.default_setting',
-    'normal-branch',
-  );
+  await ui.setBranchReferenceToBranchSetting('main', 'normal-branch');
 
   expect(
     byRole('table').byText('baseline.reference_branch: normal-branch').get(),
@@ -407,8 +396,8 @@ function getPageObjects() {
     specificAnalysisWarning: byText('baseline.specific_analysis.compliance_warning.title'),
     saveButton: byRole('button', { name: 'save' }),
     cancelButton: byRole('button', { name: 'cancel' }),
-    branchActionsButton: () => byRole('button', { name: `menu` }),
-    editButton: byRole('button', { name: 'edit' }),
+    branchActionsButton: (name: string) =>
+      byRole('button', { name: `branch_list.show_actions_for_x.${name}` }),
     resetToDefaultButton: byRole('menuitem', { name: 'reset_to_default' }),
     branchNCDsBanner: byText(/new_code_definition.auto_update.branch.message/),
     dismissButton: byLabelText('dismiss'),
@@ -459,9 +448,7 @@ function getPageObjects() {
   }
 
   async function openBranchSettingModal(branch: string) {
-    await user.click(
-      await byRole('row', { name: branch, exact: false }).byLabelText('edit').find(),
-    );
+    await user.click(await byLabelText(`branch_list.edit_for_x.${branch}`).find());
   }
 
   return {
index f5e0132f773ec86d68604bbe902a1449f91b0711..9ee9818a20ae981828d99cb761cd80c464e7cc7e 100644 (file)
@@ -691,6 +691,7 @@ branch_list.current_setting=Setting
 branch_list.current_baseline=Current Baseline
 branch_list.actions=Actions
 branch_list.show_actions_for_x=Show actions for branch {0}
+branch_list.edit_for_x=Edit {0}
 branch_list.default_setting=Project setting
 
 baseline.new_code_period_for_branch_x=New Code for {0}