-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into branch-selector-components
- Loading branch information
Showing
30 changed files
with
784 additions
and
325 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/layouts/EnterpriseLoginLayout/EnterpriseLoginLayout.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { render, screen } from '@testing-library/react' | ||
import { MemoryRouter, Route } from 'react-router-dom' | ||
|
||
import EnterpriseLoginLayout from './EnterpriseLoginLayout' | ||
|
||
jest.mock('./Header', () => () => 'Header') | ||
jest.mock('layouts/Footer', () => () => 'Footer') | ||
jest.mock('shared/GlobalBanners', () => () => 'GlobalBanners') | ||
jest.mock('layouts/ToastNotifications', () => () => 'ToastNotifications') | ||
jest.mock('ui/SessionExpiryTracker', () => () => 'SessionExpiryTracker') | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: false, | ||
}, | ||
}, | ||
}) | ||
|
||
const wrapper = ({ children }: { children: React.ReactNode }) => ( | ||
<QueryClientProvider client={queryClient}> | ||
<MemoryRouter initialEntries={['/']}> | ||
<Route path="/"> | ||
<EnterpriseLoginLayout>{children}</EnterpriseLoginLayout> | ||
</Route> | ||
</MemoryRouter> | ||
</QueryClientProvider> | ||
) | ||
|
||
describe('EnterpriseLoginLayout', () => { | ||
it('renders children', () => { | ||
render(<>children</>, { wrapper }) | ||
|
||
const children = screen.getByText(/children/) | ||
expect(children).toBeInTheDocument() | ||
}) | ||
|
||
it('renders global banners', () => { | ||
render(<>children</>, { wrapper }) | ||
|
||
const globalBanners = screen.getByText(/GlobalBanners/) | ||
expect(globalBanners).toBeInTheDocument() | ||
}) | ||
|
||
it('renders the header', () => { | ||
render(<>children</>, { wrapper }) | ||
|
||
const header = screen.getByText(/Header/) | ||
expect(header).toBeInTheDocument() | ||
}) | ||
|
||
it('renders the footer', () => { | ||
render(<>children</>, { wrapper }) | ||
|
||
const footer = screen.getByText(/Footer/) | ||
expect(footer).toBeInTheDocument() | ||
}) | ||
|
||
it('renders toast notifications', () => { | ||
render(<>children</>, { wrapper }) | ||
|
||
const ToastNotifications = screen.getByText(/ToastNotifications/) | ||
expect(ToastNotifications).toBeInTheDocument() | ||
}) | ||
|
||
it('renders the session expiry tracker if no tracking session found', () => { | ||
render(<>children</>, { wrapper }) | ||
|
||
const session = screen.getByText(/SessionExpiryTracker/) | ||
expect(session).toBeInTheDocument() | ||
}) | ||
|
||
it('does not render the session expiry tracker if tracking session found', () => { | ||
localStorage.setItem('tracking-session-expiry', 'true') | ||
|
||
render(<>children</>, { wrapper }) | ||
|
||
const session = screen.queryByText(/SessionExpiryTracker/) | ||
expect(session).not.toBeInTheDocument() | ||
}) | ||
}) |
45 changes: 45 additions & 0 deletions
45
src/layouts/EnterpriseLoginLayout/EnterpriseLoginLayout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Suspense } from 'react' | ||
|
||
import Footer from 'layouts/Footer' | ||
import ErrorBoundary from 'layouts/shared/ErrorBoundary' | ||
import NetworkErrorBoundary from 'layouts/shared/NetworkErrorBoundary' | ||
import ToastNotifications from 'layouts/ToastNotifications' | ||
import GlobalBanners from 'shared/GlobalBanners' | ||
import LoadingLogo from 'ui/LoadingLogo' | ||
import SessionExpiryTracker from 'ui/SessionExpiryTracker' | ||
|
||
import Header from './Header' | ||
|
||
const LOCAL_STORAGE_SESSION_TRACKING_KEY = 'tracking-session-expiry' | ||
|
||
const FullPageLoader = () => ( | ||
<div className="mt-16 flex flex-1 items-center justify-center"> | ||
<LoadingLogo /> | ||
</div> | ||
) | ||
|
||
function EnterpriseLoginLayout({ children }: { children: React.ReactNode }) { | ||
const isTrackingSession = localStorage.getItem( | ||
LOCAL_STORAGE_SESSION_TRACKING_KEY | ||
) | ||
return ( | ||
<> | ||
<Header /> | ||
{!isTrackingSession && <SessionExpiryTracker />} | ||
<Suspense fallback={<FullPageLoader />}> | ||
<ErrorBoundary sentryScopes={[['layout', 'base']]}> | ||
<NetworkErrorBoundary> | ||
<main className="container mb-8 mt-2 flex grow flex-col gap-2 md:p-0"> | ||
<GlobalBanners /> | ||
{children} | ||
</main> | ||
</NetworkErrorBoundary> | ||
</ErrorBoundary> | ||
</Suspense> | ||
<Footer /> | ||
<ToastNotifications /> | ||
</> | ||
) | ||
} | ||
|
||
export default EnterpriseLoginLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { MemoryRouter, Route } from 'react-router-dom' | ||
|
||
import Header from './Header' | ||
|
||
const wrapper = ({ children }: { children: React.ReactNode }) => ( | ||
<MemoryRouter initialEntries={['/']}> | ||
<Route path="/" exact> | ||
{children} | ||
</Route> | ||
</MemoryRouter> | ||
) | ||
|
||
describe('Header', () => { | ||
it('renders the header', () => { | ||
render(<Header />, { wrapper }) | ||
|
||
const link = screen.getByText(/Link to Homepage/) | ||
expect(link).toBeInTheDocument() | ||
}) | ||
|
||
it('renders the docs link', () => { | ||
render(<Header />, { wrapper }) | ||
|
||
const link = screen.getByText(/Docs/) | ||
expect(link).toBeInTheDocument() | ||
}) | ||
|
||
it('renders the support link', () => { | ||
render(<Header />, { wrapper }) | ||
|
||
const link = screen.getByText(/Support/) | ||
expect(link).toBeInTheDocument() | ||
}) | ||
|
||
it('renders the blog link', () => { | ||
render(<Header />, { wrapper }) | ||
|
||
const link = screen.getByText(/Blog/) | ||
expect(link).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import cs from 'classnames' | ||
|
||
import { ReactComponent as CodecovIcon } from 'assets/svg/codecov.svg' | ||
import { useImpersonate } from 'services/impersonate' | ||
import A from 'ui/A' | ||
|
||
function Header() { | ||
const { isImpersonating } = useImpersonate() | ||
|
||
return ( | ||
<header | ||
className={cs('text-white', { | ||
'bg-ds-primary-base': !isImpersonating, | ||
'bg-ds-pink-tertiary': isImpersonating, | ||
})} | ||
> | ||
<nav | ||
className="container mx-auto flex gap-4 px-3 py-4 sm:px-0" | ||
data-testid="desktop-menu" | ||
> | ||
<A | ||
to={{ | ||
pageName: 'root', | ||
}} | ||
variant="header" | ||
data-testid="homepage-link" | ||
hook="homepage-link" | ||
isExternal | ||
> | ||
<span className="sr-only">Link to Homepage</span> | ||
<CodecovIcon /> | ||
</A> | ||
<A | ||
hook="header-enterprise" | ||
to={{ pageName: 'docs' }} | ||
variant="header" | ||
showExternalIcon={false} | ||
isExternal | ||
> | ||
Docs | ||
</A> | ||
<A | ||
to={{ pageName: 'support' }} | ||
variant="header" | ||
showExternalIcon={false} | ||
hook="support-link" | ||
isExternal | ||
> | ||
Support | ||
</A> | ||
<A | ||
to={{ pageName: 'blog' }} | ||
variant="header" | ||
showExternalIcon={false} | ||
hook="blog-link" | ||
isExternal | ||
> | ||
Blog | ||
</A> | ||
</nav> | ||
</header> | ||
) | ||
} | ||
|
||
export default Header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './Header' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './EnterpriseLoginLayout' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/pages/PullRequestPage/Header/PendoLink/PendoLink.spec.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.