From 67d195c19a9b970b6c38d33c1a524409684b549f Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Wed, 17 Feb 2021 15:51:17 +0100 Subject: [PATCH] SONAR-14462 Do not display the branch name until the main branch is analyzed for the first time --- .../branch-like/BranchLikeNavigation.tsx | 5 +++++ .../__tests__/BranchLikeNavigation-test.tsx | 19 ++++++++++++++++++- .../BranchLikeNavigation-test.tsx.snap | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx index 72729ff47ce..cafece6895c 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/BranchLikeNavigation.tsx @@ -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 ( { 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) { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap index 9a956e3303c..5e1897ca5c1 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/branch-like/__tests__/__snapshots__/BranchLikeNavigation-test.tsx.snap @@ -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", -- 2.39.5