@@ -127,6 +127,7 @@ function createUIForSuites() {
127
127
checkbox . checked = ! suite . disabled ;
128
128
checkbox . onchange = ( ) => {
129
129
suite . disabled = ! checkbox . checked ;
130
+ updateParamsSuitesAndTags ( ) ;
130
131
updateURL ( ) ;
131
132
} ;
132
133
checkboxes . push ( checkbox ) ;
@@ -235,34 +236,41 @@ function createUIForRun() {
235
236
return buttons ;
236
237
}
237
238
238
- function updateURL ( ) {
239
- const url = new URL ( window . location . href ) ;
239
+ function updateParamsSuitesAndTags ( ) {
240
+ params . suites = [ ] ;
241
+ params . tags = [ ] ;
240
242
241
243
// If less than all suites are selected then change the URL "Suites" GET parameter
242
244
// to comma separate only the selected
243
245
const selectedSuites = Suites . filter ( ( suite ) => ! suite . disabled ) ;
246
+ if ( ! selectedSuites . length )
247
+ return ;
248
+
249
+ // Try finding common tags that would result in the current suite selection.
250
+ let commonTags = new Set ( selectedSuites [ 0 ] . tags ) ;
251
+ for ( const suite of Suites ) {
252
+ if ( suite . disabled )
253
+ suite . tags . forEach ( ( tag ) => commonTags . delete ( tag ) ) ;
254
+ else
255
+ commonTags = new Set ( suite . tags . filter ( ( tag ) => commonTags . has ( tag ) ) ) ;
256
+ }
257
+ if ( selectedSuites . length > 1 && commonTags . size )
258
+ params . tags = commonTags . has ( "default" ) ? [ ] : [ ...commonTags ] ;
259
+ else
260
+ params . suites = selectedSuites . map ( ( suite ) => suite . name ) ;
261
+ }
262
+
263
+ function updateURL ( ) {
264
+ const url = new URL ( window . location . href ) ;
244
265
245
266
url . searchParams . delete ( "tags" ) ;
246
267
url . searchParams . delete ( "suites" ) ;
247
268
url . searchParams . delete ( "suite" ) ;
248
- if ( selectedSuites . length ) {
249
- // Try finding common tags that would result in the current suite selection.
250
- let commonTags = new Set ( selectedSuites [ 0 ] . tags ) ;
251
- for ( const suite of Suites ) {
252
- if ( suite . disabled )
253
- suite . tags . forEach ( ( tag ) => commonTags . delete ( tag ) ) ;
254
- else
255
- commonTags = new Set ( suite . tags . filter ( ( tag ) => commonTags . has ( tag ) ) ) ;
256
- }
257
- if ( selectedSuites . length > 1 && commonTags . size ) {
258
- const tags = [ ...commonTags ] [ 0 ] ;
259
- if ( tags !== "default" )
260
- url . searchParams . set ( "tags" , tags ) ;
261
- url . searchParams . delete ( "suites" ) ;
262
- } else {
263
- url . searchParams . set ( "suites" , selectedSuites . map ( ( suite ) => suite . name ) . join ( "," ) ) ;
264
- }
265
- }
269
+
270
+ if ( params . tags . length )
271
+ url . searchParams . set ( "tags" , params . tags . join ( "," ) ) ;
272
+ else if ( params . suites . length )
273
+ url . searchParams . set ( "suites" , params . suites . join ( "," ) ) ;
266
274
267
275
const defaultParamKeys = [ "iterationCount" , "useWarmupSuite" , "warmupBeforeSync" , "waitBeforeSync" , "useAsyncSteps" ] ;
268
276
for ( const paramKey of defaultParamKeys ) {
0 commit comments