From dbee5e8b4541305dc8e7610757d50551a1593267 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Tue, 23 Oct 2018 11:08:28 +0200 Subject: [PATCH] SONAR-11379 Display estimated duplications and disable drilldown (#868) --- .../component-measures/components/App.tsx | 21 ++++++++- .../components/__tests__/App-test.tsx | 11 ++++- .../__tests__/__snapshots__/App-test.tsx.snap | 46 ++++++++++++++++++- .../main/js/apps/component-measures/utils.ts | 1 + .../resources/org/sonar/l10n/core.properties | 1 + 5 files changed, 76 insertions(+), 4 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx index 97111db9d91..3ecb85b9786 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/App.tsx @@ -37,7 +37,12 @@ import { groupByDomains, sortMeasures } from '../utils'; -import { isSameBranchLike, getBranchLikeQuery } from '../../../helpers/branches'; +import { + isSameBranchLike, + getBranchLikeQuery, + isShortLivingBranch, + isPullRequest +} from '../../../helpers/branches'; import Suggestions from '../../../app/components/embed-docs-modal/Suggestions'; import { getLocalizedMetricDomain, @@ -224,6 +229,20 @@ export default class App extends React.PureComponent { return ; } + const hideDrilldown = + (isShortLivingBranch(branchLike) || isPullRequest(branchLike)) && + (metric.key === 'coverage' || metric.key === 'duplicated_lines_density'); + + if (hideDrilldown) { + return ( +
+
+
{translate('component_measures.details_are_not_available')}
+
+
+ ); + } + return ( { await waitAndUpdate(wrapper); expect(wrapper).toMatchSnapshot(); }); + +it('should not render drilldown for estimated duplications', async () => { + const pullRequest = { base: 'master', branch: 'feature-x', key: '5', title: '' }; + const wrapper = shallow(); + await waitAndUpdate(wrapper); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap index 1360a4c4482..ff587bed735 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/component-measures/components/__tests__/__snapshots__/App-test.tsx.snap @@ -1,5 +1,40 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`should not render drilldown for estimated duplications 1`] = ` +
+ + +
+ +
+
+
+ component_measures.details_are_not_available +
+
+
+
+
+`; + exports[`should render a message when there are no measures 1`] = `