From ed9df3f57d890ddaf7a25fa6c86b2fb2f743a157 Mon Sep 17 00:00:00 2001 From: Vance Ingalls Date: Thu, 9 Jul 2026 01:08:06 -0700 Subject: [PATCH] test(sdk): cover script-patch skip and stylesheet-patch mirroring in attachSync --- packages/sdk/src/adapters/iframe.sync.test.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) 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"); + }); });