aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMathieu Suen <mathieu.suen@sonarsource.com>2022-09-16 11:48:54 +0200
committersonartech <sonartech@sonarsource.com>2022-09-19 20:03:08 +0000
commit122dcac72d7888057b3a7257fd4be18fc97b4179 (patch)
treee78cba11b39de8050685407d6f50defcce5e1a63 /server
parent50df88fef4dacda98a32e96ecc7e71cbf907d297 (diff)
downloadsonarqube-122dcac72d7888057b3a7257fd4be18fc97b4179.tar.gz
sonarqube-122dcac72d7888057b3a7257fd4be18fc97b4179.zip
SONAR-17332 Always display primary location lines
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx13
2 files changed, 10 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx
index a8553151e0f..aab3d99b77c 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/ComponentSourceSnippetGroupViewer.tsx
@@ -106,7 +106,9 @@ export default class ComponentSourceSnippetGroupViewer extends React.PureCompone
component: snippetGroup.component.key,
issue,
locations:
- snippetGroup.locations.length === 0 ? [getPrimaryLocation(issue)] : snippetGroup.locations
+ snippetGroup.locations.length === 0
+ ? [getPrimaryLocation(issue)]
+ : [getPrimaryLocation(issue), ...snippetGroup.locations]
});
this.setState({ snippets });
diff --git a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx
index 260173f7191..ca406031813 100644
--- a/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/crossComponentSourceViewer/__tests__/ComponentSourceSnippetGroupViewer-test.tsx
@@ -74,8 +74,8 @@ it('should render correctly with secondary locations', () => {
const wrapper = shallowRender({ issue, snippetGroup });
expect(wrapper.state('snippets')).toHaveLength(3);
expect(wrapper.state('snippets')[0]).toEqual({ index: 0, start: 2, end: 16 });
- expect(wrapper.state('snippets')[1]).toEqual({ index: 1, start: 29, end: 39 });
- expect(wrapper.state('snippets')[2]).toEqual({ index: 2, start: 69, end: 79 });
+ expect(wrapper.state('snippets')[1]).toEqual({ index: 2, start: 29, end: 39 });
+ expect(wrapper.state('snippets')[2]).toEqual({ index: 3, start: 69, end: 79 });
});
it('should render correctly with flows', () => {
@@ -104,9 +104,10 @@ it('should render correctly with flows', () => {
])
};
const wrapper = shallowRender({ issue, snippetGroup });
- expect(wrapper.state('snippets')).toHaveLength(2);
- expect(wrapper.state('snippets')[0]).toEqual({ index: 0, start: 29, end: 39 });
- expect(wrapper.state('snippets')[1]).toEqual({ index: 1, start: 69, end: 79 });
+ expect(wrapper.state('snippets')).toHaveLength(3);
+ expect(wrapper.state('snippets')[0]).toEqual({ index: 0, start: 2, end: 16 });
+ expect(wrapper.state('snippets')[1]).toEqual({ index: 1, start: 29, end: 39 });
+ expect(wrapper.state('snippets')[2]).toEqual({ index: 2, start: 69, end: 79 });
// Check that locationsByLine is defined when isLastOccurenceOfPrimaryComponent
expect(
@@ -237,7 +238,7 @@ it('should get the right branch when expanding', async () => {
wrapper.instance().expandBlock(0, 'down');
await waitAndUpdate(wrapper);
- expect(getSources).toHaveBeenCalledWith({ branch: 'asdf', from: 8, key: 'project:a', to: 67 });
+ expect(getSources).toHaveBeenCalledWith({ branch: 'asdf', from: 36, key: 'project:a', to: 95 });
});
it('should handle symbol highlighting', () => {