]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-14462 Do not display the branch name until the main branch is analyzed for...
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Wed, 17 Feb 2021 14:51:17 +0000 (15:51 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 19 Feb 2021 20:07:20 +0000 (20:07 +0000)
server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx
server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/BranchLikeNavigation-test.tsx
server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap

index 72729ff47ce200402020badf098bba3730a628fc..cafece6895c2e70c6082a165218c3dbd1caa3383 100644 (file)
@@ -57,6 +57,11 @@ export function BranchLikeNavigation(props: BranchLikeNavigationProps) {
     />
   );
 
+  // Main branch hasn't been analyzed yet && (CE || (DE+ && only one branch))
+  if (!component.analysisDate && (!branchesEnabled || !hasManyBranches)) {
+    return null;
+  }
+
   return (
     <span
       className={classNames('big-spacer-left flex-0 branch-like-navigation-toggler-container', {
index c0b34d01686fd267655f00752d81fea7a1aa0345..ff00b6d76246c7b2eedecfdb08d7168b1c38be17 100644 (file)
@@ -30,6 +30,23 @@ it('should render correctly', () => {
   expect(wrapper).toMatchSnapshot();
 });
 
+it('should not render', () => {
+  // CE && main branch not analyzed yet
+  const wrapper = shallowRender({
+    appState: mockAppState({ branchesEnabled: false }),
+    component: mockComponent({ analysisDate: undefined })
+  });
+  expect(wrapper.type()).toBeNull();
+
+  // DE+ && main branch not analyzed yet && no other branches
+  const wrapper1 = shallowRender({
+    appState: mockAppState({ branchesEnabled: true }),
+    component: mockComponent({ analysisDate: undefined }),
+    branchLikes: []
+  });
+  expect(wrapper1.type()).toBeNull();
+});
+
 it('should render the menu trigger if branches are enabled', () => {
   const wrapper = shallowRender({ appState: mockAppState({ branchesEnabled: true }) });
   expect(wrapper).toMatchSnapshot();
@@ -67,7 +84,7 @@ function shallowRender(props?: Partial<BranchLikeNavigationProps>) {
     <BranchLikeNavigation
       appState={mockAppState()}
       branchLikes={branchLikes}
-      component={mockComponent()}
+      component={mockComponent({ analysisDate: '2021-01-01 01:01:01' })}
       currentBranchLike={branchLikes[0]}
       {...props}
     />
index 9a956e3303cec7b161d2a8161df95d61463d6edd..5e1897ca5c10684f5d98bd4a9bd552496148d52f 100644 (file)
@@ -8,6 +8,7 @@ exports[`should render correctly 1`] = `
     branchesEnabled={false}
     component={
       Object {
+        "analysisDate": "2021-01-01 01:01:01",
         "breadcrumbs": Array [],
         "key": "my-project",
         "name": "MyProject",
@@ -117,6 +118,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
         }
         component={
           Object {
+            "analysisDate": "2021-01-01 01:01:01",
             "breadcrumbs": Array [],
             "key": "my-project",
             "name": "MyProject",
@@ -158,6 +160,7 @@ exports[`should render the menu trigger if branches are enabled 1`] = `
         branchesEnabled={true}
         component={
           Object {
+            "analysisDate": "2021-01-01 01:01:01",
             "breadcrumbs": Array [],
             "key": "my-project",
             "name": "MyProject",