Skip to content

Commit 79a6fbd

Browse files
Merge branch 'main' into cy/ts_shared_p5
2 parents 682dbee + cdd2bcd commit 79a6fbd

File tree

21 files changed

+266
-150
lines changed

21 files changed

+266
-150
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.15.1
1+
v22.11.0

.storybook/Layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import '../src/globals.css'
33

4-
const Layout = ({ children }) => {
4+
const Layout: React.FC<React.PropsWithChildren> = ({ children }) => {
55
return <div className="text-sm text-ds-primary-base">{children}</div>
66
}
77

.storybook/preview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export const parameters = {
1111

1212
const queryClient = new QueryClient()
1313

14-
const localStorageResetDecorator = (Story) => {
14+
const localStorageResetDecorator = (Story: React.FC) => {
1515
window.localStorage.clear()
1616
return <Story />
1717
}
1818

1919
export const decorators = [
2020
localStorageResetDecorator,
21-
(Story) => (
21+
(Story: React.FC) => (
2222
<QueryClientProvider client={queryClient}>
2323
<Layout>
2424
<Story />

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ RUN gpg --verify linux/codecov.SHA256SUM.sig linux/codecov.SHA256SUM
3535

3636
COPY docker/index.html /tmp/uploader
3737

38-
FROM node:20-alpine3.17 as build
38+
FROM node:22-alpine3.20 as build
3939
ARG REACT_APP_ENV_ARG
4040
ARG REACT_APP_CODECOV_VERSION
4141
ENV REACT_APP_ENV=$REACT_APP_ENV_ARG

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"@types/eslint-plugin-jsx-a11y": "^6.9.0",
121121
"@types/js-cookie": "3.0.6",
122122
"@types/lodash": "4.17.6",
123-
"@types/node": "^20.5.7",
123+
"@types/node": "^22.9.0",
124124
"@types/prismjs": "^1.26.4",
125125
"@types/prop-types": "15.7.12",
126126
"@types/qs": "6.9.15",
@@ -170,13 +170,13 @@
170170
"vitest": "^2.1.3"
171171
},
172172
"engines": {
173-
"node": ">=20.10.0"
173+
"node": ">=22.11.0"
174174
},
175175
"msw": {
176176
"workerDirectory": "public"
177177
},
178178
"volta": {
179-
"node": "20.15.1",
179+
"node": "22.11.0",
180180
"yarn": "4.5.0"
181181
},
182182
"resolutions": {

src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadItem.test.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
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 userEvent from '@testing-library/user-event'
48
import { MemoryRouter, Route } from 'react-router-dom'
59

10+
import { IgnoredIdsQueryOptions } from 'pages/CommitDetailPage/queries/IgnoredIdsQueryOptions'
611
import { formatTimeToNow } from 'shared/utils/dates'
712
import { Upload } from 'shared/utils/extractUploads'
813

@@ -26,21 +31,25 @@ const mockUpload: Upload = {
2631
}
2732

2833
const queryClient = new QueryClient()
34+
const queryClientV5 = new QueryClientV5()
2935

3036
const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => (
31-
<QueryClientProvider client={queryClient}>
32-
<MemoryRouter
33-
initialEntries={[
34-
'/gh/codecov/codecov-api/commit/a758cb364d190e9677ae2a3dd3b2af7690971624',
35-
]}
36-
>
37-
<Route path="/gh/:owner/:repo/commit/:commit">{children}</Route>
38-
</MemoryRouter>
39-
</QueryClientProvider>
37+
<QueryClientProviderV5 client={queryClientV5}>
38+
<QueryClientProvider client={queryClient}>
39+
<MemoryRouter
40+
initialEntries={[
41+
'/gh/codecov/codecov-api/commit/a758cb364d190e9677ae2a3dd3b2af7690971624',
42+
]}
43+
>
44+
<Route path="/gh/:owner/:repo/commit/:commit">{children}</Route>
45+
</MemoryRouter>
46+
</QueryClientProvider>
47+
</QueryClientProviderV5>
4048
)
4149

4250
afterEach(() => {
4351
queryClient.clear()
52+
queryClientV5.clear()
4453
})
4554

4655
describe('UploadsCard', () => {
@@ -497,9 +506,9 @@ describe('UploadsCard', () => {
497506
await user.click(checkbox)
498507

499508
await waitFor(() =>
500-
expect(queryClient.getQueryData(['IgnoredUploadIds'])).toStrictEqual([
501-
0,
502-
])
509+
expect(
510+
queryClientV5.getQueryData(IgnoredIdsQueryOptions().queryKey)
511+
).toStrictEqual([0])
503512
)
504513
})
505514

@@ -511,11 +520,15 @@ describe('UploadsCard', () => {
511520
const checkbox = screen.getByRole('checkbox')
512521
await user.click(checkbox)
513522

514-
expect(queryClient.getQueryData(['IgnoredUploadIds'])).toStrictEqual([0])
523+
expect(
524+
queryClientV5.getQueryData(IgnoredIdsQueryOptions().queryKey)
525+
).toStrictEqual([0])
515526

516527
await user.click(checkbox)
517528

518-
expect(queryClient.getQueryData(['IgnoredUploadIds'])).toStrictEqual([])
529+
expect(
530+
queryClientV5.getQueryData(IgnoredIdsQueryOptions().queryKey)
531+
).toStrictEqual([])
519532
})
520533

521534
it('handles null id gracefully', async () => {

src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadItem.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { useQueryClient } from '@tanstack/react-query'
1+
import { useQueryClient as useQueryClientV5 } from '@tanstack/react-queryV5'
22
import without from 'lodash/without'
33
import { useEffect, useState } from 'react'
44

5+
import { IgnoredIdsQueryOptions } from 'pages/CommitDetailPage/queries/IgnoredIdsQueryOptions'
56
import { UploadTypeEnum } from 'shared/utils/commit'
67
import { formatTimeToNow } from 'shared/utils/dates'
78
import { Upload } from 'shared/utils/extractUploads'
@@ -35,7 +36,7 @@ const UploadItem = ({
3536
onSelectChange = () => {},
3637
}: UploadProps) => {
3738
const [checked, setChecked] = useState(true)
38-
const queryClient = useQueryClient()
39+
const queryClientV5 = useQueryClientV5()
3940
const isCarriedForward = uploadType === UploadTypeEnum.CARRIED_FORWARD
4041

4142
useEffect(() => setChecked(isSelected ?? true), [isSelected])
@@ -53,13 +54,13 @@ const UploadItem = ({
5354

5455
if (checked && id != null) {
5556
// User is unchecking
56-
queryClient.setQueryData(
57-
['IgnoredUploadIds'],
57+
queryClientV5.setQueryData(
58+
IgnoredIdsQueryOptions().queryKey,
5859
(oldData?: number[]) => [...(oldData ?? []), id]
5960
)
6061
} else if (id != null) {
61-
queryClient.setQueryData(
62-
['IgnoredUploadIds'],
62+
queryClientV5.setQueryData(
63+
IgnoredIdsQueryOptions().queryKey,
6364
(oldData?: number[]) => without(oldData, id)
6465
)
6566
}

src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadsCard.test.tsx

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
2+
import {
3+
QueryClientProvider as QueryClientProviderV5,
4+
QueryClient as QueryClientV5,
5+
} from '@tanstack/react-queryV5'
16
import {
27
render,
38
screen,
49
waitFor,
510
waitForElementToBeRemoved,
6-
} from 'custom-testing-library'
7-
8-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
11+
} from '@testing-library/react'
912
import userEvent from '@testing-library/user-event'
1013
import { graphql, HttpResponse } from 'msw'
1114
import { setupServer } from 'msw/node'
1215
import { MemoryRouter, Route } from 'react-router-dom'
1316

17+
import { IgnoredIdsQueryOptions } from 'pages/CommitDetailPage/queries/IgnoredIdsQueryOptions'
18+
1419
import UploadsCard from './UploadsCard'
1520
import { useUploads } from './useUploads'
1621

@@ -22,34 +27,39 @@ const mocks = vi.hoisted(() => ({
2227
vi.mock('./useUploads', async () => mocks)
2328
vi.mock('services/commitErrors', async () => mocks)
2429

30+
const server = setupServer()
2531
const queryClient = new QueryClient({
26-
defaultOptions: {
27-
queries: {
28-
suspense: true,
29-
retry: false,
30-
},
31-
},
32+
defaultOptions: { queries: { suspense: true, retry: false } },
33+
})
34+
const queryClientV5 = new QueryClientV5({
35+
defaultOptions: { queries: { retry: false } },
3236
})
33-
const server = setupServer()
3437

3538
const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => (
36-
<QueryClientProvider client={queryClient}>
37-
<MemoryRouter initialEntries={['/gh/codecov/gazebo/1234']}>
38-
<Route path="/:provider/:owner/:repo/:commit">{children}</Route>
39-
</MemoryRouter>
40-
</QueryClientProvider>
39+
<QueryClientProviderV5 client={queryClientV5}>
40+
<QueryClientProvider client={queryClient}>
41+
<MemoryRouter initialEntries={['/gh/codecov/gazebo/1234']}>
42+
<Route path="/:provider/:owner/:repo/:commit">{children}</Route>
43+
</MemoryRouter>
44+
</QueryClientProvider>
45+
</QueryClientProviderV5>
4146
)
4247

4348
beforeAll(() => {
4449
console.error = () => {}
4550
server.listen()
4651
})
52+
4753
afterEach(() => {
4854
queryClient.clear()
55+
queryClientV5.clear()
4956
server.resetHandlers()
5057
vi.clearAllMocks()
5158
})
52-
afterAll(() => server.close())
59+
60+
afterAll(() => {
61+
server.close()
62+
})
5363

5464
interface MockCommitErrors {
5565
data: {
@@ -193,6 +203,7 @@ describe('UploadsCard', () => {
193203
const covReportHistory = screen.getByText(/Coverage reports history/)
194204
expect(covReportHistory).toBeInTheDocument()
195205
})
206+
196207
it('renders different cis', () => {
197208
render(<UploadsCard />, { wrapper })
198209

@@ -201,6 +212,7 @@ describe('UploadsCard', () => {
201212
const travis = screen.getByText(/travis/)
202213
expect(travis).toBeInTheDocument()
203214
})
215+
204216
it('renders build ids', () => {
205217
render(<UploadsCard />, { wrapper })
206218

@@ -215,6 +227,7 @@ describe('UploadsCard', () => {
215227
const id5 = screen.getByText(/837462/)
216228
expect(id5).toBeInTheDocument()
217229
})
230+
218231
it('renders flags', () => {
219232
render(<UploadsCard />, { wrapper })
220233

@@ -255,6 +268,7 @@ describe('UploadsCard', () => {
255268
expect(currentlyNoUploads).toBeInTheDocument()
256269
})
257270
})
271+
258272
describe('renders empty Uploads', () => {
259273
// ??
260274
beforeEach(() => {
@@ -276,6 +290,7 @@ describe('UploadsCard', () => {
276290
expect(uploads).toBeInTheDocument()
277291
})
278292
})
293+
279294
describe('The yaml viewer', () => {
280295
beforeEach(() => {
281296
setup({
@@ -815,6 +830,7 @@ describe('UploadsCard', () => {
815830
})
816831
})
817832
})
833+
818834
describe('select all interactor', () => {
819835
beforeEach(() => {
820836
setup({
@@ -908,32 +924,47 @@ describe('UploadsCard', () => {
908924
})
909925
})
910926

911-
it('unselects all when clicked', async () => {
912-
const user = userEvent.setup()
913-
render(<UploadsCard />, { wrapper })
927+
describe('unselects all when clicked', () => {
928+
it('unselects all when clicked', async () => {
929+
const user = userEvent.setup()
930+
render(<UploadsCard />, { wrapper })
914931

915-
const checkboxes = screen.getAllByRole('checkbox')
916-
const travisCheckbox = checkboxes[0]
917-
const travisUploadCheckbox1 = checkboxes[1]
918-
const travisUploadCheckbox2 = checkboxes[2]
932+
const checkboxes = screen.getAllByRole('checkbox')
933+
const travisCheckbox = checkboxes[0]
934+
const travisUploadCheckbox1 = checkboxes[1]
935+
const travisUploadCheckbox2 = checkboxes[2]
919936

920-
expect(travisCheckbox).toBeChecked()
921-
expect(travisUploadCheckbox1).toBeChecked()
922-
expect(travisUploadCheckbox2).toBeChecked()
937+
expect(travisCheckbox).toBeChecked()
938+
expect(travisUploadCheckbox1).toBeChecked()
939+
expect(travisUploadCheckbox2).toBeChecked()
923940

924-
await user.click(travisCheckbox!)
941+
await user.click(travisCheckbox!)
925942

926-
expect(travisCheckbox).not.toBeChecked()
927-
expect(travisUploadCheckbox1).not.toBeChecked()
928-
expect(travisUploadCheckbox2).not.toBeChecked()
929-
930-
// 'circleci' uploads remain checked
931-
const circleciCheckbox = checkboxes[3]
932-
const circleciUploadCheckbox1 = checkboxes[4]
933-
const circleciUploadCheckbox2 = checkboxes[5]
934-
expect(circleciCheckbox).toBeChecked()
935-
expect(circleciUploadCheckbox1).toBeChecked()
936-
expect(circleciUploadCheckbox2).toBeChecked()
943+
expect(travisCheckbox).not.toBeChecked()
944+
expect(travisUploadCheckbox1).not.toBeChecked()
945+
expect(travisUploadCheckbox2).not.toBeChecked()
946+
947+
// 'circleci' uploads remain checked
948+
const circleciCheckbox = checkboxes[3]
949+
const circleciUploadCheckbox1 = checkboxes[4]
950+
const circleciUploadCheckbox2 = checkboxes[5]
951+
expect(circleciCheckbox).toBeChecked()
952+
expect(circleciUploadCheckbox1).toBeChecked()
953+
expect(circleciUploadCheckbox2).toBeChecked()
954+
})
955+
956+
it('adds ids to ignored ids query', async () => {
957+
const user = userEvent.setup()
958+
render(<UploadsCard />, { wrapper })
959+
960+
const checkboxes = screen.getAllByRole('checkbox')
961+
const travisCheckbox = checkboxes[0]
962+
await user.click(travisCheckbox!)
963+
964+
expect(
965+
queryClientV5.getQueryData(IgnoredIdsQueryOptions().queryKey)
966+
).toEqual([0, 1])
967+
})
937968
})
938969

939970
it('shows an intermediate state', async () => {

0 commit comments

Comments
 (0)