From: Jeremy Davis
Date: Tue, 17 Dec 2019 17:48:40 +0000 (+0100)
Subject: SONAR-12753 Update view when hotspot status is changed
X-Git-Tag: 8.2.0.32929~176
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=11d161e74eb6676592f3a0df009a53d86817605c;p=sonarqube.git
SONAR-12753 Update view when hotspot status is changed
---
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx
index b61510d9ad8..1b66d70803f 100644
--- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx
+++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewer.tsx
@@ -67,6 +67,7 @@ export default class HotspotViewer extends React.PureComponent {
handleHotspotUpdate = (data: HotspotUpdateFields) => {
this.props.onUpdateHotspot({ key: this.props.hotspotKey, ...data });
+ this.fetchHotspot();
};
render() {
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx
index 21a55063138..8ce753caee8 100644
--- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx
+++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerRenderer.tsx
@@ -61,7 +61,7 @@ export function HotspotViewerRenderer(props: HotspotViewerRendererProps) {
{translate('hotspot.status')}
- {translate('issue.status', hotspot.status)}
+ {translate('hotspot.status', hotspot.resolution || hotspot.status)}
{hotspot.assignee && hotspot.assignee.name && (
<>
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx
index b1ce8cf1cbd..2dca00aa32e 100644
--- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx
+++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/HotspotActions-test.tsx
@@ -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
= {}) {
return shallow(
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap
index dfde95a28d3..9bf2e5f400d 100644
--- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotCategory-test.tsx.snap
@@ -57,7 +57,7 @@ exports[`should handle collapse and expand 2`] = `
-
-
- This a strong message about fixing !",
"key": "squid:S2077",
@@ -81,7 +81,7 @@ exports[`should render correctly 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"vulnerabilityProbability": "HIGH",
},
- "status": "RESOLVED",
+ "status": "REVIEWED",
"textRange": Object {
"endLine": 142,
"endOffset": 83,
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotSnippetContainerRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotSnippetContainerRenderer-test.tsx.snap
index 883f7e10dad..df32f19c2b8 100644
--- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotSnippetContainerRenderer-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotSnippetContainerRenderer-test.tsx.snap
@@ -195,7 +195,7 @@ exports[`should render correctly: with sourcelines 1`] = `
],
"tags": Array [],
},
- "resolution": "FALSE-POSITIVE",
+ "resolution": "FIXED",
"rule": Object {
"fixRecommendations": "This a strong message about fixing !
",
"key": "squid:S2077",
@@ -205,7 +205,7 @@ exports[`should render correctly: with sourcelines 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"vulnerabilityProbability": "HIGH",
},
- "status": "RESOLVED",
+ "status": "REVIEWED",
"textRange": Object {
"endLine": 142,
"endOffset": 83,
diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewerRenderer-test.tsx.snap b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewerRenderer-test.tsx.snap
index 54b431acf16..716dfc0dca7 100644
--- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewerRenderer-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/__snapshots__/HotspotViewerRenderer-test.tsx.snap
@@ -40,7 +40,7 @@ exports[`should render correctly 1`] = `
- issue.status.RESOLVED
+ hotspot.status.FIXED
This a strong message about fixing !",
"key": "squid:S2077",
@@ -124,7 +124,7 @@ exports[`should render correctly 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"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": "This a strong message about fixing !
",
"key": "squid:S2077",
@@ -206,7 +206,7 @@ exports[`should render correctly 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"vulnerabilityProbability": "HIGH",
},
- "status": "RESOLVED",
+ "status": "REVIEWED",
"textRange": Object {
"endLine": 142,
"endOffset": 83,
@@ -261,7 +261,7 @@ exports[`should render correctly: anonymous user 1`] = `
- issue.status.RESOLVED
+ hotspot.status.FIXED
This a strong message about fixing !",
"key": "squid:S2077",
@@ -345,7 +345,7 @@ exports[`should render correctly: anonymous user 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"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": "This a strong message about fixing !
",
"key": "squid:S2077",
@@ -427,7 +427,7 @@ exports[`should render correctly: anonymous user 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"vulnerabilityProbability": "HIGH",
},
- "status": "RESOLVED",
+ "status": "REVIEWED",
"textRange": Object {
"endLine": 142,
"endOffset": 83,
@@ -482,7 +482,7 @@ exports[`should render correctly: deleted assignee 1`] = `
- issue.status.RESOLVED
+ hotspot.status.FIXED
This a strong message about fixing !",
"key": "squid:S2077",
@@ -566,7 +566,7 @@ exports[`should render correctly: deleted assignee 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"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": "This a strong message about fixing !
",
"key": "squid:S2077",
@@ -648,7 +648,7 @@ exports[`should render correctly: deleted assignee 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"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.
This a strong message about fixing !",
+ "key": "squid:S2077",
+ "name": "That rule",
+ "riskDescription": "This a strong message about risk !
",
+ "securityCategory": "sql-injection",
+ "vulnerabilityDescription": "This a strong message about vulnerability !
",
+ "vulnerabilityProbability": "HIGH",
+ },
+ "status": "REVIEWED",
+ "textRange": Object {
+ "endLine": 142,
+ "endOffset": 83,
+ "startLine": 142,
+ "startOffset": 26,
+ },
+ "updateDate": "2013-05-13T17:55:42+0200",
+ }
+ }
onSubmit={[MockFunction]}
/>
@@ -715,7 +793,7 @@ exports[`should render correctly: user logged in 1`] = `
- issue.status.RESOLVED
+ hotspot.status.FIXED
This a strong message about fixing !
",
"key": "squid:S2077",
@@ -799,7 +877,7 @@ exports[`should render correctly: user logged in 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"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": "This a strong message about fixing !
",
"key": "squid:S2077",
@@ -881,7 +959,7 @@ exports[`should render correctly: user logged in 1`] = `
"vulnerabilityDescription": "This a strong message about vulnerability !
",
"vulnerabilityProbability": "HIGH",
},
- "status": "RESOLVED",
+ "status": "REVIEWED",
"textRange": Object {
"endLine": 142,
"endOffset": 83,
diff --git a/server/sonar-web/src/main/js/helpers/mocks/security-hotspots.ts b/server/sonar-web/src/main/js/helpers/mocks/security-hotspots.ts
index 58ebfcbe365..a0633c1892e 100644
--- a/server/sonar-web/src/main/js/helpers/mocks/security-hotspots.ts
+++ b/server/sonar-web/src/main/js/helpers/mocks/security-hotspots.ts
@@ -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): 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,