From 721a639e4f6830458a25b725e2dbfd904c8e7d02 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 25 Nov 2024 12:15:10 -0400 Subject: [PATCH 01/22] fix: Hide navigator on sync page (#3504) --- src/layouts/Header/Header.test.tsx | 56 +++++++++++++++++++----------- src/layouts/Header/Header.tsx | 10 ++++-- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/layouts/Header/Header.test.tsx b/src/layouts/Header/Header.test.tsx index 2338e878eb..3c7750e6b8 100644 --- a/src/layouts/Header/Header.test.tsx +++ b/src/layouts/Header/Header.test.tsx @@ -99,13 +99,19 @@ afterAll(() => { server.close() }) -const wrapper: React.FC = ({ children }) => ( - - - {children} - - -) +const wrapper = + ( + initialEntries = '/gh/codecov/test-repo' + ): React.FC => + ({ children }) => ( + + + + {children} + + + + ) type SetupArgs = { user?: User @@ -125,7 +131,7 @@ describe('Header', () => { it('shows impersonating banner', async () => { setup({}) mockedUseImpersonate.mockReturnValue({ isImpersonating: true }) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const impersonatingBanner = await screen.findByText('Impersonating') expect(impersonatingBanner).toBeInTheDocument() @@ -134,7 +140,7 @@ describe('Header', () => { describe('when are not logged in', () => { it('shows guest header', async () => { setup({ user: mockNullUser }) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const guestHeader = await screen.findByText('Why Test Code?') expect(guestHeader).toBeInTheDocument() @@ -142,7 +148,7 @@ describe('Header', () => { it('shows navigator', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const navigator = await screen.findByText('Navigator') expect(navigator).toBeInTheDocument() @@ -150,7 +156,7 @@ describe('Header', () => { it('does not show user/help dropdowns', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const userDropdown = screen.queryByText('User Dropdown') expect(userDropdown).not.toBeInTheDocument() @@ -162,7 +168,7 @@ describe('Header', () => { describe('when logged in', () => { it('shows navigator', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const navigator = await screen.findByText('Navigator') expect(navigator).toBeInTheDocument() @@ -170,7 +176,7 @@ describe('Header', () => { it('shows help dropdown', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const helpDropdown = await screen.findByText(/Help Dropdown/) expect(helpDropdown).toBeInTheDocument() @@ -178,7 +184,7 @@ describe('Header', () => { it('shows user dropdown', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const userDropdown = await screen.findByText(/User Dropdown/) expect(userDropdown).toBeInTheDocument() @@ -186,7 +192,7 @@ describe('Header', () => { it('has toggle for light/dark mode', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const toggle = await screen.findByText(/Theme Toggle/) expect(toggle).toBeInTheDocument() @@ -198,7 +204,7 @@ describe('Header', () => { it('shows guest header', async () => { config.IS_SELF_HOSTED = true setup({ user: mockNullUser }) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const guestHeader = await screen.findByText('Why Test Code?') expect(guestHeader).toBeInTheDocument() @@ -206,7 +212,7 @@ describe('Header', () => { it('shows navigator', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const navigator = await screen.findByText('Navigator') expect(navigator).toBeInTheDocument() @@ -214,7 +220,7 @@ describe('Header', () => { it('does not show user/help dropdowns', async () => { setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const userDropdown = screen.queryByText('User Dropdown') expect(userDropdown).not.toBeInTheDocument() @@ -227,7 +233,7 @@ describe('Header', () => { it('shows seat details', async () => { config.IS_SELF_HOSTED = true setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const text = await screen.findByText(/Seat Details/) expect(text).toBeInTheDocument() @@ -236,11 +242,21 @@ describe('Header', () => { it('shows Admin link', async () => { config.IS_SELF_HOSTED = true setup({}) - render(
, { wrapper }) + render(
, { wrapper: wrapper() }) const text = await screen.findByText(/Admin Link/) expect(text).toBeInTheDocument() }) }) }) + + describe('when on sync page', () => { + it('does not show navigator', async () => { + setup({}) + render(
, { wrapper: wrapper('/sync') }) + + const navigator = screen.queryByText('Navigator') + expect(navigator).not.toBeInTheDocument() + }) + }) }) diff --git a/src/layouts/Header/Header.tsx b/src/layouts/Header/Header.tsx index 92d736f474..f76467f6ca 100644 --- a/src/layouts/Header/Header.tsx +++ b/src/layouts/Header/Header.tsx @@ -1,4 +1,5 @@ import { Suspense } from 'react' +import { useRouteMatch } from 'react-router-dom' import config from 'config' @@ -16,6 +17,7 @@ import UserDropdown from './components/UserDropdown' function Header() { const { isImpersonating } = useImpersonate() const { data: currentUser } = useUser() + const syncPageMatch = useRouteMatch('/sync') return (
@@ -26,9 +28,11 @@ function Header() { ) : null}