Skip to content
Prev Previous commit
Next Next commit
Update frontend tests for new shadow DOM structure
  • Loading branch information
federicobond committed Apr 22, 2026
commit aef37bff9de9480f6f27aa4b4d7f052c548b4446
26 changes: 17 additions & 9 deletions tests/js/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,21 @@ describe("utils.js", () => {

beforeEach(() => {
vi.stubGlobal("fetch", vi.fn());
const djDebugRoot = document.createElement("div");
djDebugRoot.id = "djDebugRoot";
const djDebug = document.createElement("div");
djDebug.id = "djDebug";
const win = document.createElement("div");
win.id = "djDebugWindow";
document.body.appendChild(win);
djDebug.appendChild(win);
djDebugRoot.appendChild(djDebug);
document.body.appendChild(djDebugRoot);
});

afterEach(() => {
vi.unstubAllGlobals();
const win = document.getElementById("djDebugWindow");
if (win) document.body.removeChild(win);
const djDebugRoot = document.getElementById("djDebugRoot");
if (djDebugRoot) document.body.removeChild(djDebugRoot);
});

it("returns json data on success", async () => {
Expand Down Expand Up @@ -246,17 +252,21 @@ describe("utils.js", () => {

describe("replaceToolbarState", () => {
it("replaces toolbar state and panels", () => {
const djDebugRoot = document.createElement("div");
djDebugRoot.id = "djDebugRoot";
const djDebug = document.createElement("div");
djDebug.id = "djDebug";
document.body.appendChild(djDebug);

const panel = document.createElement("div");
panel.id = "panel1";
document.body.appendChild(panel);
djDebug.appendChild(panel);

const buttonContainer = document.createElement("div");
buttonContainer.id = "djdt-panel1";
document.body.appendChild(buttonContainer);
djDebug.appendChild(buttonContainer);

djDebugRoot.appendChild(djDebug);
document.body.appendChild(djDebugRoot);

const data = {
panel1: {
Expand All @@ -275,9 +285,7 @@ describe("utils.js", () => {
"New Button"
);

document.body.removeChild(djDebug);
document.body.removeChild(document.getElementById("panel1"));
document.body.removeChild(document.getElementById("djdt-panel1"));
document.body.removeChild(djDebugRoot);
});
});

Expand Down
Loading