]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21858 Fix project overall ratings tooltip text
authorIsmail Cherri <ismail.cherri@sonarsource.com>
Fri, 5 Apr 2024 14:34:05 +0000 (16:34 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 5 Apr 2024 20:02:39 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactRatingTooltip.tsx
server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx
server/sonar-web/src/main/js/apps/overview/branches/test-utils.ts
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index df155a30c7469bbca74b5b532af2a95757fc248f..d1024da4e865ae967ed3dac0f2ecb04a6def7394 100644 (file)
@@ -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,
index e32950b6c42d316932ad8e4f79a76b7938154f2e..26e9adc8aa0370d5a1e7ca051de7c8931cb5d013 100644 (file)
@@ -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();
   });
 
index 17914108eeb45b0cdd05346207197bc2420f3583..95ff924cc0dac56951954e897f9ee88ae75d3ce0 100644 (file)
@@ -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 };
 };
index c124bdc3cacd591f8b0fc2577c0e76aae5f0f568..10d1f1557d9a42ef331b75d0ebb245d9ab64a5f4 100644 (file)
@@ -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.