diff options
Diffstat (limited to 'server/sonar-web/src')
3 files changed, 45 insertions, 13 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactRatingTooltip.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactRatingTooltip.tsx index df155a30c74..d1024da4e86 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactRatingTooltip.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactRatingTooltip.tsx @@ -30,7 +30,7 @@ export function SoftwareImpactRatingTooltip(props: Readonly<SoftwareImpactRating const intl = useIntl(); - if (!rating || rating === 'A') { + if (rating === undefined) { return null; } @@ -45,6 +45,11 @@ export function SoftwareImpactRatingTooltip(props: Readonly<SoftwareImpactRating ); } + const maintainabilityMessageId = + softwareQuality === SoftwareQuality.Maintainability + ? `.${SoftwareQuality.Maintainability}` + : ''; + const softwareQualityLabel = intl.formatMessage({ id: `software_quality.${softwareQuality}`, }); @@ -56,7 +61,10 @@ export function SoftwareImpactRatingTooltip(props: Readonly<SoftwareImpactRating return intl.formatMessage( { - id: 'overview.measures.software_impact.improve_rating_tooltip', + id: + rating === 'A' + ? `overview.measures.software_impact.improve_rating_tooltip${maintainabilityMessageId}.A` + : `overview.measures.software_impact.improve_rating_tooltip${maintainabilityMessageId}`, }, { softwareQuality: softwareQualityLabel, 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 e32950b6c42..26e9adc8aa0 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 @@ -37,7 +37,7 @@ import { mockAnalysis, mockAnalysisEvent } from '../../../../helpers/mocks/proje import { mockQualityGateProjectStatus } from '../../../../helpers/mocks/quality-gates'; import { mockLoggedInUser, mockMeasure, mockPaging } from '../../../../helpers/testMocks'; import { renderComponent } from '../../../../helpers/testReactTestingUtils'; -import { byLabelText, byRole, byText } from '../../../../helpers/testSelector'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { SoftwareImpactSeverity, SoftwareQuality } from '../../../../types/clean-code-taxonomy'; import { ComponentQualifier } from '../../../../types/component'; import { MetricKey } from '../../../../types/metrics'; @@ -298,6 +298,12 @@ describe('project overview', () => { }, [false, true, false], ); + await ui.expectSoftwareImpactMeasureCardRatingTooltip( + SoftwareQuality.Security, + 'B', + 'overview.measures.software_impact.improve_rating_tooltip.software_quality.SECURITY.software_quality.security.B.overview.measures.software_impact.severity.LOW.improve_tooltip', + ); + ui.expectSoftwareImpactMeasureCard( SoftwareQuality.Reliability, 'A', @@ -311,6 +317,12 @@ describe('project overview', () => { undefined, true, ); + await ui.expectSoftwareImpactMeasureCardRatingTooltip( + SoftwareQuality.Reliability, + 'A', + 'overview.measures.software_impact.improve_rating_tooltip.A.software_quality.RELIABILITY.software_quality.reliability.A.overview.measures.software_impact.severity.LOW.improve_tooltip', + ); + ui.expectSoftwareImpactMeasureCard( SoftwareQuality.Maintainability, 'E', @@ -322,6 +334,11 @@ describe('project overview', () => { }, [false, false, true], ); + await ui.expectSoftwareImpactMeasureCardRatingTooltip( + SoftwareQuality.Maintainability, + 'E', + 'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.E.overview.measures.software_impact.severity.HIGH.improve_tooltip', + ); }); // eslint-disable-next-line jest/expect-expect @@ -400,23 +417,17 @@ describe('project overview', () => { ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Security); expect( - byLabelText( - `overview.project.software_impact.has_rating.software_quality.${SoftwareQuality.Security}.B`, - ).get(), + ui.softwareImpactMeasureCardRating(SoftwareQuality.Security, 'B').get(), ).toBeInTheDocument(); ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Reliability); expect( - byLabelText( - `overview.project.software_impact.has_rating.software_quality.${SoftwareQuality.Reliability}.A`, - ).get(), + ui.softwareImpactMeasureCardRating(SoftwareQuality.Reliability, 'A').get(), ).toBeInTheDocument(); ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability); expect( - byLabelText( - `overview.project.software_impact.has_rating.software_quality.${SoftwareQuality.Maintainability}.E`, - ).get(), + ui.softwareImpactMeasureCardRating(SoftwareQuality.Maintainability, 'E').get(), ).toBeInTheDocument(); }); 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 17914108eeb..95ff924cc0d 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 @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import userEvent from '@testing-library/user-event'; -import { byRole, byTestId, byText } from '../../../helpers/testSelector'; +import { byLabelText, byRole, byTestId, byText } from '../../../helpers/testSelector'; import { SoftwareImpactMeasureData, SoftwareImpactSeverity, @@ -31,6 +31,10 @@ export const getPageObjects = () => { overallCodeButton: byRole('tab', { name: /overview.overall_code/ }), softwareImpactMeasureCard: (softwareQuality: SoftwareQuality) => byTestId(`overview__software-impact-card-${softwareQuality}`), + softwareImpactMeasureCardRating: (softwareQuality: SoftwareQuality, rating: string) => + byLabelText( + `overview.project.software_impact.has_rating.software_quality.${softwareQuality}.${rating}`, + ), }; const ui = { ...selectors, @@ -143,6 +147,15 @@ export const getPageObjects = () => { expect(link).not.toHaveClass('active'); } }, + expectSoftwareImpactMeasureCardRatingTooltip: async ( + softwareQuality: SoftwareQuality, + rating: string, + text: string, + ) => { + await expect( + ui.softwareImpactMeasureCardRating(softwareQuality, rating).get(), + ).toHaveATooltipWithContent(text); + }, }; return { user, ui }; }; |