]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16157 Avoid duplicate primary location
authorMathieu Suen <mathieu.suen@sonarsource.com>
Thu, 31 Mar 2022 15:04:46 +0000 (17:04 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 5 Apr 2022 20:03:16 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx
server/sonar-web/src/main/js/components/SourceViewer/components/__tests__/LineCode-test.tsx

index 17fe386ae950c515a73bb85fb10ca66b7671ac90..a6dc9efcd2878d2702ae185558d8724ad5af59f9 100644 (file)
@@ -246,7 +246,7 @@ export default class LineCode extends React.PureComponent<Props, State> {
             selectedIssue={selectedIssue}
           />
         )}
-        {selectedIssue && !showIssues && (
+        {selectedIssue && !showIssues && issueLocations.length > 0 && (
           <LineIssuesList
             branchLike={this.props.branchLike}
             issuePopup={this.props.issuePopup}
index 92ee72265e23e2cd2a41cf14dba40b880eee3c18..616878e5037c47d30b746b204e56aed7f81e8abb 100644 (file)
@@ -22,6 +22,7 @@ import * as React from 'react';
 import { mockBranch } from '../../../../helpers/mocks/branch-like';
 import { mockIssue, mockSourceLine } from '../../../../helpers/testMocks';
 import LineCode from '../LineCode';
+import LineIssuesList from '../LineIssuesList';
 
 it('render code', () => {
   expect(shallowRender()).toMatchSnapshot();
@@ -37,6 +38,12 @@ it('render code', () => {
   ).toMatchSnapshot('with secondary location');
 });
 
+it('should not render issue list when no issue location', () => {
+  const wrapper = shallowRender({ issueLocations: [], showIssues: false });
+
+  expect(wrapper.find(LineIssuesList).length).toBe(0);
+});
+
 function shallowRender(props: Partial<LineCode['props']> = {}) {
   return shallow(
     <LineCode