diff --git a/packages/sdk/src/adapters/iframe.sync.test.ts b/packages/sdk/src/adapters/iframe.sync.test.ts index 5d577aac8..fdfabe9d9 100644 --- a/packages/sdk/src/adapters/iframe.sync.test.ts +++ b/packages/sdk/src/adapters/iframe.sync.test.ts @@ -108,4 +108,47 @@ describe("IframePreviewAdapter.attachSync", () => { ), ).toBe("#f00"); }); + + it("does NOT mirror a /script/gsap patch onto the live +`; + const iframe = mountIframe(html); + const liveScriptBefore = iframe.contentDocument!.querySelector("script")!.textContent; + + const comp = await openComposition(html); + const adapter = createIframePreviewAdapter(iframe); + adapter.attachSync(comp); + + comp.addGsapTween("hf-box", { method: "to", properties: { opacity: 1 }, duration: 1 }); + + // The offscreen model's script changed (proves the edit really happened)... + expect(comp.serialize()).not.toBe(html); + // ...but the LIVE script tag is untouched — script patches are never mirrored. + expect(iframe.contentDocument!.querySelector("script")!.textContent).toBe(liveScriptBefore); + }); + + it("DOES mirror a /style/css (stylesheet) patch onto the live +`; + const iframe = mountIframe(html); + const comp = await openComposition(html); + const adapter = createIframePreviewAdapter(iframe); + adapter.attachSync(comp); + + comp.dispatch({ type: "setClassStyle", selector: ".boxy", styles: { color: "green" } }); + + const liveStyle = iframe.contentDocument!.querySelector("style")!.textContent ?? ""; + expect(liveStyle).toContain("green"); + }); });