From fa13c63645bfb1d3a29ed70c2066d2b1076b6631 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Thu, 9 Nov 2023 17:08:57 +0100 Subject: [PATCH] SONAR-20998 Improve performance of Code-it --- .../src/main/js/apps/code/__tests__/Code-it.ts | 18 ++++++++++++++++-- .../main/js/apps/code/components/Component.tsx | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) 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 && ( -- 2.39.5