aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2020-09-03 14:50:59 +0200
committersonartech <sonartech@sonarsource.com>2020-09-04 20:07:08 +0000
commit88e87020615f59ceed877b2fce817689613dcd5d (patch)
tree6fb4f27042aa35412f61200c0d79e3deb1aab16b
parentacf7f310de7da60647b305fa7a7956c1064269c4 (diff)
downloadsonarqube-88e87020615f59ceed877b2fce817689613dcd5d.tar.gz
sonarqube-88e87020615f59ceed877b2fce817689613dcd5d.zip
SONAR-13847 Fix overview auto-refresh
-rw-r--r--server/sonar-web/src/main/js/app/components/ComponentContainer.tsx5
-rw-r--r--server/sonar-web/src/main/js/app/components/__tests__/ComponentContainer-test.tsx7
2 files changed, 7 insertions, 5 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 f00a0568426..82d48a415ba 100644
--- a/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
+++ b/server/sonar-web/src/main/js/app/components/ComponentContainer.tsx
@@ -269,7 +269,10 @@ export class ComponentContainer extends React.PureComponent<Props, State> {
};
isSameBranch = (task: Pick<T.Task, 'branch' | 'pullRequest'>, branchLike?: BranchLike) => {
- if (branchLike && !isMainBranch(branchLike)) {
+ if (branchLike) {
+ if (isMainBranch(branchLike)) {
+ return (!task.pullRequest && !task.branch) || branchLike.name === task.branch;
+ }
if (isPullRequest(branchLike)) {
return branchLike.key === task.pullRequest;
}
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 118cb162e87..d96dc9a6d24 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
@@ -71,8 +71,6 @@ jest.mock('../nav/component/ComponentNav', () => ({
const Inner = () => <div />;
-const mainBranch = mockMainBranch();
-
beforeEach(() => {
jest.clearAllMocks();
});
@@ -107,7 +105,7 @@ it('updates branches on change', async () => {
registerBranchStatus
});
wrapper.setState({
- branchLikes: [mainBranch],
+ branchLikes: [mockMainBranch()],
component: mockComponent({
breadcrumbs: [{ key: 'projectKey', name: 'project', qualifier: 'TRK' }]
}),
@@ -138,8 +136,9 @@ it('filters correctly the pending tasks for a main branch', () => {
const branch2 = mockBranch({ name: 'branch-2' });
const pullRequest = mockPullRequest();
- expect(component.isSameBranch({}, undefined)).toBe(true);
+ expect(component.isSameBranch({} /*, undefined*/)).toBe(true);
expect(component.isSameBranch({}, mainBranch)).toBe(true);
+ expect(component.isSameBranch({ branch: mainBranch.name }, mainBranch)).toBe(true);
expect(component.isSameBranch({}, branch3)).toBe(false);
expect(component.isSameBranch({ branch: branch3.name }, branch3)).toBe(true);
expect(component.isSameBranch({ branch: 'feature' }, branch2)).toBe(false);