Skip to content

Commit c156335

Browse files
authored
Fix non-standard suites and tags with developerMode (#506)
- Fixes issue #489 by properly updating the params from the developer menu - Keep params and Suites selection in sync - Refactor updateParamsSuitesAndTags into separate method
1 parent 5e7cec8 commit c156335

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

resources/developer-mode.mjs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function createUIForSuites() {
127127
checkbox.checked = !suite.disabled;
128128
checkbox.onchange = () => {
129129
suite.disabled = !checkbox.checked;
130+
updateParamsSuitesAndTags();
130131
updateURL();
131132
};
132133
checkboxes.push(checkbox);
@@ -235,34 +236,41 @@ function createUIForRun() {
235236
return buttons;
236237
}
237238

238-
function updateURL() {
239-
const url = new URL(window.location.href);
239+
function updateParamsSuitesAndTags() {
240+
params.suites = [];
241+
params.tags = [];
240242

241243
// If less than all suites are selected then change the URL "Suites" GET parameter
242244
// to comma separate only the selected
243245
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);
244265

245266
url.searchParams.delete("tags");
246267
url.searchParams.delete("suites");
247268
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(","));
266274

267275
const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync", "useAsyncSteps"];
268276
for (const paramKey of defaultParamKeys) {

0 commit comments

Comments
 (0)