aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-04-12 15:56:29 +0200
committerSonarTech <sonartech@sonarsource.com>2018-04-16 20:20:47 +0200
commit2c36adcf2180253e3cd6832d6fb454e580a42cd2 (patch)
treeb8ae45d97bc1614c140ec1344677108156a67d41 /server/sonar-web/src/main/js/apps
parentee0cd4ea0df3e71d1fceced8255ce5a01c98cc4e (diff)
downloadsonarqube-2c36adcf2180253e3cd6832d6fb454e580a42cd2.tar.gz
sonarqube-2c36adcf2180253e3cd6832d6fb454e580a42cd2.zip
SONAR-10572 Fix wrong link for branches in background tasks
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/TaskComponent.tsx13
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/TaskComponent-test.tsx38
-rw-r--r--server/sonar-web/src/main/js/apps/background-tasks/components/__tests__/__snapshots__/TaskComponent-test.tsx.snap112
3 files changed, 133 insertions, 30 deletions
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(<TaskComponent task={task} />)).toMatchSnapshot();
- expect(shallow(<TaskComponent task={{ ...task, componentKey: undefined }} />)).toMatchSnapshot();
- expect(shallow(<TaskComponent task={{ ...task, branch: 'feature' }} />)).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(<TaskComponent task={TASK} />)).toMatchSnapshot();
+ expect(shallow(<TaskComponent task={{ ...TASK, componentKey: undefined }} />)).toMatchSnapshot();
+});
+
+it('renders correctly for branches and pullrequest', () => {
+ expect(
+ shallow(<TaskComponent task={{ ...TASK, branch: 'feature', branchType: 'SHORT' }} />)
+ ).toMatchSnapshot();
+ expect(
+ shallow(<TaskComponent task={{ ...TASK, branch: 'branch-6.7', branchType: 'LONG' }} />)
+ ).toMatchSnapshot();
+ expect(shallow(<TaskComponent task={{ ...TASK, pullRequest: 'pr-89' }} />)).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`] = `
<td>
<span
className="little-spacer-right"
@@ -33,7 +33,7 @@ exports[`renders 1`] = `
</td>
`;
-exports[`renders 2`] = `
+exports[`renders correctly 2`] = `
<td>
<span
className="note"
@@ -46,15 +46,11 @@ exports[`renders 2`] = `
</td>
`;
-exports[`renders 3`] = `
+exports[`renders correctly for branches and pullrequest 1`] = `
<td>
- <span
+ <ShortLivingBranchIcon
className="little-spacer-right"
- >
- <QualifierIcon
- qualifier="TRK"
- />
- </span>
+ />
<Connect(Organization)
organizationKey="org"
/>
@@ -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`] = `
/>
</td>
`;
+
+exports[`renders correctly for branches and pullrequest 2`] = `
+<td>
+ <LongLivingBranchIcon
+ className="little-spacer-right"
+ />
+ <Connect(Organization)
+ organizationKey="org"
+ />
+ <Link
+ className="spacer-right"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/dashboard",
+ "query": Object {
+ "branch": "branch-6.7",
+ "id": "foo",
+ },
+ }
+ }
+ >
+ foo
+ <span
+ className="text-limited text-text-top"
+ title="branch-6.7"
+ >
+ <span
+ style={
+ Object {
+ "marginLeft": 5,
+ "marginRight": 5,
+ }
+ }
+ >
+ /
+ </span>
+ branch-6.7
+ </span>
+ </Link>
+ <TaskType
+ type="REPORT"
+ />
+</td>
+`;
+
+exports[`renders correctly for branches and pullrequest 3`] = `
+<td>
+ <PullRequestIcon
+ className="little-spacer-right"
+ />
+ <Connect(Organization)
+ organizationKey="org"
+ />
+ <Link
+ className="spacer-right"
+ onlyActiveOnIndex={false}
+ style={Object {}}
+ to={
+ Object {
+ "pathname": "/project/issues",
+ "query": Object {
+ "id": "foo",
+ "pullRequest": "pr-89",
+ "resolved": "false",
+ },
+ }
+ }
+ >
+ foo
+ <Tooltip>
+ <span
+ className="text-limited text-text-top"
+ >
+ <span
+ style={
+ Object {
+ "marginLeft": 5,
+ "marginRight": 5,
+ }
+ }
+ >
+ /
+ </span>
+ pr-89
+ </span>
+ </Tooltip>
+ </Link>
+ <TaskType
+ type="REPORT"
+ />
+</td>
+`;