Skip to content

Commit

Permalink
update ActivationRequiredSelfHosted
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Dec 13, 2024
1 parent cc169e8 commit 1cca9c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
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, http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { Suspense } from 'react'
import { MemoryRouter, Route } from 'react-router-dom'

import ActivationRequiredSelfHosted from './ActivationRequiredSelfHosted'

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

const server = setupServer()

beforeAll(() => {
server.listen({ onUnhandledRequest: 'warn' })
console.error = () => {}
})

afterEach(() => {
queryClient.clear()
queryClientV5.clear()
server.resetHandlers()
vi.clearAllMocks()
})
Expand All @@ -31,14 +46,6 @@ afterAll(() => {
server.close()
})

const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={['/gh/codecov/gazebo/new']}>
<Route path="/:provider/:owner/:repo/new">{children}</Route>
</MemoryRouter>
</QueryClientProvider>
)

describe('ActivationRequiredSelfHosted', () => {
function setup(isAdmin: boolean, seatsUsed: number, seatsLimit: number) {
server.use(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
useSelfHostedCurrentUser,
useSelfHostedSeatsConfig,
} from 'services/selfHosted'
import { useSuspenseQuery as useSuspenseQueryV5 } from '@tanstack/react-queryV5'
import { useParams } from 'react-router'

import { useSelfHostedSeatsConfig } from 'services/selfHosted'
import { SelfHostedCurrentUserQueryOpts } from 'services/selfHosted/SelfHostedCurrentUserQueryOpts'
import A from 'ui/A'
import Banner from 'ui/Banner'
import BannerContent from 'ui/Banner/BannerContent'
Expand Down Expand Up @@ -60,8 +61,15 @@ function SeatsAvailable({ isAdmin }: { isAdmin: boolean }) {
)
}

interface URLParams {
provider: string
}

function ActivationRequiredSelfHosted() {
const { data } = useSelfHostedCurrentUser()
const { provider } = useParams<URLParams>()
const { data } = useSuspenseQueryV5(
SelfHostedCurrentUserQueryOpts({ provider })
)
const { data: selfHostedSeats } = useSelfHostedSeatsConfig()

const hasSelfHostedSeats =
Expand Down

0 comments on commit 1cca9c1

Please sign in to comment.