diff options
author | stanislavh <stanislav.honcharov@sonarsource.com> | 2024-02-13 10:48:01 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-02-14 20:02:33 +0000 |
commit | df05d8edc5f11f168071e6e4db5429f001f2ee7d (patch) | |
tree | ee84a0e25d74d915b49f793026690f2a6bcc1836 /server | |
parent | 66be361628612970f753712ab6f10b0631168dbf (diff) | |
download | sonarqube-df05d8edc5f11f168071e6e4db5429f001f2ee7d.tar.gz sonarqube-df05d8edc5f11f168071e6e4db5429f001f2ee7d.zip |
SONAR-21600 Add branch name to software quality counters links
Diffstat (limited to 'server')
5 files changed, 46 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx b/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx index c32c347f5bb..52893ab28c9 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/OverallCodeMeasuresPanel.tsx @@ -29,7 +29,7 @@ import { useIntl } from 'react-intl'; import { getBranchLikeQuery } from '../../../helpers/branch-like'; import { findMeasure, formatMeasure, formatRating } from '../../../helpers/measures'; import { getComponentIssuesUrl, getComponentSecurityHotspotsUrl } from '../../../helpers/urls'; -import { BranchLike } from '../../../types/branch-like'; +import { Branch } from '../../../types/branch-like'; import { SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { isApplication } from '../../../types/component'; import { IssueStatus } from '../../../types/issues'; @@ -44,7 +44,7 @@ import MeasuresPanelPercentCards from './MeasuresPanelPercentCards'; import SoftwareImpactMeasureCard from './SoftwareImpactMeasureCard'; export interface OverallCodeMeasuresPanelProps { - branch?: BranchLike; + branch?: Branch; component: Component; measures: MeasureEnhanced[]; qgStatuses?: QualityGateStatus[]; @@ -65,18 +65,21 @@ export default function OverallCodeMeasuresPanel(props: Readonly<OverallCodeMeas <div id={getTabPanelId(MeasuresTabs.Overall)} className="sw-mt-6"> <div className="sw-flex sw-gap-4"> <SoftwareImpactMeasureCard + branch={branch} component={component} softwareQuality={SoftwareQuality.Security} ratingMetricKey={MetricKey.security_rating} measures={measures} /> <SoftwareImpactMeasureCard + branch={branch} component={component} softwareQuality={SoftwareQuality.Reliability} ratingMetricKey={MetricKey.reliability_rating} measures={measures} /> <SoftwareImpactMeasureCard + branch={branch} component={component} softwareQuality={SoftwareQuality.Maintainability} ratingMetricKey={MetricKey.sqale_rating} diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureBreakdownCard.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureBreakdownCard.tsx index 0366bb06bf9..4e6799fd95d 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureBreakdownCard.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureBreakdownCard.tsx @@ -25,12 +25,14 @@ import { useIntl } from 'react-intl'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; import { formatMeasure } from '../../../helpers/measures'; import { getComponentIssuesUrl } from '../../../helpers/urls'; +import { Branch } from '../../../types/branch-like'; import { SoftwareImpactSeverity, SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { MetricType } from '../../../types/metrics'; import { Component } from '../../../types/types'; export interface SoftwareImpactMeasureBreakdownCardProps { softwareQuality: SoftwareQuality; + branch?: Branch; component: Component; value?: string; severity: SoftwareImpactSeverity; @@ -40,7 +42,7 @@ export interface SoftwareImpactMeasureBreakdownCardProps { export function SoftwareImpactMeasureBreakdownCard( props: Readonly<SoftwareImpactMeasureBreakdownCardProps>, ) { - const { softwareQuality, component, value, severity, active } = props; + const { softwareQuality, component, value, severity, active, branch } = props; const intl = useIntl(); @@ -48,6 +50,7 @@ export function SoftwareImpactMeasureBreakdownCard( ...DEFAULT_ISSUES_QUERY, impactSoftwareQualities: softwareQuality, impactSeverities: severity, + branch: branch?.name, }); const testId = `overview__software-impact-${softwareQuality}-severity-${severity}`; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx index 5a1ef7bcd5b..5907d3ee693 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx @@ -33,6 +33,7 @@ import Tooltip from '../../../components/controls/Tooltip'; import { DEFAULT_ISSUES_QUERY } from '../../../components/shared/utils'; import { formatMeasure } from '../../../helpers/measures'; import { getComponentIssuesUrl } from '../../../helpers/urls'; +import { Branch } from '../../../types/branch-like'; import { SoftwareImpactMeasureData, SoftwareImpactSeverity, @@ -50,10 +51,11 @@ export interface SoftwareImpactBreakdownCardProps { softwareQuality: SoftwareQuality; ratingMetricKey: MetricKey; measures: MeasureEnhanced[]; + branch?: Branch; } export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdownCardProps>) { - const { component, softwareQuality, ratingMetricKey, measures } = props; + const { component, softwareQuality, ratingMetricKey, measures, branch } = props; const intl = useIntl(); @@ -70,6 +72,7 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow const totalLinkHref = getComponentIssuesUrl(component.key, { ...DEFAULT_ISSUES_QUERY, impactSoftwareQualities: softwareQuality, + branch: branch?.name, }); // We highlight the highest severity breakdown card with non-zero count @@ -140,6 +143,7 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow SoftwareImpactSeverity.Low, ].map((severity) => ( <SoftwareImpactMeasureBreakdownCard + branch={branch} key={severity} component={component} softwareQuality={softwareQuality} diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx index 5a5b5547ebf..429ab05477c 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx @@ -302,6 +302,27 @@ describe('project overview', () => { ); }); + // eslint-disable-next-line jest/expect-expect + it('should render overall tab without branch specified', async () => { + const { user, ui } = getPageObjects(); + renderBranchOverview({ branch: undefined }); + + await user.click(await ui.overallCodeButton.find()); + + ui.expectSoftwareImpactMeasureCard( + SoftwareQuality.Maintainability, + 'E', + { + total: 2, + [SoftwareImpactSeverity.High]: 0, + [SoftwareImpactSeverity.Medium]: 0, + [SoftwareImpactSeverity.Low]: 1, + }, + [false, false, true], + '', + ); + }); + it('should render missing software impact measure cards', async () => { // Make as if reliability_issues was not computed measuresHandler.deleteComponentMeasure('foo', MetricKey.maintainability_issues); diff --git a/server/sonar-web/src/main/js/apps/overview/branches/test-utils.ts b/server/sonar-web/src/main/js/apps/overview/branches/test-utils.ts index d6e4e1f592c..d748b941b48 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/test-utils.ts +++ b/server/sonar-web/src/main/js/apps/overview/branches/test-utils.ts @@ -39,6 +39,7 @@ export const getPageObjects = () => { rating?: string, data?: SoftwareImpactMeasureData, severitiesActiveState?: boolean[], + branch = 'master', ) => { if (typeof rating === 'string') { expect( @@ -46,18 +47,26 @@ export const getPageObjects = () => { ).toBeInTheDocument(); } if (data) { + const branchQuery = branch ? `&branch=${branch}` : ''; + expect( byRole('link', { name: `overview.measures.software_impact.see_list_of_x_open_issues.${data.total}.software_quality.${softwareQuality}`, }).get(), - ).toBeInTheDocument(); + ).toHaveAttribute( + 'href', + `/project/issues?issueStatuses=OPEN%2CCONFIRMED&impactSoftwareQualities=${softwareQuality}${branchQuery}&id=foo`, + ); expect( byRole('link', { name: `overview.measures.software_impact.severity.see_x_open_issues.${ data[SoftwareImpactSeverity.High] }.software_quality.${softwareQuality}.overview.measures.software_impact.severity.HIGH.tooltip`, }).get(), - ).toBeInTheDocument(); + ).toHaveAttribute( + 'href', + `/project/issues?issueStatuses=OPEN%2CCONFIRMED&impactSoftwareQualities=${softwareQuality}&impactSeverities=${SoftwareImpactSeverity.High}${branchQuery}&id=foo`, + ); expect( byRole('link', { name: `overview.measures.software_impact.severity.see_x_open_issues.${ |