Skip to content

Commit 2efecf4

Browse files
committed
test(core): add integration test for JS-created element probe scenario
1 parent a28c94f commit 2efecf4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/core/src/studio-api/helpers/sourceMutation.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,20 @@ describe("probeElementInSource", () => {
300300
const html = `<div class="item">A</div><div class="item">B</div>`;
301301
expect(probeElementInSource(html, { selector: ".item", selectorIndex: 5 })).toBe(false);
302302
});
303+
304+
it("returns false for an element that would only exist after JS execution", () => {
305+
const sourceHtml = `<!doctype html><html><head></head><body>
306+
<div id="root" data-composition-id="main">
307+
<div id="canvas"></div>
308+
<script>
309+
const svg = document.createElement("div");
310+
svg.id = "arrows-svg";
311+
document.getElementById("canvas").appendChild(svg);
312+
</script>
313+
</div>
314+
</body></html>`;
315+
316+
expect(probeElementInSource(sourceHtml, { id: "arrows-svg" })).toBe(false);
317+
expect(probeElementInSource(sourceHtml, { id: "canvas" })).toBe(true);
318+
});
303319
});

0 commit comments

Comments
 (0)