DEV: Abort qunit tests when clicking in the toolbar (#17989)

Ever opened `/tests`, immediately tried to change the config, and got frustrated that focus keeps getting stolen by the running tests? Worry no more - this commit will make the tests auto-abort when you click any of the input/dropdowns in the QUnit header. It's not perfect - abort will wait until the end of the currently running test, so sometimes focus will be stolen one more time. But it's still a lot better than having to manually find and click the abort button.
This commit is contained in:
David Taylor 2022-08-18 23:32:38 +01:00 committed by GitHub
parent 542cd1ff90
commit df9e546f5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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() {