DEV: Clean up HTML state between tests

A bunch of tests were leaving leftovers in the DOM like class names,
custom styles and scroll positions. This ensures they are cleared
between tests.
This commit is contained in:
Robin Ward 2022-01-27 15:53:53 -05:00
parent 23d7fcf9a1
commit 3350657553

View File

@ -342,8 +342,20 @@ function setupTestsCommon(application, container, config) {
resetPretender(); resetPretender();
clearPresenceState(); clearPresenceState();
// Destroy any modals // Clean up the DOM. Some tests might leave extra classes or elements behind.
$(".modal-backdrop").remove(); Array.from(document.getElementsByClassName("modal-backdrop")).forEach((e) =>
e.remove()
);
document.body.removeAttribute("class");
let html = document.getElementsByTagName("html")[0];
html.removeAttribute("class");
html.removeAttribute("style");
let testing = document.getElementById("ember-testing");
testing.removeAttribute("class");
testing.removeAttribute("style");
let testContainer = document.getElementById("ember-testing-container");
testContainer.scrollTop = 0;
flushMap(); flushMap();
MessageBus.unsubscribe("*"); MessageBus.unsubscribe("*");