mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 13:39:36 -06:00
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:
parent
542cd1ff90
commit
df9e546f5d
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user