1
+ import { QueryClient , QueryClientProvider } from '@tanstack/react-query'
2
+ import {
3
+ QueryClientProvider as QueryClientProviderV5 ,
4
+ QueryClient as QueryClientV5 ,
5
+ } from '@tanstack/react-queryV5'
1
6
import {
2
7
render ,
3
8
screen ,
4
9
waitFor ,
5
10
waitForElementToBeRemoved ,
6
- } from 'custom-testing-library'
7
-
8
- import { QueryClient , QueryClientProvider } from '@tanstack/react-query'
11
+ } from '@testing-library/react'
9
12
import userEvent from '@testing-library/user-event'
10
13
import { graphql , HttpResponse } from 'msw'
11
14
import { setupServer } from 'msw/node'
12
15
import { MemoryRouter , Route } from 'react-router-dom'
13
16
17
+ import { IgnoredIdsQueryOptions } from 'pages/CommitDetailPage/queries/IgnoredIdsQueryOptions'
18
+
14
19
import UploadsCard from './UploadsCard'
15
20
import { useUploads } from './useUploads'
16
21
@@ -22,34 +27,39 @@ const mocks = vi.hoisted(() => ({
22
27
vi . mock ( './useUploads' , async ( ) => mocks )
23
28
vi . mock ( 'services/commitErrors' , async ( ) => mocks )
24
29
30
+ const server = setupServer ( )
25
31
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 } } ,
32
36
} )
33
- const server = setupServer ( )
34
37
35
38
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 >
41
46
)
42
47
43
48
beforeAll ( ( ) => {
44
49
console . error = ( ) => { }
45
50
server . listen ( )
46
51
} )
52
+
47
53
afterEach ( ( ) => {
48
54
queryClient . clear ( )
55
+ queryClientV5 . clear ( )
49
56
server . resetHandlers ( )
50
57
vi . clearAllMocks ( )
51
58
} )
52
- afterAll ( ( ) => server . close ( ) )
59
+
60
+ afterAll ( ( ) => {
61
+ server . close ( )
62
+ } )
53
63
54
64
interface MockCommitErrors {
55
65
data : {
@@ -193,6 +203,7 @@ describe('UploadsCard', () => {
193
203
const covReportHistory = screen . getByText ( / C o v e r a g e r e p o r t s h i s t o r y / )
194
204
expect ( covReportHistory ) . toBeInTheDocument ( )
195
205
} )
206
+
196
207
it ( 'renders different cis' , ( ) => {
197
208
render ( < UploadsCard /> , { wrapper } )
198
209
@@ -201,6 +212,7 @@ describe('UploadsCard', () => {
201
212
const travis = screen . getByText ( / t r a v i s / )
202
213
expect ( travis ) . toBeInTheDocument ( )
203
214
} )
215
+
204
216
it ( 'renders build ids' , ( ) => {
205
217
render ( < UploadsCard /> , { wrapper } )
206
218
@@ -215,6 +227,7 @@ describe('UploadsCard', () => {
215
227
const id5 = screen . getByText ( / 8 3 7 4 6 2 / )
216
228
expect ( id5 ) . toBeInTheDocument ( )
217
229
} )
230
+
218
231
it ( 'renders flags' , ( ) => {
219
232
render ( < UploadsCard /> , { wrapper } )
220
233
@@ -255,6 +268,7 @@ describe('UploadsCard', () => {
255
268
expect ( currentlyNoUploads ) . toBeInTheDocument ( )
256
269
} )
257
270
} )
271
+
258
272
describe ( 'renders empty Uploads' , ( ) => {
259
273
// ??
260
274
beforeEach ( ( ) => {
@@ -276,6 +290,7 @@ describe('UploadsCard', () => {
276
290
expect ( uploads ) . toBeInTheDocument ( )
277
291
} )
278
292
} )
293
+
279
294
describe ( 'The yaml viewer' , ( ) => {
280
295
beforeEach ( ( ) => {
281
296
setup ( {
@@ -815,6 +830,7 @@ describe('UploadsCard', () => {
815
830
} )
816
831
} )
817
832
} )
833
+
818
834
describe ( 'select all interactor' , ( ) => {
819
835
beforeEach ( ( ) => {
820
836
setup ( {
@@ -908,32 +924,47 @@ describe('UploadsCard', () => {
908
924
} )
909
925
} )
910
926
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 } )
914
931
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 ]
919
936
920
- expect ( travisCheckbox ) . toBeChecked ( )
921
- expect ( travisUploadCheckbox1 ) . toBeChecked ( )
922
- expect ( travisUploadCheckbox2 ) . toBeChecked ( )
937
+ expect ( travisCheckbox ) . toBeChecked ( )
938
+ expect ( travisUploadCheckbox1 ) . toBeChecked ( )
939
+ expect ( travisUploadCheckbox2 ) . toBeChecked ( )
923
940
924
- await user . click ( travisCheckbox ! )
941
+ await user . click ( travisCheckbox ! )
925
942
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
+ } )
937
968
} )
938
969
939
970
it ( 'shows an intermediate state' , async ( ) => {
0 commit comments