mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
* fix(studio): move only the dragged word, not every word sharing its tween A drag on one element whose position tween also targets its siblings (a stagger on a shared class) now persists that element's own offset instead of rewriting the shared tween. The motion-path overlay leaves such a tween read-only, and every write of one drag records as one undo step. * fix(studio): keep the comment share flat in the word-move fix * fix(studio): save a shared-tween word's move as left/top on that word A CSS translate offset on an element a GSAP tween still drives gets folded into GSAP's transform, so render, preview and a second drag disagreed. left/top is never parsed by GSAP, adds to any offset the word already has, and is refused when it would not shift the box exactly. The resize anchor move takes the same channel, and tweens that miss the element or are shared with siblings no longer steer a drag that has its own tween. * refactor(studio): drop the untested own-tween selector override in the drag * fix(studio): keep a Layers-picked word's move and make a resize one undo step A word picked in the Layers panel is lifted to position:relative for display only; the move now reads the authored position, saves position:relative, and survives deselect. An anchored resize saves its move after the size, under the same undo key, and drops it when the size save fails. A percent left or top gets its own refusal message. * fix(studio): give the host canvas hook the per-word left/top move The host geometry hook now stages a shared-tween word's move with the same left/top offset as the editor, saved through the host's patch path, so a Desktop drag of one word moves only that word. * fix(studio): keep host word moves saving after one failed save The host canvas hook reset its save queue per save, as the host style hook does, so one conflict no longer pauses every later word move. A save error the patch path already showed is no longer covered by a generic failure toast.
76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
// @vitest-environment happy-dom
|
|
|
|
import React, { act } from "react";
|
|
import { beforeEach, describe, expect, it, vi, type Mock } from "vitest";
|
|
import type { DomEditSelection } from "../components/editor/domEditingTypes";
|
|
import { mountReactHarness } from "./domSelectionTestHarness";
|
|
import { GsapEditBlockedError } from "./gsapEditOutcome";
|
|
|
|
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
const { trackStudioEditBlocked, trackStudioSaveFailure } = vi.hoisted(() => ({
|
|
trackStudioEditBlocked: vi.fn(),
|
|
trackStudioSaveFailure: vi.fn(),
|
|
}));
|
|
vi.mock("../utils/studioSaveDiagnostics", async (importOriginal) => ({
|
|
...(await importOriginal<object>()),
|
|
trackStudioEditBlocked,
|
|
trackStudioSaveFailure,
|
|
}));
|
|
|
|
import { useGsapInteractionFailureTelemetry } from "./useGsapInteractionFailureTelemetry";
|
|
|
|
const selection = {
|
|
id: "clip",
|
|
selector: "#clip",
|
|
element: document.createElement("div"),
|
|
} as unknown as DomEditSelection;
|
|
|
|
function mountFailureTelemetry(showToast: Mock) {
|
|
let report!: ReturnType<typeof useGsapInteractionFailureTelemetry>;
|
|
function Harness() {
|
|
report = useGsapInteractionFailureTelemetry("index.html", showToast);
|
|
return null;
|
|
}
|
|
const root = mountReactHarness(<Harness />);
|
|
return { report, root };
|
|
}
|
|
|
|
describe("useGsapInteractionFailureTelemetry", () => {
|
|
beforeEach(() => {
|
|
trackStudioEditBlocked.mockClear();
|
|
trackStudioSaveFailure.mockClear();
|
|
});
|
|
|
|
it("tracks an expected edit block separately from save failures", () => {
|
|
const showToast = vi.fn();
|
|
const { report, root } = mountFailureTelemetry(showToast);
|
|
|
|
act(() => report(new GsapEditBlockedError("unroll-required"), selection, "drag", "Move"));
|
|
|
|
expect(showToast).toHaveBeenCalledWith(
|
|
"This motion comes from a helper or loop. Choose Unroll to edit it explicitly.",
|
|
"error",
|
|
);
|
|
expect(trackStudioEditBlocked).toHaveBeenCalledWith(
|
|
expect.objectContaining({ source: "gsap_commit", mutationType: "drag", targetId: "clip" }),
|
|
);
|
|
expect(trackStudioSaveFailure).not.toHaveBeenCalled();
|
|
act(() => root.unmount());
|
|
});
|
|
|
|
it("keeps unexpected GSAP persistence errors in save_failure", () => {
|
|
const showToast = vi.fn();
|
|
const { report, root } = mountFailureTelemetry(showToast);
|
|
const error = new Error("network dropped");
|
|
|
|
act(() => report(error, selection, "drag", "Move"));
|
|
|
|
expect(trackStudioSaveFailure).toHaveBeenCalledWith(
|
|
expect.objectContaining({ source: "gsap_commit", error, mutationType: "drag" }),
|
|
);
|
|
expect(trackStudioEditBlocked).not.toHaveBeenCalled();
|
|
act(() => root.unmount());
|
|
});
|
|
});
|