mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 14:27:26 +00:00
* feat(studio): every Studio panel is a dock panel and the shell moves onto it
EditorShell, App.tsx, the left and right panel columns, and the
inspector hooks now render through Dock.Panel instead of the old
fixed-width sidebars and split-pane inspector. usePanelLayout becomes
a thin facade over the dock store; fitPanels, the resize divider and
the split-inspector hook are dead and removed.
* refactor(studio): drop dead inspector flags and stale fallow entries after dock migration
Collapse inspectorButtonActive into inspectorPanelActive, remove unread
layers/design active fields, un-export unused prop types, flatten a nested
ternary, and point fallow ignores at the renamed/deleted files.
* fix(studio): keep right-panel behaviours the dock migration dropped
Block params dismiss on selection or when Design is hidden, the slideshow
panel can be closed, the selection outline follows the inspector intent,
caption editing focuses Design, and a URL slideshow tab opens once the
panel exists.
* refactor(studio): name the inspector-open state once in the header
* fix(studio): right-panel behaviours survive selection, restore and reopen after the dock migration
Block params stay open over an element that was already selected, caption mode wins over block params, the slideshow panel waits for the dock, the Renders tab title survives a reopen, each side column remembers the tab it last showed, tab switches are reported only when the tab changes, and the e2e thumbnail selector follows the dock.
* docs(studio): describe the dock layout and point comments at the renamed right panels
* fix(studio): block params survive a preview reload of the selected element, and panel titles are covered
The dismissal compares the selected element by its target key instead of object identity, because a preview reload rebuilds the selection for the same element. A closed and reopened panel keeps its custom title, with a test, and the e2e selector is formatted.
* fix(studio): block params leave with any other tab pick, and a restored slideshow placement survives loading
Block params are now dismissed by the tab setter the way their old tab was, including a re-pick of the same element, instead of by comparing selections. The slideshow panel is only closed after a file that was a slideshow stops being one, so a restored layout is not discarded while the file loads.
* refactor(studio): drop the duplicate inspector-open computation
The rebase onto main left two identical inspectorButtonActive/inspectorOpen
constants after a conflict resolution; only the first was still referenced.
* chore(studio): allow the dock migration deletions in the guard
StudioLeftSidebar.tsx, LeftSidebar.tsx and its storage test,
TimelineResizeDivider.tsx, useInspectorSplitResize.ts and fitPanels
are replaced by the dock; the CI deletion guard needs each named
with its reason.
* style(studio): oxfmt the deletion-guard entries
* fix(studio): rename Timeline's aria-label so it does not collide with its dock panel wrapper
Every dock panel wrapper now carries aria-label=<title>, matching the "Timeline"
title for the timeline panel. Timeline.tsx also set aria-label="Timeline" on its
own content div, so `document.querySelector('[aria-label=\"Timeline\"]')` found
the dock wrapper first and the timeline viewport gate CI check timed out waiting
for an attribute the real content div actually carried. Renamed to "Timeline
track view" and updated every consumer: the production diagnostics selector,
its tests, and the e2e viewport-gate script.
* fix(studio): restore inspectorButtonActive as a real prop after a rebase regression
Rebasing PR2 onto main replayed an older local commit whose diff did not
textually overlap main's newer inspectorButtonActive prop, so git applied
it with no conflict marker and silently reverted the header to computing
the value itself instead of receiving it. StudioHeader.dom.test.tsx already
asserts the prop is respected; restoring it makes that test meaningful
again. App.tsx now computes it once (panelLayout.rightCollapsed is already
the dock's effective collapse state, no separate railed-by-width case) and
passes it down.
* chore(studio): wrap a long doc comment in useRightPanelIntents
153 lines
5.8 KiB
TypeScript
153 lines
5.8 KiB
TypeScript
// @vitest-environment happy-dom
|
|
|
|
import React, { act } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { useDockLayoutStore, type DockController } from "../components/dock/dockLayoutStore";
|
|
import { PANEL_IDS, type PanelId } from "../components/dock/panelRegistry";
|
|
import { trackStudioEvent } from "../utils/studioTelemetry";
|
|
import { usePanelLayout, type InitialPanelLayoutState } from "./usePanelLayout";
|
|
|
|
(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
vi.mock("../utils/studioTelemetry", () => ({ trackStudioEvent: vi.fn() }));
|
|
|
|
function fakeController(): DockController {
|
|
return {
|
|
open: vi.fn(),
|
|
activate: vi.fn(),
|
|
close: vi.fn(),
|
|
setTitle: vi.fn(),
|
|
setGroupVisible: vi.fn(),
|
|
reset: vi.fn(),
|
|
};
|
|
}
|
|
|
|
function showDock(visible: PanelId[], controller = fakeController()) {
|
|
useDockLayoutStore.setState({
|
|
controller,
|
|
openPanels: new Set(PANEL_IDS),
|
|
visiblePanels: new Set(visible),
|
|
lastActive: {},
|
|
activePanel: null,
|
|
});
|
|
return controller;
|
|
}
|
|
|
|
function renderLayout(initial?: InitialPanelLayoutState) {
|
|
const host = document.createElement("div");
|
|
document.body.append(host);
|
|
const root = createRoot(host);
|
|
let current: ReturnType<typeof usePanelLayout> | null = null;
|
|
function Harness() {
|
|
current = usePanelLayout(initial);
|
|
return null;
|
|
}
|
|
act(() => root.render(React.createElement(Harness)));
|
|
return {
|
|
get layout() {
|
|
if (!current) throw new Error("layout not rendered");
|
|
return current;
|
|
},
|
|
unmount: () => act(() => root.unmount()),
|
|
};
|
|
}
|
|
|
|
beforeEach(() => vi.mocked(trackStudioEvent).mockClear());
|
|
afterEach(() => {
|
|
document.body.innerHTML = "";
|
|
useDockLayoutStore.setState({ controller: null });
|
|
});
|
|
|
|
describe("usePanelLayout over the dock", () => {
|
|
it("reads the tab of the right-zone panel that is showing", () => {
|
|
showDock(["preview", "timeline", "compositions", "renders"]);
|
|
const view = renderLayout();
|
|
expect(view.layout.rightPanelTab).toBe("renders");
|
|
expect(view.layout.rightCollapsed).toBe(false);
|
|
});
|
|
|
|
it("is collapsed when no right-zone panel is showing", () => {
|
|
showDock(["preview", "timeline", "compositions"]);
|
|
const view = renderLayout();
|
|
expect(view.layout.rightCollapsed).toBe(true);
|
|
expect(view.layout.rightPanelTab).toBe("design");
|
|
});
|
|
|
|
it("opens the Design panel for the legacy block-params tab and reports the tab switch", () => {
|
|
const controller = showDock(["preview"]);
|
|
const view = renderLayout();
|
|
act(() => view.layout.setRightPanelTab("block-params"));
|
|
expect(controller.setGroupVisible).toHaveBeenCalledWith("design", true);
|
|
expect(controller.activate).toHaveBeenCalledWith("design");
|
|
expect(trackStudioEvent).toHaveBeenCalledWith("tab_switch", {
|
|
panel: "right_panel",
|
|
tab: "block-params",
|
|
});
|
|
});
|
|
|
|
it("reports a tab switch only when the tab actually changes", () => {
|
|
showDock(["preview", "design"]);
|
|
const view = renderLayout();
|
|
vi.mocked(trackStudioEvent).mockClear();
|
|
act(() => view.layout.setRightPanelTab("design"));
|
|
expect(trackStudioEvent).not.toHaveBeenCalled();
|
|
act(() => view.layout.setRightPanelTab("layers"));
|
|
expect(trackStudioEvent).toHaveBeenCalledWith("tab_switch", {
|
|
panel: "right_panel",
|
|
tab: "layers",
|
|
});
|
|
});
|
|
|
|
it("collapses every open right-zone panel group and leaves the other zones alone", () => {
|
|
const controller = showDock(["preview", "design"]);
|
|
const view = renderLayout();
|
|
act(() => view.layout.setRightCollapsed(true));
|
|
const hidden = vi.mocked(controller.setGroupVisible).mock.calls;
|
|
expect(hidden.map(([id]) => id).sort()).toEqual(
|
|
["design", "layers", "renders", "slideshow", "variables"].sort(),
|
|
);
|
|
expect(hidden.every(([, visible]) => visible === false)).toBe(true);
|
|
});
|
|
|
|
it("expanding an already-showing right column does nothing to the tab", () => {
|
|
const controller = showDock(["design"]);
|
|
const view = renderLayout();
|
|
act(() => view.layout.setRightCollapsed(false));
|
|
expect(controller.activate).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("expanding a fully hidden right column brings Design back", () => {
|
|
const controller = showDock(["preview"]);
|
|
const view = renderLayout();
|
|
act(() => view.layout.setRightCollapsed(false));
|
|
expect(controller.activate).toHaveBeenCalledWith("design");
|
|
});
|
|
|
|
it("applies the URL's tab and collapse state once, when the dock attaches", () => {
|
|
useDockLayoutStore.setState({ controller: null, openPanels: new Set(PANEL_IDS) });
|
|
const view = renderLayout({ rightPanelTab: "variables", rightCollapsed: true });
|
|
const controller = fakeController();
|
|
act(() => useDockLayoutStore.getState().attach(controller));
|
|
expect(controller.activate).toHaveBeenCalledWith("variables");
|
|
expect(controller.setGroupVisible).toHaveBeenCalledWith("design", false);
|
|
const later = fakeController();
|
|
act(() => useDockLayoutStore.getState().attach(later));
|
|
expect(later.activate).not.toHaveBeenCalled();
|
|
expect(later.setGroupVisible).not.toHaveBeenCalled();
|
|
view.unmount();
|
|
});
|
|
|
|
it("keeps a URL's slideshow tab until the panel opens, then activates it once", () => {
|
|
const opened = new Set<PanelId>(PANEL_IDS.filter((id) => id !== "slideshow"));
|
|
useDockLayoutStore.setState({ controller: null, openPanels: opened });
|
|
const view = renderLayout({ rightPanelTab: "slideshow" });
|
|
const controller = fakeController();
|
|
act(() => useDockLayoutStore.getState().attach(controller));
|
|
expect(controller.activate).not.toHaveBeenCalled();
|
|
act(() => useDockLayoutStore.setState({ openPanels: new Set(PANEL_IDS) }));
|
|
expect(controller.activate).toHaveBeenCalledWith("slideshow");
|
|
view.unmount();
|
|
});
|
|
});
|