From db209490bc43fa60c53b47327cc35a8ba866981c Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Fri, 5 Apr 2024 16:34:05 +0200 Subject: [PATCH] SONAR-21858 Fix project overall ratings tooltip text --- .../branches/SoftwareImpactRatingTooltip.tsx | 12 +++++-- .../branches/__tests__/BranchOverview-it.tsx | 31 +++++++++++++------ .../js/apps/overview/branches/test-utils.ts | 15 ++++++++- .../resources/org/sonar/l10n/core.properties | 5 ++- 4 files changed, 49 insertions(+), 14 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 { }, [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 }; }; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index c124bdc3cac..10d1f1557d9 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3963,7 +3963,10 @@ overview.measures.software_impact.severity.MEDIUM.improve_tooltip=medium overview.measures.software_impact.severity.LOW=L overview.measures.software_impact.severity.LOW.tooltip=Low Impact overview.measures.software_impact.severity.LOW.improve_tooltip=low -overview.measures.software_impact.improve_rating_tooltip={softwareQuality} rating is a {ratingLabel} when there is at least one issue with {severity} impact on the {_softwareQuality} of your software. +overview.measures.software_impact.improve_rating_tooltip=The {softwareQuality} rating is {ratingLabel} when there is at least one issue with {severity} impact on the {_softwareQuality} of your software. +overview.measures.software_impact.improve_rating_tooltip.A=The {softwareQuality} rating is {ratingLabel} when there are no issues with impact on the {_softwareQuality} of your software. +overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY=The Maintainability rating is {ratingLabel} if the code has a relatively higher level of technical debt when compared to the size of the codebase. +overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.A=The Maintainability rating is A if the code has a relatively lower level of technical debt when compared to the size of the codebase. overview.project.no_lines_of_code=This project has no lines of code. overview.project.empty=This project is empty. -- 2.39.5