Skip to content

Commit 8c3da13

Browse files
committed
test(studio): assert automation labels against the real curve, not a formula
The previous test recomputed the expected top with the same formula the fix uses, so a regression in TimelineAutomationLaneSlot's own offset would still read green. Moved it to TimelineLanes.test.tsx, which mounts both the header and the canvas, and compares their rendered [data-automation-lane-label]/[data-automation-lane] tops directly.
1 parent 6980d4f commit 8c3da13

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎packages/studio/src/player/components/TimelineLanes.test.tsx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,27 @@ describe("TimelineLanes audio disclosure", () => {
314314
expect(usePlayerStore.getState().expandedLaneOwnerIds).toEqual(new Set(["audio-1", "audio-2"]));
315315
act(() => view.root.unmount());
316316
});
317+
318+
it("keeps a second automation label aligned with its own curve", () => {
319+
const audio = element("audio-clip", TRACK_A);
320+
audio.tag = "audio";
321+
audio.automation = JSON.stringify({
322+
version: 1,
323+
lanes: [
324+
{ target: "volume", points: [{ t: 0, v: 1 }] },
325+
{ target: "rate", points: [{ t: 0, v: 1 }] },
326+
],
327+
});
328+
usePlayerStore.setState({ expandedLaneOwnerIds: new Set([audio.id]) });
329+
const view = renderLanes({ elements: [audio] });
330+
331+
const labels = [...view.host.querySelectorAll<HTMLElement>("[data-automation-lane-label]")];
332+
const curves = [...view.host.querySelectorAll<HTMLElement>("[data-automation-lane]")];
333+
expect(labels).toHaveLength(2);
334+
expect(curves).toHaveLength(2);
335+
expect(labels.map((el) => el.style.top)).toEqual(curves.map((el) => el.style.top));
336+
act(() => view.root.unmount());
337+
});
317338
});
318339

319340
describe("TimelineLanes selection", () => {

‎packages/studio/src/player/components/TimelineTrackHeader.test.tsx‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
66
import { TimelineTrackHeader } from "./TimelineTrackHeader";
77
import { defaultTimelineTheme } from "./timelineTheme";
88
import type { TimelineElement } from "../store/playerStore";
9-
import { LABEL_COL_W, TRACK_H } from "./timelineLayout";
10-
import { AUTOMATION_LANE_H } from "./automationLaneHeight";
9+
import { LABEL_COL_W } from "./timelineLayout";
1110

1211
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
1312
afterEach(() => (document.body.innerHTML = ""));
@@ -108,26 +107,6 @@ describe("TimelineTrackHeader", () => {
108107
act(() => root.unmount());
109108
});
110109

111-
it("stacks a second automation label at the curve's own stride, not the keyframe stride", () => {
112-
const clip: TimelineElement = {
113-
...ELEMENT,
114-
tag: "audio",
115-
automation: JSON.stringify({
116-
version: 1,
117-
lanes: [
118-
{ target: "volume", points: [{ t: 0, v: 1 }] },
119-
{ target: "rate", points: [{ t: 0, v: 1 }] },
120-
],
121-
}),
122-
};
123-
const { host, root } = renderHeader({ clip, audio: true });
124-
const labels = [...host.querySelectorAll<HTMLElement>("[data-automation-lane-label]")];
125-
expect(labels).toHaveLength(2);
126-
const curveTops = labels.map((_, index) => TRACK_H + index * AUTOMATION_LANE_H);
127-
expect(labels.map((el) => Number(el.dataset.timelineLaneTop))).toEqual(curveTops);
128-
act(() => root.unmount());
129-
});
130-
131110
it("names a shared audio track rather than the selected clip", () => {
132111
const automation = JSON.stringify({
133112
version: 1,

0 commit comments

Comments
 (0)