aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorIsmail Cherri <ismail.cherri@sonarsource.com>2024-10-21 13:57:13 +0200
committersonartech <sonartech@sonarsource.com>2024-10-22 20:03:09 +0000
commit226ccce51ea2a73e35fc330126d73d825813400d (patch)
treeed3c994788a7b481f5d1da256ca5a9912f7eb347 /server
parent77cc1d1e0db19c2b135313381328fc4f2545a67a (diff)
downloadsonarqube-226ccce51ea2a73e35fc330126d73d825813400d.tar.gz
sonarqube-226ccce51ea2a73e35fc330126d73d825813400d.zip
SONAR-23232 Fix analysis missing message showing on all Pull Requests
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx25
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx9
-rw-r--r--server/sonar-web/src/main/js/helpers/measures.ts12
3 files changed, 42 insertions, 4 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx
index 1a0ccf0c4d1..a3f42dde545 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx
@@ -176,7 +176,7 @@ describe('rendering', () => {
].forEach((measure) => {
expect(ui.measureLink(measure).get()).toBeInTheDocument();
});
- expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument();
+ expect(ui.analysisMissingMessage.get()).toBeInTheDocument();
});
it('should show new counts but not ratings if no rating measures', async () => {
@@ -208,7 +208,7 @@ describe('rendering', () => {
].forEach((measure) => {
expect(ui.measureLink(measure).get()).toBeInTheDocument();
});
- expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument();
+ expect(ui.analysisMissingMessage.get()).toBeInTheDocument();
});
it('should show old measures and no flag message if no rating measures and legacy mode', async () => {
@@ -345,6 +345,26 @@ describe('rendering', () => {
expect(await ui.detailsUnavailableText.find()).toBeInTheDocument();
});
+ it('should not render analysis missing if on a pull request and leak measure are available', async () => {
+ const { ui } = getPageObject();
+ renderMeasuresApp('component_measures?id=foo&pullRequest=01');
+ await ui.appLoaded();
+
+ expect(screen.queryByText('overview.missing_project_dataTRK')).not.toBeInTheDocument();
+ });
+
+ it('should render analysis missing if on a pull request and leak measure are missing', async () => {
+ const { ui } = getPageObject();
+ measuresHandler.deleteComponentMeasure(
+ 'foo',
+ MetricKey.new_software_quality_maintainability_rating,
+ );
+ renderMeasuresApp('component_measures?id=foo&pullRequest=01');
+ await ui.appLoaded();
+
+ expect(ui.analysisMissingMessage.get()).toBeInTheDocument();
+ });
+
it('should render a warning message if the user does not have access to all components', async () => {
const { ui } = getPageObject();
renderMeasuresApp('component_measures?id=foo&metric=code_smells', {
@@ -663,6 +683,7 @@ function getPageObject() {
seeDataAsListLink: byRole('link', { name: 'component_measures.overview.see_data_as_list' }),
bubbleChart: byTestId('bubble-chart'),
newCodePeriodTxt: byText('component_measures.leak_legend.new_code'),
+ analysisMissingMessage: byText('overview.missing_project_dataTRK'),
// Navigation
overviewDomainLink: byRole('link', {
diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
index f12e7111e68..f1a488cb6bd 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
+++ b/server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
@@ -46,6 +46,8 @@ import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissi
import { translate } from '../../../helpers/l10n';
import {
areCCTMeasuresComputed,
+ areLeakCCTMeasuresComputed,
+ areLeakSoftwareQualityRatingsComputed,
areSoftwareQualityRatingsComputed,
} from '../../../helpers/measures';
import { useCurrentBranchQuery } from '../../../queries/branch';
@@ -104,6 +106,10 @@ export default function ComponentMeasuresApp() {
componentWithMeasures?.qualifier === ComponentQualifier.Project ? period : undefined;
const displayOverview = hasBubbleChart(bubblesByDomain, query.metric);
+ const showMissingAnalysisMessage = isPullRequest(branchLike)
+ ? !areLeakCCTMeasuresComputed(measures) || !areLeakSoftwareQualityRatingsComputed(measures)
+ : !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures);
+
if (!component) {
return null;
}
@@ -226,8 +232,7 @@ export default function ComponentMeasuresApp() {
/>
</FlagMessage>
)}
- {(!areCCTMeasuresComputed(measures) ||
- !areSoftwareQualityRatingsComputed(measures)) && (
+ {showMissingAnalysisMessage && (
<AnalysisMissingInfoMessage
className="sw-mb-4"
qualifier={component?.qualifier as ComponentQualifier}
diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts
index d7569bbb15d..c3fed3454e3 100644
--- a/server/sonar-web/src/main/js/helpers/measures.ts
+++ b/server/sonar-web/src/main/js/helpers/measures.ts
@@ -129,6 +129,18 @@ export function areSoftwareQualityRatingsComputed(measures?: Measure[] | Measure
);
}
+export function areLeakSoftwareQualityRatingsComputed(measures?: Measure[] | MeasureEnhanced[]) {
+ return [
+ MetricKey.new_software_quality_reliability_rating,
+ MetricKey.new_software_quality_security_rating,
+ MetricKey.new_software_quality_maintainability_rating,
+ ].every((metric) =>
+ measures?.find((measure) =>
+ isMeasureEnhanced(measure) ? measure.metric.key === metric : measure.metric === metric,
+ ),
+ );
+}
+
export function areLeakAndOverallCCTMeasuresComputed(measures?: Measure[] | MeasureEnhanced[]) {
return areLeakCCTMeasuresComputed(measures) && areCCTMeasuresComputed(measures);
}