From 608f422e0081deaa5e88cfed35cf55f23df5e6aa Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Fri, 13 Dec 2024 09:16:31 -0500 Subject: [PATCH] update usage in MissingDesignatedAdmins --- .../MissingDesignatedAdmins.test.jsx | 33 +++++++++++++------ .../MissingDesignatedAdmins.tsx | 8 ++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.test.jsx b/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.test.jsx index 3ce829d440..9e94c41f95 100644 --- a/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.test.jsx +++ b/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.test.jsx @@ -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' @@ -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 }) => ( + + + + + Loading}>{children} + + + + + ) const server = setupServer() beforeAll(() => { @@ -25,6 +47,7 @@ beforeAll(() => { afterEach(() => { queryClient.clear() + queryClientV5.clear() server.resetHandlers() }) @@ -32,16 +55,6 @@ afterAll(() => { server.close() }) -const wrapper = - (initialEntries = ['/gh/test-org/test-repo/pull/12']) => - ({ children }) => ( - - - {children} - - - ) - describe('MissingDesignatedAdmins', () => { function setup(overrideData) { server.use( diff --git a/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.tsx b/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.tsx index 30cf1f123e..e59700e141 100644 --- a/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.tsx +++ b/src/shared/GlobalBanners/MissingDesignatedAdmins/MissingDesignatedAdmins.tsx @@ -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' @@ -33,9 +34,8 @@ interface URLParams { const MissingDesignatedAdmins = () => { const { provider } = useParams() - 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({