From e8295b4f5ab735d708305f17b76eaf839b64fb4d Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Fri, 18 Sep 2026 21:30:50 -0400 Subject: [PATCH] test(studio): cut and delete record under the drop's fold key, delete does not ripple --- .../src/hooks/useTimelineDeleteOps.test.tsx | 23 ++++++++++++++++++- .../src/utils/razorSplitTransaction.test.ts | 20 ++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx b/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx index 682cb5e829..de265a1e0b 100644 --- a/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx +++ b/packages/studio/src/hooks/useTimelineDeleteOps.test.tsx @@ -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 | 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 }), + ); + }); }); diff --git a/packages/studio/src/utils/razorSplitTransaction.test.ts b/packages/studio/src/utils/razorSplitTransaction.test.ts index 9e4a2dfebd..aca4ab1beb 100644 --- a/packages/studio/src/utils/razorSplitTransaction.test.ts +++ b/packages/studio/src/utils/razorSplitTransaction.test.ts @@ -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);