]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12753 Update view when hotspot status is changed
authorJeremy Davis <jeremy.davis@sonarsource.com>
Tue, 17 Dec 2019 17:48:40 +0000 (18:48 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 13 Jan 2020 19:46:31 +0000 (20:46 +0100)
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotSnippetContainer-test.tsx.snap
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotSnippetContainerRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewerRenderer-test.tsx.snap
server/sonar-web/src/main/js/helpers/mocks/security-hotspots.ts

index b61510d9ad8d729ee70fd2809136888a30200d9e..1b66d70803f5a968e8440964a26b748e4f236c64 100644 (file)
@@ -67,6 +67,7 @@ export default class HotspotViewer extends React.PureComponent<Props, State> {
 
   handleHotspotUpdate = (data: HotspotUpdateFields) => {
     this.props.onUpdateHotspot({ key: this.props.hotspotKey, ...data });
+    this.fetchHotspot();
   };
 
   render() {
index 21a550631385831fed53c6c3d7fb4599909e9e32..8ce753caee8435d71ad93065c0d59a143dd400d7 100644 (file)
@@ -61,7 +61,7 @@ export function HotspotViewerRenderer(props: HotspotViewerRendererProps) {
           <div className="huge-spacer-bottom">
             <span>{translate('hotspot.status')}</span>
             <span className="badge little-spacer-left">
-              {translate('issue.status', hotspot.status)}
+              {translate('hotspot.status', hotspot.resolution || hotspot.status)}
             </span>
             {hotspot.assignee && hotspot.assignee.name && (
               <>
index b1ce8cf1cbdb078c66c311938e7d064836e64cc2..2dca00aa32e465619466b75e6876b552d75d6cf9 100644 (file)
@@ -21,6 +21,7 @@ import { shallow } from 'enzyme';
 import * as React from 'react';
 import { Button } from 'sonar-ui-common/components/controls/buttons';
 import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { mockDetailledHotspot } from '../../../../helpers/mocks/security-hotspots';
 import { HotspotStatus } from '../../../../types/security-hotspots';
 import HotspotActions, { HotspotActionsProps } from '../HotspotActions';
 
@@ -69,8 +70,7 @@ it('should register an eventlistener', () => {
 function shallowRender(props: Partial<HotspotActionsProps> = {}) {
   return shallow(
     <HotspotActions
-      hotspotKey="key"
-      hotspotStatus={HotspotStatus.TO_REVIEW}
+      hotspot={mockDetailledHotspot({ key: 'key', status: HotspotStatus.TO_REVIEW })}
       onSubmit={jest.fn()}
       {...props}
     />
index dfde95a28d3f54425a666120af19e8f048addc9a..9bf2e5f400d736b81237d4d8d1829e8e08d62c95 100644 (file)
@@ -57,7 +57,7 @@ exports[`should handle collapse and expand 2`] = `
     <li
       key="01fc972e-2a3c-433e-bcae-0bd7f88f5123"
     >
-      <Memo(HotspotListItem)
+      <HotspotListItem
         hotspot={
           Object {
             "author": "Developer 1",
@@ -114,7 +114,7 @@ exports[`should render correctly with hotspots 1`] = `
     <li
       key="h1"
     >
-      <Memo(HotspotListItem)
+      <HotspotListItem
         hotspot={
           Object {
             "author": "Developer 1",
@@ -139,7 +139,7 @@ exports[`should render correctly with hotspots 1`] = `
     <li
       key="h2"
     >
-      <Memo(HotspotListItem)
+      <HotspotListItem
         hotspot={
           Object {
             "author": "Developer 1",
index 0d5e1ad75b43bfb6f16f2c00f8c5b124bd31a245..f24c9b4ed5aac8bb0abdd7a7771efed2cf0168f5 100644 (file)
@@ -71,7 +71,7 @@ exports[`should render correctly 1`] = `
         ],
         "tags": Array [],
       },
-      "resolution": "FALSE-POSITIVE",
+      "resolution": "FIXED",
       "rule": Object {
         "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
         "key": "squid:S2077",
@@ -81,7 +81,7 @@ exports[`should render correctly 1`] = `
         "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
         "vulnerabilityProbability": "HIGH",
       },
-      "status": "RESOLVED",
+      "status": "REVIEWED",
       "textRange": Object {
         "endLine": 142,
         "endOffset": 83,
index 883f7e10dad612ab5230a9304eb4a74c6d63c43e..df32f19c2b8b0639944fec0744a297c90f374248 100644 (file)
@@ -195,7 +195,7 @@ exports[`should render correctly: with sourcelines 1`] = `
               ],
               "tags": Array [],
             },
-            "resolution": "FALSE-POSITIVE",
+            "resolution": "FIXED",
             "rule": Object {
               "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
               "key": "squid:S2077",
@@ -205,7 +205,7 @@ exports[`should render correctly: with sourcelines 1`] = `
               "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
               "vulnerabilityProbability": "HIGH",
             },
-            "status": "RESOLVED",
+            "status": "REVIEWED",
             "textRange": Object {
               "endLine": 142,
               "endOffset": 83,
index 54b431acf164699c74c8fc312ae062e06e964b3d..716dfc0dca719ec4818afc325611a537f5895a3e 100644 (file)
@@ -40,7 +40,7 @@ exports[`should render correctly 1`] = `
       <span
         className="badge little-spacer-left"
       >
-        issue.status.RESOLVED
+        hotspot.status.FIXED
       </span>
       <span
         className="huge-spacer-left"
@@ -114,7 +114,7 @@ exports[`should render correctly 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -124,7 +124,7 @@ exports[`should render correctly 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -196,7 +196,7 @@ exports[`should render correctly 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -206,7 +206,7 @@ exports[`should render correctly 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -261,7 +261,7 @@ exports[`should render correctly: anonymous user 1`] = `
       <span
         className="badge little-spacer-left"
       >
-        issue.status.RESOLVED
+        hotspot.status.FIXED
       </span>
       <span
         className="huge-spacer-left"
@@ -335,7 +335,7 @@ exports[`should render correctly: anonymous user 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -345,7 +345,7 @@ exports[`should render correctly: anonymous user 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -417,7 +417,7 @@ exports[`should render correctly: anonymous user 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -427,7 +427,7 @@ exports[`should render correctly: anonymous user 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -482,7 +482,7 @@ exports[`should render correctly: deleted assignee 1`] = `
       <span
         className="badge little-spacer-left"
       >
-        issue.status.RESOLVED
+        hotspot.status.FIXED
       </span>
       <span
         className="huge-spacer-left"
@@ -556,7 +556,7 @@ exports[`should render correctly: deleted assignee 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -566,7 +566,7 @@ exports[`should render correctly: deleted assignee 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -638,7 +638,7 @@ exports[`should render correctly: deleted assignee 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -648,7 +648,7 @@ exports[`should render correctly: deleted assignee 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -688,8 +688,86 @@ exports[`should render correctly: user logged in 1`] = `
           '3' is a magic number.
         </h1>
         <HotspotActions
-          hotspotKey="01fc972e-2a3c-433e-bcae-0bd7f88f5123"
-          hotspotStatus="RESOLVED"
+          hotspot={
+            Object {
+              "assignee": Object {
+                "active": true,
+                "local": true,
+                "login": "john.doe",
+                "name": "John Doe",
+              },
+              "author": Object {
+                "active": true,
+                "local": true,
+                "login": "john.doe",
+                "name": "John Doe",
+              },
+              "component": Object {
+                "breadcrumbs": Array [],
+                "key": "my-project",
+                "name": "MyProject",
+                "organization": "foo",
+                "qualifier": "FIL",
+                "qualityGate": Object {
+                  "isDefault": true,
+                  "key": "30",
+                  "name": "Sonar way",
+                },
+                "qualityProfiles": Array [
+                  Object {
+                    "deleted": false,
+                    "key": "my-qp",
+                    "language": "ts",
+                    "name": "Sonar way",
+                  },
+                ],
+                "tags": Array [],
+              },
+              "creationDate": "2013-05-13T17:55:41+0200",
+              "key": "01fc972e-2a3c-433e-bcae-0bd7f88f5123",
+              "line": 142,
+              "message": "'3' is a magic number.",
+              "project": Object {
+                "breadcrumbs": Array [],
+                "key": "my-project",
+                "name": "MyProject",
+                "organization": "foo",
+                "qualifier": "TRK",
+                "qualityGate": Object {
+                  "isDefault": true,
+                  "key": "30",
+                  "name": "Sonar way",
+                },
+                "qualityProfiles": Array [
+                  Object {
+                    "deleted": false,
+                    "key": "my-qp",
+                    "language": "ts",
+                    "name": "Sonar way",
+                  },
+                ],
+                "tags": Array [],
+              },
+              "resolution": "FIXED",
+              "rule": Object {
+                "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
+                "key": "squid:S2077",
+                "name": "That rule",
+                "riskDescription": "<p>This a <strong>strong</strong> message about risk !</p>",
+                "securityCategory": "sql-injection",
+                "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
+                "vulnerabilityProbability": "HIGH",
+              },
+              "status": "REVIEWED",
+              "textRange": Object {
+                "endLine": 142,
+                "endOffset": 83,
+                "startLine": 142,
+                "startOffset": 26,
+              },
+              "updateDate": "2013-05-13T17:55:42+0200",
+            }
+          }
           onSubmit={[MockFunction]}
         />
       </div>
@@ -715,7 +793,7 @@ exports[`should render correctly: user logged in 1`] = `
       <span
         className="badge little-spacer-left"
       >
-        issue.status.RESOLVED
+        hotspot.status.FIXED
       </span>
       <span
         className="huge-spacer-left"
@@ -789,7 +867,7 @@ exports[`should render correctly: user logged in 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -799,7 +877,7 @@ exports[`should render correctly: user logged in 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
@@ -871,7 +949,7 @@ exports[`should render correctly: user logged in 1`] = `
             ],
             "tags": Array [],
           },
-          "resolution": "FALSE-POSITIVE",
+          "resolution": "FIXED",
           "rule": Object {
             "fixRecommendations": "<p>This a <strong>strong</strong> message about fixing !</p>",
             "key": "squid:S2077",
@@ -881,7 +959,7 @@ exports[`should render correctly: user logged in 1`] = `
             "vulnerabilityDescription": "<p>This a <strong>strong</strong> message about vulnerability !</p>",
             "vulnerabilityProbability": "HIGH",
           },
-          "status": "RESOLVED",
+          "status": "REVIEWED",
           "textRange": Object {
             "endLine": 142,
             "endOffset": 83,
index 58ebfcbe3658371cfac8020292faa7444c1f0288..a0633c1892e77f7ea3fe92b08cc50c5d7b6ddee5 100644 (file)
@@ -21,6 +21,7 @@ import { ComponentQualifier } from '../../types/component';
 import {
   DetailedHotspot,
   DetailedHotspotRule,
+  HotspotResolution,
   HotspotStatus,
   RawHotspot,
   RiskExposure
@@ -56,9 +57,9 @@ export function mockDetailledHotspot(overrides?: Partial<DetailedHotspot>): Deta
     line: 142,
     message: "'3' is a magic number.",
     project: mockComponent({ qualifier: ComponentQualifier.Project }),
-    resolution: 'FALSE-POSITIVE',
+    resolution: HotspotResolution.FIXED,
     rule: mockDetailledHotspotRule(),
-    status: 'RESOLVED',
+    status: HotspotStatus.REVIEWED,
     textRange: {
       startLine: 142,
       endLine: 142,