From: Philippe Perrin Date: Mon, 15 Jun 2020 13:35:35 +0000 (+0200) Subject: SONAR-13023 About page doesn't display the security hotspot's count X-Git-Tag: 8.4.0.35506~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b11488eb1b9f2aafa3233397794e8df347078f86;p=sonarqube.git SONAR-13023 About page doesn't display the security hotspot's count --- diff --git a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx index 976999b18d1..64a1c738c07 100644 --- a/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx @@ -115,12 +115,10 @@ export class AboutApp extends React.PureComponent { let bugs; let vulnerabilities; let codeSmells; - let securityHotspots; if (!loading && issueTypes) { bugs = issueTypes['BUG'] && issueTypes['BUG'].count; vulnerabilities = issueTypes['VULNERABILITY'] && issueTypes['VULNERABILITY'].count; codeSmells = issueTypes['CODE_SMELL'] && issueTypes['CODE_SMELL'].count; - securityHotspots = issueTypes['SECURITY_HOTSPOT'] && issueTypes['SECURITY_HOTSPOT'].count; } return ( @@ -147,7 +145,6 @@ export class AboutApp extends React.PureComponent { bugs={bugs} codeSmells={codeSmells} loading={loading} - securityHotspots={securityHotspots} vulnerabilities={vulnerabilities} /> diff --git a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx index 9f9bc94500d..1743b3811f3 100644 --- a/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx +++ b/server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx @@ -21,17 +21,15 @@ import * as React from 'react'; import { Link } from 'react-router'; import BugIcon from 'sonar-ui-common/components/icons/BugIcon'; import CodeSmellIcon from 'sonar-ui-common/components/icons/CodeSmellIcon'; -import SecurityHotspotIcon from 'sonar-ui-common/components/icons/SecurityHotspotIcon'; import VulnerabilityIcon from 'sonar-ui-common/components/icons/VulnerabilityIcon'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { formatMeasure } from 'sonar-ui-common/helpers/measures'; import { getIssuesUrl } from '../../../helpers/urls'; -interface Props { +export interface EntryIssueTypesProps { bugs?: number; codeSmells?: number; loading: boolean; - securityHotspots?: number; vulnerabilities?: number; } @@ -39,9 +37,8 @@ export default function EntryIssueTypes({ bugs, codeSmells, loading, - securityHotspots, vulnerabilities -}: Props) { +}: EntryIssueTypesProps) { return (
{loading ? ( @@ -98,25 +95,6 @@ export default function EntryIssueTypes({ {translate('issue.type.CODE_SMELL.plural')} - - - - {formatMeasure(securityHotspots, 'SHORT_INT')} - - - - - - - {translate('issue.type.SECURITY_HOTSPOT.plural')} - - )} diff --git a/server/sonar-web/src/main/js/apps/about/components/__tests__/EntryIssueTypes-test.tsx b/server/sonar-web/src/main/js/apps/about/components/__tests__/EntryIssueTypes-test.tsx new file mode 100644 index 00000000000..09d68dd0e8d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/about/components/__tests__/EntryIssueTypes-test.tsx @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import { shallow } from 'enzyme'; +import * as React from 'react'; +import EntryIssueTypes, { EntryIssueTypesProps } from '../EntryIssueTypes'; + +it('should render correctly', () => { + const wrapper = shallowRender(); + + expect(wrapper).toMatchSnapshot('loading'); + + wrapper.setProps({ loading: false }); + + expect(wrapper).toMatchSnapshot('loading'); +}); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap b/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap index f1fe792370d..292d1393e56 100644 --- a/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap @@ -60,7 +60,6 @@ exports[`should render correctly 1`] = ` bugs={10} codeSmells={5} loading={false} - securityHotspots={5} vulnerabilities={0} />
diff --git a/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/EntryIssueTypes-test.tsx.snap b/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/EntryIssueTypes-test.tsx.snap new file mode 100644 index 00000000000..fe7b11d60ce --- /dev/null +++ b/server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/EntryIssueTypes-test.tsx.snap @@ -0,0 +1,117 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly: loading 1`] = ` +
+ +
+`; + +exports[`should render correctly: loading 2`] = ` +
+ + + + + + + + + + + + + + + +
+ + 10 + + + + + + issue.type.BUG.plural +
+ + 1short_number_suffix.k + + + + + + issue.type.VULNERABILITY.plural +
+ + 100 + + + + + + issue.type.CODE_SMELL.plural +
+
+`;