Skip to content

Commit

Permalink
update usage in ConfigurationManager
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Dec 31, 2024
1 parent 0c14fde commit 6e69b21
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import {
QueryClientProvider as QueryClientProviderV5,
QueryClient as QueryClientV5,
} from '@tanstack/react-queryV5'
import { render, screen, waitFor } from '@testing-library/react'
import { graphql, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
Expand All @@ -7,7 +11,7 @@ import { MemoryRouter, Route } from 'react-router'
import { TierNames, TTierNames } from 'services/tier'

import ConfigurationManager from './ConfigurationManager'
import { RepositoryConfiguration } from './hooks/useRepoConfigurationStatus/useRepoConfigurationStatus'
import { RepositoryConfiguration } from './hooks/useRepoConfigurationStatus/RepoConfigurationStatusQueryOpts'

interface mockRepoConfigArgs {
tierName?: TTierNames
Expand Down Expand Up @@ -52,26 +56,28 @@ function mockRepoConfig({
}

const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
},
},
defaultOptions: { queries: { retry: false } },
})
const queryClientV5 = new QueryClientV5({
defaultOptions: { queries: { retry: false } },
})
const server = setupServer()
const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={['/gh/codecov/cool-repo/config']}>
<Route path="/:provider/:owner/:repo/config">{children}</Route>
</MemoryRouter>
</QueryClientProvider>
<QueryClientProviderV5 client={queryClientV5}>
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={['/gh/codecov/cool-repo/config']}>
<Route path="/:provider/:owner/:repo/config">{children}</Route>
</MemoryRouter>
</QueryClientProvider>
</QueryClientProviderV5>
)

beforeAll(() => {
server.listen()
})
afterEach(() => {
queryClient.clear()
queryClientV5.clear()
server.resetHandlers()
})
afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useSuspenseQuery as useSuspenseQueryV5 } from '@tanstack/react-queryV5'
import { useParams } from 'react-router'

import { TierNames } from 'services/tier'

import FeatureGroup from './components/FeatureGroup'
import FeatureItem from './components/FeatureItem/FeatureItem'
import {
RepoConfigurationStatusQueryOpts,
RepositoryConfiguration,
useRepoConfigurationStatus,
} from './hooks/useRepoConfigurationStatus/useRepoConfigurationStatus'
} from './hooks/useRepoConfigurationStatus/RepoConfigurationStatusQueryOpts'

interface URLParams {
provider: string
Expand All @@ -17,11 +18,13 @@ interface URLParams {

function ConfigurationManager() {
const { provider, owner, repo } = useParams<URLParams>()
const { data: repoConfiguration } = useRepoConfigurationStatus({
provider,
owner,
repo,
})
const { data: repoConfiguration } = useSuspenseQueryV5(
RepoConfigurationStatusQueryOpts({
provider,
owner,
repo,
})
)

return (
<div className="flex flex-col gap-6 lg:w-3/4">
Expand Down

0 comments on commit 6e69b21

Please sign in to comment.