From 052a4458e6225349fedb8a6ebd03347cd12a4753 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Thu, 31 Mar 2022 17:04:46 +0200 Subject: [PATCH] SONAR-16157 Avoid duplicate primary location --- .../js/components/SourceViewer/components/LineCode.tsx | 2 +- .../SourceViewer/components/__tests__/LineCode-test.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx index 17fe386ae95..a6dc9efcd28 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCode.tsx @@ -246,7 +246,7 @@ export default class LineCode extends React.PureComponent { selectedIssue={selectedIssue} /> )} - {selectedIssue && !showIssues && ( + {selectedIssue && !showIssues && issueLocations.length > 0 && ( { 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 = {}) { return shallow(