mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
feat(studio): apps embedding Studio can style a sealed pick as Studio's panel does (#8614)
* test(studio): an embedding app styles a sealed pick through the public API * feat(studio): apps embedding Studio can style a sealed pick as Studio's panel does
This commit is contained in:
@@ -59,14 +59,18 @@ export {
|
||||
previewPointerTargets,
|
||||
queryPreviewElements,
|
||||
type PreviewElement,
|
||||
type PreviewElementEdit,
|
||||
type PreviewElementHit,
|
||||
} from "./player/lib/previewElements";
|
||||
export {
|
||||
editSealedSelection,
|
||||
findPreviewElementForSelection,
|
||||
findPreviewElementForTimelineElement,
|
||||
readable,
|
||||
resolveFoundSelection,
|
||||
standInFor,
|
||||
standInHandle,
|
||||
type PreviewSelectionOptions,
|
||||
} from "./components/editor/previewSelection";
|
||||
export { PREVIEW_QUALITY_LEVELS, type PreviewQuality } from "@hyperframes/core/preview-quality";
|
||||
export type {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { sealedPreviewFrame } from "./player/lib/sealedPreviewFrame.test-helpers";
|
||||
import {
|
||||
describePreviewElements,
|
||||
editSealedSelection,
|
||||
queryPreviewElements,
|
||||
resolveFoundSelection,
|
||||
} from "./index";
|
||||
|
||||
const FIXTURE = `
|
||||
<div data-composition-id="main" data-width="1920" data-height="1080">
|
||||
<h1 id="target" style="opacity: 0.8">Ship it</h1>
|
||||
</div>`;
|
||||
const CONTEXT = { activeCompositionPath: "index.html", isMasterView: false };
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
// An app embedding Studio styles a sealed pick the way Studio's own panel does: one selection, one preview owner.
|
||||
it("an app embedding Studio previews a style on a sealed pick and puts it back, through the public API", async () => {
|
||||
document.body.innerHTML = FIXTURE;
|
||||
const { iframe } = sealedPreviewFrame();
|
||||
const [match] = (await queryPreviewElements(iframe, "#target"))!.matches;
|
||||
const [described] = (await describePreviewElements(iframe, [match!.handle]))!;
|
||||
|
||||
const selection = await resolveFoundSelection(iframe, described!, CONTEXT);
|
||||
expect(selection?.handle).toBe(match!.handle);
|
||||
expect(selection?.computedStyles.opacity).toBe("0.8");
|
||||
|
||||
const target = document.getElementById("target")!;
|
||||
const edit = editSealedSelection(iframe, selection!, { styles: [["opacity", "0.3"]] })!;
|
||||
expect(await edit.drawn).toBe(true);
|
||||
expect(target.style.opacity).toBe("0.3");
|
||||
edit.restore();
|
||||
await vi.waitFor(() => expect(target.style.opacity).toBe("0.8"));
|
||||
});
|
||||
Reference in New Issue
Block a user