]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20998 Improve performance of Code-it
authorJeremy Davis <jeremy.davis@sonarsource.com>
Thu, 9 Nov 2023 16:08:57 +0000 (17:08 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 10 Nov 2023 20:02:51 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts
server/sonar-web/src/main/js/apps/code/components/Component.tsx

index b432a72abf0a4d5ad23f6c7bd64e0d396f943716..f0f92a72982957dee43c64c41e851b5a8bfe5d8c 100644 (file)
@@ -28,7 +28,7 @@ import { isDiffMetric } from '../../../helpers/measures';
 import { mockComponent } from '../../../helpers/mocks/component';
 import { mockMeasure } from '../../../helpers/testMocks';
 import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils';
-import { ReactTestingQuery, byRole, byText } from '../../../helpers/testSelector';
+import { ReactTestingQuery, byLabelText, byRole, byText } from '../../../helpers/testSelector';
 import { ComponentQualifier } from '../../../types/component';
 import { MetricKey } from '../../../types/metrics';
 import { Component } from '../../../types/types';
@@ -44,6 +44,20 @@ jest.mock('../../../components/SourceViewer/helpers/lines', () => {
   };
 });
 
+jest.mock('../../../api/branches', () => ({
+  deleteBranch: jest.fn(),
+  deletePullRequest: jest.fn(),
+  excludeBranchFromPurge: jest.fn(),
+  getBranches: jest.fn(),
+  getPullRequests: jest.fn(),
+  renameBranch: jest.fn(),
+  setMainBranch: jest.fn(),
+}));
+
+jest.mock('../../../api/quality-gates', () => ({
+  getQualityGateProjectStatus: jest.fn(),
+}));
+
 const DEFAULT_LINES_LOADED = 19;
 const originalScrollTo = window.scrollTo;
 
@@ -385,7 +399,7 @@ function getPageObject(user: UserEvent) {
     showingOutOfTxt: (x: number, y: number) => byText(`x_of_y_shown.${x}.${y}`),
     newCodeBtn: byRole('radio', { name: 'projects.view.new_code' }),
     overallCodeBtn: byRole('radio', { name: 'projects.view.overall_code' }),
-    measureRow: (name: string | RegExp) => byRole('row', { name, exact: false }),
+    measureRow: (name: string | RegExp) => byLabelText(name),
     measureValueCell: (row: ReactTestingQuery, name: string, value: string) => {
       const i = Array.from(screen.getAllByRole('columnheader')).findIndex(
         (c) => c.textContent?.includes(name),
index 580a2a58ae4170a2e56d81d8494e03446782d31a..7a7366244aaf5889375e1cbb6c9d7ed32d041103 100644 (file)
@@ -62,7 +62,7 @@ export default function Component(props: Props) {
     component.qualifier === ComponentQualifier.TestFile;
 
   return (
-    <TableRowInteractive selected={selected}>
+    <TableRowInteractive selected={selected} aria-label={component.name}>
       {canBePinned && (
         <ContentCell className="sw-py-3">
           {isFile && (