Skip to content

Commit 5812194

Browse files
committed
update CoverageChart to use updated useRepoCoverageTimeseries
1 parent 5f6cdbf commit 5812194

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

src/pages/RepoPage/CoverageTab/OverviewTab/subroute/CoverageChart/CoverageChart.test.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
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, within } from '@testing-library/react'
37
import { graphql, HttpResponse } from 'msw'
48
import { setupServer } from 'msw/node'
@@ -26,21 +30,27 @@ vi.mock('recharts', async () => {
2630
}
2731
})
2832

33+
const queryClient = new QueryClient({
34+
defaultOptions: { queries: { retry: false } },
35+
})
36+
const queryClientV5 = new QueryClientV5({
37+
defaultOptions: { queries: { retry: false } },
38+
})
39+
2940
const wrapper =
3041
(
3142
initialEntries = ['/gh/codecov/bells-hells/tree/main']
3243
): React.FC<React.PropsWithChildren> =>
3344
({ children }) => (
34-
<QueryClientProvider client={queryClient}>
35-
<MemoryRouter initialEntries={initialEntries}>
36-
<Route path="/:provider/:owner/:repo">{children}</Route>
37-
</MemoryRouter>
38-
</QueryClientProvider>
45+
<QueryClientProviderV5 client={queryClientV5}>
46+
<QueryClientProvider client={queryClient}>
47+
<MemoryRouter initialEntries={initialEntries}>
48+
<Route path="/:provider/:owner/:repo">{children}</Route>
49+
</MemoryRouter>
50+
</QueryClientProvider>
51+
</QueryClientProviderV5>
3952
)
4053

41-
const queryClient = new QueryClient({
42-
defaultOptions: { queries: { retry: false } },
43-
})
4454
const server = setupServer()
4555

4656
beforeAll(() => {
@@ -73,6 +83,7 @@ beforeEach(() => {
7383

7484
afterEach(() => {
7585
queryClient.clear()
86+
queryClientV5.clear()
7687
server.resetHandlers()
7788
})
7889

src/pages/RepoPage/CoverageTab/OverviewTab/subroute/CoverageChart/CoverageChart.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { keepPreviousData } from '@tanstack/react-queryV5'
12
import { format } from 'date-fns'
23
import { useParams } from 'react-router-dom'
34
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts'
@@ -43,17 +44,16 @@ function CoverageChart() {
4344
defaultBranch: overview?.defaultBranch ?? '',
4445
})
4546

46-
const { data, isPreviousData, isLoading, isError } =
47+
const { data, isPlaceholderData, isPending, isError } =
4748
useRepoCoverageTimeseries({
4849
branch: selection?.name,
4950
options: {
5051
enabled: !!selection?.name,
51-
suspense: false,
52-
keepPreviousData: true,
52+
placeholderData: keepPreviousData,
5353
},
5454
})
5555

56-
if (!isPreviousData && isLoading) {
56+
if (!isPlaceholderData && isPending) {
5757
return <Placeholder />
5858
}
5959

@@ -65,7 +65,7 @@ function CoverageChart() {
6565
)
6666
}
6767

68-
if (data?.measurements.length < 1) {
68+
if (!isPending && data?.measurements?.length < 1) {
6969
return (
7070
<div className="flex min-h-[250px] items-center justify-center xl:min-h-[380px]">
7171
<p className="text-center">

0 commit comments

Comments
 (0)