@@ -34,7 +34,8 @@ const mockRepoOverview = {
34
34
} ,
35
35
}
36
36
37
- const mockBranchBundles = {
37
+ const mockBranchBundles = ( isTimescaleEnabled : boolean ) => ( {
38
+ config : { isTimescaleEnabled } ,
38
39
owner : {
39
40
repository : {
40
41
__typename : 'Repository' ,
@@ -63,9 +64,10 @@ const mockBranchBundles = {
63
64
} ,
64
65
} ,
65
66
} ,
66
- }
67
+ } )
67
68
68
69
const mockBranchBundlesError = {
70
+ config : { isTimescaleEnabled : false } ,
69
71
owner : {
70
72
repository : {
71
73
__typename : 'Repository' ,
@@ -85,6 +87,7 @@ const mockBranchBundlesError = {
85
87
}
86
88
87
89
const mockEmptyBundleSelection = {
90
+ config : { isTimescaleEnabled : false } ,
88
91
owner : {
89
92
repository : {
90
93
__typename : 'Repository' ,
@@ -113,14 +116,8 @@ const mockAssets = {
113
116
routes : [ '/' ] ,
114
117
extension : 'js' ,
115
118
bundleData : {
116
- loadTime : {
117
- threeG : 2000 ,
118
- highSpeed : 2000 ,
119
- } ,
120
- size : {
121
- uncompress : 3000 ,
122
- gzip : 4000 ,
123
- } ,
119
+ loadTime : { threeG : 2000 , highSpeed : 2000 } ,
120
+ size : { uncompress : 3000 , gzip : 4000 } ,
124
121
} ,
125
122
measurements : {
126
123
change : { size : { uncompress : 5 } } ,
@@ -217,14 +214,8 @@ const mockBundleSummary = {
217
214
name : 'bundle1' ,
218
215
moduleCount : 10 ,
219
216
bundleData : {
220
- loadTime : {
221
- threeG : 1000 ,
222
- highSpeed : 500 ,
223
- } ,
224
- size : {
225
- gzip : 1000 ,
226
- uncompress : 2000 ,
227
- } ,
217
+ loadTime : { threeG : 1000 , highSpeed : 500 } ,
218
+ size : { gzip : 1000 , uncompress : 2000 } ,
228
219
} ,
229
220
} ,
230
221
} ,
@@ -282,12 +273,14 @@ afterAll(() => {
282
273
interface SetupArgs {
283
274
isBundleError ?: boolean
284
275
isEmptyBundleSelection ?: boolean
276
+ isTimescaleEnabled ?: boolean
285
277
}
286
278
287
279
describe ( 'BundleContent' , ( ) => {
288
280
function setup ( {
289
281
isBundleError = false ,
290
282
isEmptyBundleSelection = false ,
283
+ isTimescaleEnabled = true ,
291
284
} : SetupArgs ) {
292
285
server . use (
293
286
graphql . query ( 'BranchBundleSummaryData' , ( ) => {
@@ -296,7 +289,9 @@ describe('BundleContent', () => {
296
289
} else if ( isEmptyBundleSelection ) {
297
290
return HttpResponse . json ( { data : mockEmptyBundleSelection } )
298
291
}
299
- return HttpResponse . json ( { data : mockBranchBundles } )
292
+ return HttpResponse . json ( {
293
+ data : mockBranchBundles ( isTimescaleEnabled ) ,
294
+ } )
300
295
} ) ,
301
296
graphql . query ( 'GetRepoOverview' , ( ) => {
302
297
return HttpResponse . json ( { data : mockRepoOverview } )
@@ -398,6 +393,39 @@ describe('BundleContent', () => {
398
393
expect ( moduleCount ) . toBeInTheDocument ( )
399
394
} )
400
395
} )
396
+
397
+ describe ( 'rendering the trend chart' , ( ) => {
398
+ describe ( 'when timescale is enabled' , ( ) => {
399
+ it ( 'renders the trend chart' , async ( ) => {
400
+ setup ( { isTimescaleEnabled : true } )
401
+ render ( < BundleContent /> , {
402
+ wrapper : wrapper (
403
+ '/gh/codecov/test-repo/bundles/main/test-bundle'
404
+ ) ,
405
+ } )
406
+
407
+ const chart = await screen . findByText ( 'Hide chart' )
408
+ expect ( chart ) . toBeInTheDocument ( )
409
+ } )
410
+ } )
411
+
412
+ describe ( 'when timescale is disabled' , ( ) => {
413
+ it ( 'renders the trend chart' , async ( ) => {
414
+ setup ( { isTimescaleEnabled : false } )
415
+ render ( < BundleContent /> , {
416
+ wrapper : wrapper (
417
+ '/gh/codecov/test-repo/bundles/main/test-bundle'
418
+ ) ,
419
+ } )
420
+
421
+ const bundleName = await screen . findByText ( 'asset-1' )
422
+ expect ( bundleName ) . toBeInTheDocument ( )
423
+
424
+ const chart = screen . queryByText ( 'Hide chart' )
425
+ expect ( chart ) . not . toBeInTheDocument ( )
426
+ } )
427
+ } )
428
+ } )
401
429
} )
402
430
403
431
describe ( 'when only the branch is set' , ( ) => {
0 commit comments