Skip to content

Commit

Permalink
update usage in MissingDesignatedAdmins
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Dec 23, 2024
1 parent 11652da commit 608f422
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
QueryClientProvider as QueryClientProviderV5,
QueryClient as QueryClientV5,
} from '@tanstack/react-queryV5'
import { render, screen } from '@testing-library/react'
import { graphql, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { Suspense } from 'react'
import { MemoryRouter, Route } from 'react-router-dom'

import config from 'config'
Expand All @@ -17,6 +22,23 @@ const mockApiCloud = { config: undefined }
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
})
const queryClientV5 = new QueryClientV5({
defaultOptions: { queries: { retry: false } },
})

const wrapper =
(initialEntries = ['/gh/test-org/test-repo/pull/12']) =>
({ children }) => (
<QueryClientProviderV5 client={queryClientV5}>
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Route path="/:provider/:owner/:repo/pull/:pullId">
<Suspense fallback={<div>Loading</div>}>{children}</Suspense>
</Route>
</MemoryRouter>
</QueryClientProvider>
</QueryClientProviderV5>
)

const server = setupServer()
beforeAll(() => {
Expand All @@ -25,23 +47,14 @@ beforeAll(() => {

afterEach(() => {
queryClient.clear()
queryClientV5.clear()
server.resetHandlers()
})

afterAll(() => {
server.close()
})

const wrapper =
(initialEntries = ['/gh/test-org/test-repo/pull/12']) =>
({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Route path="/:provider/:owner/:repo/pull/:pullId">{children}</Route>
</MemoryRouter>
</QueryClientProvider>
)

describe('MissingDesignatedAdmins', () => {
function setup(overrideData) {
server.use(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useSuspenseQuery as useSuspenseQueryV5 } from '@tanstack/react-queryV5'
import { useParams } from 'react-router-dom'

import config from 'config'

import { useSelfHostedHasAdmins } from 'services/selfHosted'
import { SelfHostedHasAdminsQueryOpts } from 'services/selfHosted/SelfHostedHasAdminsQueryOpts'
import { Provider } from 'shared/api/helpers'
import A from 'ui/A'
import Banner from 'ui/Banner'
Expand Down Expand Up @@ -33,9 +34,8 @@ interface URLParams {

const MissingDesignatedAdmins = () => {
const { provider } = useParams<URLParams>()
const { data: hasAdmins, isFetching } = useSelfHostedHasAdmins(
{ provider },
{ enabled: !!provider && !!config.IS_SELF_HOSTED }
const { data: hasAdmins, isFetching } = useSuspenseQueryV5(
SelfHostedHasAdminsQueryOpts({ provider })
)
// This hook is purely side stepping the complexity rule here.
const hideBanner = useHideBanner({
Expand Down

0 comments on commit 608f422

Please sign in to comment.