]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10571 Always display failed background task notif on all branches
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 29 May 2018 12:53:51 +0000 (14:53 +0200)
committerSonarTech <sonartech@sonarsource.com>
Fri, 1 Jun 2018 18:20:47 +0000 (20:20 +0200)
server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx

index 27165885dc5a3dc2e423948057f9c20e221fd1cb..11d254b4ada6eaaaf46a7dbd2dcd019136db612b 100644 (file)
@@ -146,7 +146,13 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
 
   getCurrentTask = (branchLike?: BranchLike) => {
     const { currentTask } = this.state;
-    return currentTask && this.isSameBranch(currentTask, branchLike) ? currentTask : undefined;
+    if (!currentTask) {
+      return undefined;
+    }
+
+    return currentTask.status === STATUSES.FAILED || this.isSameBranch(currentTask, branchLike)
+      ? currentTask
+      : undefined;
   };
 
   getPendingTasks = (branchLike?: BranchLike) => {
index 1611daa5d00ac8553a31a887dc9d3ff44ace1d6b..eda3927faf18ff2787eac94b33f34675065cdf83 100644 (file)
@@ -31,6 +31,7 @@ import {
   PullRequest,
   BranchType
 } from '../../types';
+import { STATUSES } from '../../../apps/background-tasks/constants';
 
 jest.mock('../../../api/branches', () => ({
   getBranches: jest.fn(() => Promise.resolve([])),
@@ -221,13 +222,16 @@ it('filters correctly the pending tasks for a main branch', () => {
   ).toBeFalsy();
   expect(component.isSameBranch({ pullRequest: 'pr-89' }, pullRequest)).toBeTruthy();
 
-  const currentTask = { pullRequest: 'pr-89' } as Task;
+  const currentTask = { pullRequest: 'pr-89', status: STATUSES.IN_PROGRESS } as Task;
+  const failedTask = { ...currentTask, status: STATUSES.FAILED };
   const pendingTasks = [
     currentTask,
     { branch: 'feature', branchType: 'SHORT' } as Task,
     {} as Task
   ];
   expect(component.getCurrentTask(undefined)).toBe(undefined);
+  component.setState({ currentTask: failedTask });
+  expect(component.getCurrentTask(mainBranch)).toBe(failedTask);
   component.setState({ currentTask });
   expect(component.getCurrentTask(mainBranch)).toBe(undefined);
   expect(component.getCurrentTask(pullRequest)).toMatchObject(currentTask);