].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 () => {
].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 () => {
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', {
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', {
import { translate } from '../../../helpers/l10n';
import {
areCCTMeasuresComputed,
+ areLeakCCTMeasuresComputed,
+ areLeakSoftwareQualityRatingsComputed,
areSoftwareQualityRatingsComputed,
} from '../../../helpers/measures';
import { useCurrentBranchQuery } from '../../../queries/branch';
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;
}
/>
</FlagMessage>
)}
- {(!areCCTMeasuresComputed(measures) ||
- !areSoftwareQualityRatingsComputed(measures)) && (
+ {showMissingAnalysisMessage && (
<AnalysisMissingInfoMessage
className="sw-mb-4"
qualifier={component?.qualifier as ComponentQualifier}
);
}
+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);
}