diff --git a/src/layouts/BaseLayout/BaseLayout.jsx b/src/layouts/BaseLayout/BaseLayout.jsx index 3bd9148605..c59479389f 100644 --- a/src/layouts/BaseLayout/BaseLayout.jsx +++ b/src/layouts/BaseLayout/BaseLayout.jsx @@ -15,7 +15,6 @@ import SessionExpiryTracker from 'ui/SessionExpiryTracker' import { useUserAccessGate } from './hooks/useUserAccessGate' -const LimitedHeader = lazy(() => import('layouts/LimitedHeader')) const DefaultOrgSelector = lazy(() => import('pages/DefaultOrgSelector')) const InstallationHelpBanner = lazy(() => import('./InstallationHelpBanner')) const TermsOfService = lazy(() => import('pages/TermsOfService')) @@ -77,7 +76,6 @@ function BaseLayout({ children }) { ) : ( - {showDefaultOrgSelector && } )} diff --git a/src/layouts/LimitedHeader/LimitedHeader.jsx b/src/layouts/LimitedHeader/LimitedHeader.jsx deleted file mode 100644 index f399e14b15..0000000000 --- a/src/layouts/LimitedHeader/LimitedHeader.jsx +++ /dev/null @@ -1,42 +0,0 @@ -import cs from 'classnames' - -import { CodecovIcon } from 'assets/svg/codecov' -import { useImpersonate } from 'services/impersonate' -import { useUser } from 'services/user' -import A from 'ui/A' -import Avatar from 'ui/Avatar' - -export default function LimitedHeader() { - const { isImpersonating } = useImpersonate() - const { data: currentUser, isLoading } = useUser() - const defaultOrg = - currentUser?.owner?.defaultOrgUsername ?? currentUser?.user?.username - - return ( -
- -
- ) -} diff --git a/src/layouts/LimitedHeader/LimitedHeader.spec.jsx b/src/layouts/LimitedHeader/LimitedHeader.spec.jsx deleted file mode 100644 index 7620a84d9c..0000000000 --- a/src/layouts/LimitedHeader/LimitedHeader.spec.jsx +++ /dev/null @@ -1,127 +0,0 @@ -import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import { render, screen } from '@testing-library/react' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' -import { MemoryRouter, Route } from 'react-router-dom' - -import { useImage } from 'services/image' -import { useImpersonate } from 'services/impersonate' - -import LimitedHeader from './LimitedHeader' - -jest.mock('services/image') -jest.mock('services/impersonate') - -const user = { - username: 'CodecovUser', - email: 'codecov@codecov.io', - name: 'codecov', - avatarUrl: 'http://127.0.0.1/avatar-url', - onboardingCompleted: false, -} - -const queryClient = new QueryClient({ - defaultOptions: { - queries: { - retry: false, - }, - }, -}) -const server = setupServer() - -const wrapper = - (initialEntries = ['/bb/batman/batcave']) => - ({ children }) => - ( - - - {children} - - - ) - -beforeAll(() => { - server.listen({ onUnhandledRequest: 'warn' }) -}) -afterEach(() => { - queryClient.clear() - server.resetHandlers() -}) -afterAll(() => server.close()) - -describe('LimitedLayout', () => { - afterEach(() => jest.resetAllMocks()) - - function setup({ isImpersonating = false } = { isImpersonating: false }) { - useImage.mockReturnValue({ src: 'photo', isLoading: false, error: null }) - useImpersonate.mockReturnValue({ isImpersonating }) - - server.use( - graphql.query('CurrentUser', (_, res, ctx) => - res( - ctx.status(200), - ctx.data({ - me: { user: user, trackingMetadata: { ownerid: 123 }, ...user }, - }) - ) - ) - ) - } - - describe('renders', () => { - beforeEach(() => setup()) - - it('a regular header', async () => { - render(, { - wrapper: wrapper(), - }) - - const regularHeader = await screen.findByTestId('header') - expect(regularHeader).toHaveClass('bg-ds-gray-octonary') - }) - - it('a user avatar', async () => { - render(, { - wrapper: wrapper(), - }) - - const avatar = await screen.findByRole('img', { name: 'avatar' }) - expect(avatar).toBeInTheDocument() - }) - }) - - describe('renders while impersonated', () => { - beforeEach(() => setup({ isImpersonating: true })) - - it('a pink header', async () => { - render(, { - wrapper: wrapper(), - }) - - const pinkHeader = await screen.findByTestId('header') - expect(pinkHeader).toHaveClass('bg-ds-pink-tertiary') - }) - }) - - describe('Avatar render logic', () => { - beforeEach(() => setup()) - - it(`isn't rendered on first render`, () => { - render(, { - wrapper: wrapper(), - }) - - const avatar = screen.queryByRole('img', { name: 'avatar' }) - expect(avatar).not.toBeInTheDocument() - }) - - it('is rendered once useUser settles', async () => { - render(, { - wrapper: wrapper(), - }) - - const avatar = await screen.findByRole('img', { name: 'avatar' }) - expect(avatar).toBeInTheDocument() - }) - }) -}) diff --git a/src/layouts/LimitedHeader/index.js b/src/layouts/LimitedHeader/index.js deleted file mode 100644 index 29cada709d..0000000000 --- a/src/layouts/LimitedHeader/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './LimitedHeader'