mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 04:56:18 +08:00
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:
parent
23d7fcf9a1
commit
3350657553
|
@ -342,8 +342,20 @@ function setupTestsCommon(application, container, config) {
|
|||
resetPretender();
|
||||
clearPresenceState();
|
||||
|
||||
// Destroy any modals
|
||||
$(".modal-backdrop").remove();
|
||||
// Clean up the DOM. Some tests might leave extra classes or elements behind.
|
||||
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();
|
||||
|
||||
MessageBus.unsubscribe("*");
|
||||
|
|
Loading…
Reference in New Issue
Block a user