test(studio): cut and delete record under the drop's fold key, delete does not ripple

This commit is contained in:
Miguel Angel Simon Sierra
2026-09-19 07:03:53 -04:00
parent 67dd388821
commit e8295b4f5a
2 changed files with 42 additions and 1 deletions
@@ -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);