From fa9d4c659b1ecfcc3cb7b76994282230babcd3e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 29 May 2018 14:53:51 +0200 Subject: [PATCH] SONAR-10571 Always display failed background task notif on all branches --- .../src/main/js/app/components/ComponentContainer.tsx | 8 +++++++- .../app/components/__tests__/ComponentContainer-test.tsx | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx index 27165885dc5..11d254b4ada 100644 --- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx @@ -146,7 +146,13 @@ export class ComponentContainer extends React.PureComponent { 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) => { diff --git a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx index 1611daa5d00..eda3927faf1 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx @@ -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); -- 2.39.5