Skip to content

Commit 12c0e8f

Browse files
update use of hook into query
1 parent 19c7450 commit 12c0e8f

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

src/pages/CommitDetailPage/Header/HeaderTeam/HeaderTeam.jsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useSuspenseQuery as useSuspenseQueryV5 } from '@tanstack/react-queryV5'
12
import { useParams } from 'react-router-dom'
23

34
import { formatTimeToNow } from 'shared/utils/dates'
@@ -8,20 +9,22 @@ import Icon from 'ui/Icon'
89
import TotalsNumber from 'ui/TotalsNumber'
910
import TruncatedMessage from 'ui/TruncatedMessage/TruncatedMessage'
1011

11-
import { useCommitHeaderDataTeam } from './hooks'
12+
import { CommitHeaderDataTeamQueryOpts } from './queries/CommitHeaderDataTeamQueryOpts'
1213

1314
import PullLabel from '../PullLabel'
1415

1516
function HeaderTeam() {
1617
const { provider, owner, repo, commit: commitSha } = useParams()
1718
const shortSHA = commitSha?.slice(0, 7)
1819

19-
const { data: headerData } = useCommitHeaderDataTeam({
20-
provider,
21-
owner,
22-
repo,
23-
commitId: commitSha,
24-
})
20+
const { data: headerData } = useSuspenseQueryV5(
21+
CommitHeaderDataTeamQueryOpts({
22+
provider,
23+
owner,
24+
repo,
25+
commitId: commitSha,
26+
})
27+
)
2528
const commit = headerData?.commit
2629

2730
const providerPullUrl = getProviderPullURL({

src/pages/CommitDetailPage/Header/HeaderTeam/HeaderTeam.test.jsx

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
2+
import {
3+
QueryClientProvider as QueryClientProviderV5,
4+
QueryClient as QueryClientV5,
5+
} from '@tanstack/react-queryV5'
26
import { render, screen, waitFor } from '@testing-library/react'
37
import { graphql, HttpResponse } from 'msw'
48
import { setupServer } from 'msw/node'
9+
import { Suspense } from 'react'
510
import { MemoryRouter, Route } from 'react-router-dom'
611

712
import HeaderTeam from './HeaderTeam'
@@ -43,25 +48,39 @@ const mockData = (pullId = null) => ({
4348
},
4449
})
4550

51+
const server = setupServer()
4652
const queryClient = new QueryClient({
4753
defaultOptions: { queries: { retry: false } },
4854
})
49-
const server = setupServer()
55+
const queryClientV5 = new QueryClientV5({
56+
defaultOptions: { queries: { retry: false } },
57+
})
5058

5159
const wrapper = ({ children }) => (
52-
<QueryClientProvider client={queryClient}>
53-
<MemoryRouter initialEntries={['/gh/codecov/test-repo/commit/id-1']}>
54-
<Route path="/:provider/:owner/:repo/commit/:commit">{children}</Route>
55-
</MemoryRouter>
56-
</QueryClientProvider>
60+
<QueryClientProviderV5 client={queryClientV5}>
61+
<QueryClientProvider client={queryClient}>
62+
<MemoryRouter initialEntries={['/gh/codecov/test-repo/commit/id-1']}>
63+
<Route path="/:provider/:owner/:repo/commit/:commit">
64+
<Suspense fallback={<div>Loading</div>}>{children}</Suspense>
65+
</Route>
66+
</MemoryRouter>
67+
</QueryClientProvider>
68+
</QueryClientProviderV5>
5769
)
5870

59-
beforeAll(() => server.listen())
71+
beforeAll(() => {
72+
server.listen()
73+
})
74+
6075
afterEach(() => {
6176
queryClient.clear()
77+
queryClientV5.clear()
6278
server.resetHandlers()
6379
})
64-
afterAll(() => server.close())
80+
81+
afterAll(() => {
82+
server.close()
83+
})
6584

6685
describe('HeaderTeam', () => {
6786
function setup(pullId = 1234) {

0 commit comments

Comments
 (0)