From: Jeremy Davis Date: Thu, 9 Nov 2023 16:08:57 +0000 (+0100) Subject: SONAR-20998 Improve performance of Code-it X-Git-Tag: 10.4.0.87286~477 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fa13c63645bfb1d3a29ed70c2066d2b1076b6631;p=sonarqube.git SONAR-20998 Improve performance of Code-it --- diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts index b432a72abf0..f0f92a72982 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts +++ b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts @@ -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), diff --git a/server/sonar-web/src/main/js/apps/code/components/Component.tsx b/server/sonar-web/src/main/js/apps/code/components/Component.tsx index 580a2a58ae4..7a7366244aa 100644 --- a/server/sonar-web/src/main/js/apps/code/components/Component.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/Component.tsx @@ -62,7 +62,7 @@ export default function Component(props: Props) { component.qualifier === ComponentQualifier.TestFile; return ( - + {canBePinned && ( {isFile && (