Files
hyperframes/packages/studio/src/utils/rootDuration.test.ts
T
Miguel Angel Simon Sierra 5e3ca6ae63 feat(studio): drag a clip past the video end to extend its duration
Dragging a timeline clip (or its right resize edge) past the end of the
video now extends the composition duration on drop, instead of clamping
the clip at the current end. Extend-only and undoable.

- Relax the move/resize horizontal clamps that pinned a clip's end at the
  current duration; effectiveDuration now folds in the active drag/resize
  preview so the ruler and track width grow live as you drag past the end.
- On drop, extend the root composition data-duration (and the store) when
  the clip's new end exceeds it, via a shared extendRootDurationInSource
  helper extracted from the block installer (now the single owner of that
  logic). An extending edit routes through the server persist path since
  the SDK setTiming op can't express the root composition's own duration.
2026-07-08 23:46:27 -04:00

35 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { extendRootDurationInSource } from "./rootDuration";
describe("extendRootDurationInSource", () => {
it("extends data-duration when the new end is bigger than the root duration", () => {
const source = [
`<div data-composition-id="main" data-duration="4">`,
` <section id="clip" data-start="2" data-duration="3"></section>`,
`</div>`,
].join("\n");
expect(extendRootDurationInSource(source, 5.25)).toContain(
`data-composition-id="main" data-duration="5.25"`,
);
});
it("does nothing when the new end is smaller than or equal to the root duration", () => {
const source = `<div data-composition-id="main" data-duration="6"></div>`;
expect(extendRootDurationInSource(source, 5)).toBe(source);
expect(extendRootDurationInSource(source, 6)).toBe(source);
});
it("leaves non-root data-duration attributes untouched by the extension", () => {
const source = [
`<div data-duration="3"></div>`,
`<div data-composition-id="main" data-duration="4"></div>`,
].join("\n");
const patched = extendRootDurationInSource(source, 7);
expect(patched).toContain(`<div data-duration="3"></div>`);
expect(patched).toContain(`<div data-composition-id="main" data-duration="7"></div>`);
});
});