]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13023 About page doesn't display the security hotspot's count
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Mon, 15 Jun 2020 13:35:35 +0000 (15:35 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 26 Jun 2020 20:04:58 +0000 (20:04 +0000)
server/sonar-web/src/main/js/apps/about/components/AboutApp.tsx
server/sonar-web/src/main/js/apps/about/components/EntryIssueTypes.tsx
server/sonar-web/src/main/js/apps/about/components/__tests__/EntryIssueTypes-test.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/AboutApp-test.tsx.snap
server/sonar-web/src/main/js/apps/about/components/__tests__/__snapshots__/EntryIssueTypes-test.tsx.snap [new file with mode: 0644]

index 976999b18d1516a55e217dbcaea8df246958664f..64a1c738c071617720140706e955271e24c8095f 100644 (file)
@@ -115,12 +115,10 @@ export class AboutApp extends React.PureComponent<Props, State> {
     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<Props, State> {
                 bugs={bugs}
                 codeSmells={codeSmells}
                 loading={loading}
-                securityHotspots={securityHotspots}
                 vulnerabilities={vulnerabilities}
               />
             </div>
index 9f9bc94500dd6f4970c990e46545e91ed5ae67ca..1743b3811f3a1260b58563095239571ddbabacc7 100644 (file)
@@ -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 (
     <div className="about-page-projects">
       {loading ? (
@@ -98,25 +95,6 @@ export default function EntryIssueTypes({
                 {translate('issue.type.CODE_SMELL.plural')}
               </td>
             </tr>
-            <tr>
-              <td className="about-page-issue-type-number">
-                <Link
-                  className="about-page-issue-type-link"
-                  to={getIssuesUrl({
-                    resolved: 'false',
-                    types: 'SECURITY_HOTSPOT',
-                    s: 'CREATION_DATE'
-                  })}>
-                  {formatMeasure(securityHotspots, 'SHORT_INT')}
-                </Link>
-              </td>
-              <td>
-                <span className="little-spacer-right">
-                  <SecurityHotspotIcon />
-                </span>
-                {translate('issue.type.SECURITY_HOTSPOT.plural')}
-              </td>
-            </tr>
           </tbody>
         </table>
       )}
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 (file)
index 0000000..09d68dd
--- /dev/null
@@ -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<EntryIssueTypesProps> = {}) {
+  return shallow<EntryIssueTypesProps>(
+    <EntryIssueTypes loading={true} bugs={10} codeSmells={100} vulnerabilities={1000} {...props} />
+  );
+}
index f1fe792370d5679120feee49881df1b8efcd9b58..292d1393e5637faeb590ab0697089a932813779b 100644 (file)
@@ -60,7 +60,6 @@ exports[`should render correctly 1`] = `
           bugs={10}
           codeSmells={5}
           loading={false}
-          securityHotspots={5}
           vulnerabilities={0}
         />
       </div>
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 (file)
index 0000000..fe7b11d
--- /dev/null
@@ -0,0 +1,117 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly: loading 1`] = `
+<div
+  className="about-page-projects"
+>
+  <i
+    className="spinner"
+  />
+</div>
+`;
+
+exports[`should render correctly: loading 2`] = `
+<div
+  className="about-page-projects"
+>
+  <table
+    className="about-page-issue-types"
+  >
+    <tbody>
+      <tr>
+        <td
+          className="about-page-issue-type-number"
+        >
+          <Link
+            className="about-page-issue-type-link"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/issues",
+                "query": Object {
+                  "resolved": "false",
+                  "s": "CREATION_DATE",
+                  "types": "BUG",
+                },
+              }
+            }
+          >
+            10
+          </Link>
+        </td>
+        <td>
+          <span
+            className="little-spacer-right"
+          >
+            <BugIcon />
+          </span>
+          issue.type.BUG.plural
+        </td>
+      </tr>
+      <tr>
+        <td
+          className="about-page-issue-type-number"
+        >
+          <Link
+            className="about-page-issue-type-link"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/issues",
+                "query": Object {
+                  "resolved": "false",
+                  "s": "CREATION_DATE",
+                  "types": "VULNERABILITY",
+                },
+              }
+            }
+          >
+            1short_number_suffix.k
+          </Link>
+        </td>
+        <td>
+          <span
+            className="little-spacer-right"
+          >
+            <VulnerabilityIcon />
+          </span>
+          issue.type.VULNERABILITY.plural
+        </td>
+      </tr>
+      <tr>
+        <td
+          className="about-page-issue-type-number"
+        >
+          <Link
+            className="about-page-issue-type-link"
+            onlyActiveOnIndex={false}
+            style={Object {}}
+            to={
+              Object {
+                "pathname": "/issues",
+                "query": Object {
+                  "resolved": "false",
+                  "s": "CREATION_DATE",
+                  "types": "CODE_SMELL",
+                },
+              }
+            }
+          >
+            100
+          </Link>
+        </td>
+        <td>
+          <span
+            className="little-spacer-right"
+          >
+            <CodeSmellIcon />
+          </span>
+          issue.type.CODE_SMELL.plural
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</div>
+`;