mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 14:27:26 +00:00
test(studio): cut and delete record under the drop's fold key, delete does not ripple
This commit is contained in:
@@ -58,6 +58,7 @@ describe("useTimelineDeleteOps: ripple undo label", () => {
|
||||
function mountDeleteHarness(overrides: {
|
||||
handleTimelineGroupMove: DeleteOpsOptions["handleTimelineGroupMove"];
|
||||
showToast?: DeleteOpsOptions["showToast"];
|
||||
recordEdit?: DeleteOpsOptions["recordEdit"];
|
||||
}) {
|
||||
const elements = [el("hf-a", 0, 2), el("hf-b", 2, 2), el("hf-c", 4, 2)];
|
||||
let hook: ReturnType<typeof useTimelineDeleteOps> | null = null;
|
||||
@@ -68,7 +69,7 @@ describe("useTimelineDeleteOps: ripple undo label", () => {
|
||||
timelineElements: elements,
|
||||
showToast: overrides.showToast ?? vi.fn(),
|
||||
writeProjectFile: vi.fn().mockResolvedValue(undefined),
|
||||
recordEdit: vi.fn().mockResolvedValue(undefined),
|
||||
recordEdit: overrides.recordEdit ?? vi.fn().mockResolvedValue(undefined),
|
||||
reloadPreview: vi.fn(),
|
||||
previewIframeRef: { current: null },
|
||||
handleTimelineGroupMove: overrides.handleTimelineGroupMove,
|
||||
@@ -116,4 +117,24 @@ describe("useTimelineDeleteOps: ripple undo label", () => {
|
||||
expect.objectContaining({ suppressFailureToast: true }),
|
||||
);
|
||||
});
|
||||
|
||||
it("an overwrite delete records under the drop's fold key and never ripples the main track", async () => {
|
||||
const handleTimelineGroupMove = vi.fn().mockResolvedValue(undefined);
|
||||
const recordEdit = vi.fn().mockResolvedValue(undefined);
|
||||
const { b, getHook } = mountDeleteHarness({ handleTimelineGroupMove, recordEdit });
|
||||
let deleted: boolean | undefined;
|
||||
|
||||
await act(async () => {
|
||||
deleted = await getHook().deleteTimelineElements([b], {
|
||||
coalesceKey: "clip-overwrite:3",
|
||||
coalesceMs: Number.POSITIVE_INFINITY,
|
||||
});
|
||||
});
|
||||
|
||||
expect(deleted).toBe(true);
|
||||
expect(handleTimelineGroupMove).not.toHaveBeenCalled();
|
||||
expect(recordEdit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ coalesceKey: "clip-overwrite:3", coalesceMs: Infinity }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -141,6 +141,26 @@ describe("runAtomicCutTransaction", () => {
|
||||
expect(result).toMatchObject({ splitCount: 1, syncFailed: false });
|
||||
});
|
||||
|
||||
it("records the cut under the caller's fold key so it merges into one undo step", async () => {
|
||||
installCutServer();
|
||||
const recordEdit = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
await runAtomicCutTransaction({
|
||||
projectId: "p1",
|
||||
intents: buildAtomicCutIntents([element()], 2, "index.html"),
|
||||
label: "Split timeline clip",
|
||||
coalesceKey: "clip-overwrite:7",
|
||||
coalesceMs: Number.POSITIVE_INFINITY,
|
||||
writeProjectFile: vi.fn(),
|
||||
recordEdit,
|
||||
synchronize: vi.fn(),
|
||||
});
|
||||
|
||||
expect(recordEdit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ coalesceKey: "clip-overwrite:7", coalesceMs: Infinity }),
|
||||
);
|
||||
});
|
||||
|
||||
it("CAS-restores durable bytes when history registration fails", async () => {
|
||||
installCutServer();
|
||||
const writeProjectFile = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
Reference in New Issue
Block a user