-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into sshin/2859
- Loading branch information
Showing
89 changed files
with
799 additions
and
565 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,39 +1,43 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { render, screen } from '@testing-library/react' | ||
import { | ||
QueryClientProvider as QueryClientProviderV5, | ||
QueryClient as QueryClientV5, | ||
} from '@tanstack/react-queryV5' | ||
import { render, screen, waitFor } from '@testing-library/react' | ||
import { http, HttpResponse } from 'msw' | ||
import { setupServer } from 'msw/node' | ||
import { Suspense } from 'react' | ||
import { MemoryRouter, Route } from 'react-router-dom' | ||
|
||
import AdminLink from './AdminLink' | ||
|
||
const queryClientV5 = new QueryClientV5({ | ||
defaultOptions: { queries: { retry: false } }, | ||
}) | ||
|
||
const wrapper: ({ | ||
initialEntries, | ||
}: { | ||
initialEntries?: string | ||
}) => React.FC<React.PropsWithChildren> = | ||
({ initialEntries = '/gh' }) => | ||
({ children }) => ( | ||
<QueryClientProvider client={queryClient}> | ||
<QueryClientProviderV5 client={queryClientV5}> | ||
<MemoryRouter initialEntries={[initialEntries]}> | ||
<Route path="/:provider" exact> | ||
{children} | ||
<Suspense fallback={<div>Loading</div>}>{children}</Suspense> | ||
</Route> | ||
</MemoryRouter> | ||
</QueryClientProvider> | ||
</QueryClientProviderV5> | ||
) | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { queries: { retry: false } }, | ||
}) | ||
|
||
const server = setupServer() | ||
beforeAll(() => { | ||
server.listen() | ||
}) | ||
|
||
beforeEach(() => { | ||
afterEach(() => { | ||
queryClientV5.clear() | ||
server.resetHandlers() | ||
queryClient.clear() | ||
}) | ||
|
||
afterAll(() => { | ||
|
@@ -69,7 +73,7 @@ describe('AdminLink', () => { | |
}) | ||
|
||
describe('user is not an admin', () => { | ||
it('renders nothing', () => { | ||
it('renders nothing', async () => { | ||
setup({ | ||
activated: false, | ||
email: '[email protected]', | ||
|
@@ -80,7 +84,7 @@ describe('AdminLink', () => { | |
}) | ||
|
||
const { container } = render(<AdminLink />, { wrapper: wrapper({}) }) | ||
expect(container).toBeEmptyDOMElement() | ||
await waitFor(() => expect(container).toBeEmptyDOMElement()) | ||
}) | ||
}) | ||
}) |
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
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
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
Oops, something went wrong.