From: Grégoire Aubert Date: Thu, 12 Apr 2018 13:56:29 +0000 (+0200) Subject: SONAR-10572 Fix wrong link for branches in background tasks X-Git-Tag: 7.5~1358 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2c36adcf2180253e3cd6832d6fb454e580a42cd2;p=sonarqube.git SONAR-10572 Fix wrong link for branches in background tasks --- diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx index a81919215b1..7d57ddf1205 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx @@ -92,13 +92,14 @@ export default function TaskComponent({ task }: Props) { } function getTaskComponentUrl(componentKey: string, task: Task) { - if (task.branch && task.branchType === 'SHORT') { - return getShortLivingBranchUrl(componentKey, task.branchType); - } else if (task.branchType && task.branchType === 'LONG') { - return getLongLivingBranchUrl(componentKey, task.branchType); + if (task.branch) { + if (task.branchType === 'SHORT') { + return getShortLivingBranchUrl(componentKey, task.branch); + } else if (task.branchType === 'LONG') { + return getLongLivingBranchUrl(componentKey, task.branch); + } } else if (task.pullRequest) { return getPullRequestUrl(componentKey, task.pullRequest); - } else { - return getProjectUrl(componentKey); } + return getProjectUrl(componentKey); } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx index 7518c51dc30..ad89c600812 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx @@ -21,18 +21,28 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import TaskComponent from '../TaskComponent'; -it('renders', () => { - const task = { - componentKey: 'foo', - componentName: 'foo', - componentQualifier: 'TRK', - id: 'bar', - organization: 'org', - status: 'PENDING', - submittedAt: '2017-01-01', - type: 'REPORT' - }; - expect(shallow()).toMatchSnapshot(); - expect(shallow()).toMatchSnapshot(); - expect(shallow()).toMatchSnapshot(); +const TASK = { + componentKey: 'foo', + componentName: 'foo', + componentQualifier: 'TRK', + id: 'bar', + organization: 'org', + status: 'PENDING', + submittedAt: '2017-01-01', + type: 'REPORT' +}; + +it('renders correctly', () => { + expect(shallow()).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); +}); + +it('renders correctly for branches and pullrequest', () => { + expect( + shallow() + ).toMatchSnapshot(); + expect( + shallow() + ).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap index f71a484187b..d1f54e342f5 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders 1`] = ` +exports[`renders correctly 1`] = ` `; -exports[`renders 2`] = ` +exports[`renders correctly 2`] = ` `; -exports[`renders 3`] = ` +exports[`renders correctly for branches and pullrequest 1`] = ` - - - + /> @@ -64,9 +60,11 @@ exports[`renders 3`] = ` style={Object {}} to={ Object { - "pathname": "/dashboard", + "pathname": "/project/issues", "query": Object { + "branch": "feature", "id": "foo", + "resolved": "false", }, } } @@ -94,3 +92,97 @@ exports[`renders 3`] = ` /> `; + +exports[`renders correctly for branches and pullrequest 2`] = ` + + + + + foo + + + / + + branch-6.7 + + + + +`; + +exports[`renders correctly for branches and pullrequest 3`] = ` + + + + + foo + + + + / + + pr-89 + + + + + +`;