@@ -12,6 +12,15 @@ import MetricsSection, { historicalTrendToCopy } from './MetricsSection'
12
12
13
13
import { TestResultsFilterParameter } from '../hooks/useInfiniteTestResults/useInfiniteTestResults'
14
14
15
+ vi . mock ( 'shared/featureFlags' , async ( ) => {
16
+ const actual = await vi . importActual ( 'shared/featureFlags' )
17
+
18
+ return {
19
+ ...actual ,
20
+ useFlags : vi . fn ( ( ) => ( { allBranchesEnabled : false } ) ) ,
21
+ }
22
+ } )
23
+
15
24
const mockAggResponse = (
16
25
planValue : PlanName = Plans . USERS_ENTERPRISEM ,
17
26
isPrivate = false
@@ -148,11 +157,14 @@ describe('MetricsSection', () => {
148
157
} )
149
158
} )
150
159
151
- describe ( 'when on default branch' , ( ) => {
160
+ describe . each ( [
161
+ [ 'default branch' , 'main' ] ,
162
+ [ 'all branches' , 'All%20branches' ] ,
163
+ ] ) ( 'when on %s' , ( _ , encodedBranch ) => {
152
164
it ( 'renders subheaders' , async ( ) => {
153
165
setup ( )
154
166
render ( < MetricsSection /> , {
155
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
167
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
156
168
} )
157
169
158
170
const runEfficiency = await screen . findByText ( 'Improve CI Run Efficiency' )
@@ -164,7 +176,7 @@ describe('MetricsSection', () => {
164
176
it ( 'renders total test runtime card' , async ( ) => {
165
177
setup ( )
166
178
render ( < MetricsSection /> , {
167
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
179
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
168
180
} )
169
181
170
182
const title = await screen . findByText ( 'Total test run time' )
@@ -182,7 +194,7 @@ describe('MetricsSection', () => {
182
194
it ( 'renders slowest tests card' , async ( ) => {
183
195
setup ( )
184
196
render ( < MetricsSection /> , {
185
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
197
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
186
198
} )
187
199
188
200
const title = await screen . findByText ( 'Slowest tests' )
@@ -199,7 +211,7 @@ describe('MetricsSection', () => {
199
211
it ( 'can update the location params on button click' , async ( ) => {
200
212
const { user } = setup ( )
201
213
render ( < MetricsSection /> , {
202
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
214
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
203
215
} )
204
216
const select = await screen . findByText ( '12' )
205
217
expect ( select ) . toBeInTheDocument ( )
@@ -217,7 +229,7 @@ describe('MetricsSection', () => {
217
229
it ( 'removes the location param on second button click' , async ( ) => {
218
230
const { user } = setup ( )
219
231
render ( < MetricsSection /> , {
220
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
232
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
221
233
} )
222
234
const select = await screen . findByText ( '12' )
223
235
expect ( select ) . toBeInTheDocument ( )
@@ -239,7 +251,7 @@ describe('MetricsSection', () => {
239
251
it ( 'renders total flaky tests card' , async ( ) => {
240
252
setup ( )
241
253
render ( < MetricsSection /> , {
242
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
254
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
243
255
} )
244
256
245
257
const title = await screen . findByText ( 'Flaky tests' )
@@ -256,7 +268,7 @@ describe('MetricsSection', () => {
256
268
it ( 'can update the location params on button click' , async ( ) => {
257
269
const { user } = setup ( )
258
270
render ( < MetricsSection /> , {
259
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
271
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
260
272
} )
261
273
const select = await screen . findByText ( 88 )
262
274
expect ( select ) . toBeInTheDocument ( )
@@ -274,7 +286,7 @@ describe('MetricsSection', () => {
274
286
it ( 'removes the location param on second button click' , async ( ) => {
275
287
const { user } = setup ( )
276
288
render ( < MetricsSection /> , {
277
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
289
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
278
290
} )
279
291
const select = await screen . findByText ( 88 )
280
292
expect ( select ) . toBeInTheDocument ( )
@@ -313,7 +325,7 @@ describe('MetricsSection', () => {
313
325
it ( 'renders total failures card' , async ( ) => {
314
326
setup ( )
315
327
render ( < MetricsSection /> , {
316
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
328
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
317
329
} )
318
330
319
331
const title = await screen . findByText ( 'Cumulative Failures' )
@@ -330,7 +342,7 @@ describe('MetricsSection', () => {
330
342
it ( 'can update the location params on button click' , async ( ) => {
331
343
const { user } = setup ( )
332
344
render ( < MetricsSection /> , {
333
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
345
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
334
346
} )
335
347
const select = await screen . findByText ( 1 )
336
348
expect ( select ) . toBeInTheDocument ( )
@@ -370,7 +382,7 @@ describe('MetricsSection', () => {
370
382
it ( 'renders total skips card' , async ( ) => {
371
383
setup ( )
372
384
render ( < MetricsSection /> , {
373
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
385
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
374
386
} )
375
387
376
388
const title = await screen . findByText ( 'Skipped tests' )
@@ -387,7 +399,7 @@ describe('MetricsSection', () => {
387
399
it ( 'can update the location params on button click' , async ( ) => {
388
400
const { user } = setup ( )
389
401
render ( < MetricsSection /> , {
390
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
402
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
391
403
} )
392
404
const select = await screen . findByText ( 20 )
393
405
expect ( select ) . toBeInTheDocument ( )
@@ -405,7 +417,7 @@ describe('MetricsSection', () => {
405
417
it ( 'removes the location param on second button click' , async ( ) => {
406
418
const { user } = setup ( )
407
419
render ( < MetricsSection /> , {
408
- wrapper : wrapper ( ' /gh/owner/repo/tests/main' ) ,
420
+ wrapper : wrapper ( ` /gh/owner/repo/tests/${ encodedBranch } ` ) ,
409
421
} )
410
422
const select = await screen . findByText ( 20 )
411
423
expect ( select ) . toBeInTheDocument ( )
0 commit comments