A platform for community discussion. Free, open, simple.
DEV: Abort qunit tests when clicking in the toolbar (#17989)
David Taylordf9e546f5dca
diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.jsindex f8e37d3aa5a..4b76abc5028 100644--- a/app/assets/javascripts/discourse/tests/setup-tests.js+++ b/app/assets/javascripts/discourse/tests/setup-tests.js@@ -150,6 +150,23 @@ function setupToolbar() {label: "Plugin",value: Array.from(pluginNames),});++ // Abort tests when the qunit controls are clicked+ document.querySelector("#qunit").addEventListener("click", ({ target }) => {+ if (!target.closest("#qunit-testrunner-toolbar")) {+ // Outside toolbar, carry on+ return;+ }++ if (target.closest("label[for=qunit-urlconfig-hidepassed]")) {+ // This one can be toggled during tests, carry on+ return;+ }++ if (["INPUT", "SELECT", "LABEL"].includes(target.tagName)) {+ document.querySelector("#qunit-abort-tests-button")?.click();+ }+ });}function reportMemoryUsageAfterTests() {