Files
paseo/packages/app/src/utils/split-navigation.test.ts
T
Mohamed Boudra ab274d635e Make the workspace right pane a first-class tab host (#3287)
* feat(app): add persistent workspace side panes

Keep the common review and file-browsing workflow beside the active agent without tearing down pane contents. Workspace tabs now share one compact chip language, assistant file links route into the retained right pane, and diff/file trees share stable geometry.

* fix(app): localize pull request empty state

* test(app): update explorer pane coverage

* fix(app): preserve explorer pane workflows

* test(app): make explorer tab selection idempotent

* fix(app): persist workspace review pins

* fix(app): preserve sidebar scrim drag hook

* fix(app): restore companion pane interactions

* test(app): follow selected sidebar surface
2026-08-16 18:18:32 +02:00

96 lines
2.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { SplitNode } from "@/stores/workspace-layout-store";
import { findAdjacentPane } from "./split-navigation";
function createPaneNode(id: string, hidden = false): SplitNode {
return {
kind: "pane",
pane: {
id,
tabIds: [],
focusedTabId: null,
...(hidden ? { hidden: true } : {}),
},
};
}
function createGroupNode(input: {
direction: "horizontal" | "vertical";
sizes: number[];
children: SplitNode[];
}): SplitNode {
return {
kind: "group",
group: {
id: `${input.direction}-group`,
direction: input.direction,
sizes: input.sizes,
children: input.children,
},
};
}
describe("findAdjacentPane", () => {
it("finds direct horizontal and vertical neighbors in nested layouts", () => {
const root = createGroupNode({
direction: "horizontal",
sizes: [0.25, 0.5, 0.25],
children: [
createPaneNode("left"),
createGroupNode({
direction: "vertical",
sizes: [0.5, 0.5],
children: [createPaneNode("top-middle"), createPaneNode("bottom-middle")],
}),
createPaneNode("right"),
],
});
expect(findAdjacentPane(root, "top-middle", "left")).toBe("left");
expect(findAdjacentPane(root, "top-middle", "right")).toBe("right");
expect(findAdjacentPane(root, "top-middle", "down")).toBe("bottom-middle");
expect(findAdjacentPane(root, "bottom-middle", "up")).toBe("top-middle");
});
it("returns null when there is no pane in the requested direction", () => {
const root = createGroupNode({
direction: "horizontal",
sizes: [0.5, 0.5],
children: [createPaneNode("left"), createPaneNode("right")],
});
expect(findAdjacentPane(root, "left", "left")).toBeNull();
expect(findAdjacentPane(root, "right", "right")).toBeNull();
expect(findAdjacentPane(root, "left", "up")).toBeNull();
});
it("prefers the closest overlapping pane when multiple candidates exist", () => {
const root = createGroupNode({
direction: "vertical",
sizes: [0.5, 0.5],
children: [
createPaneNode("top"),
createGroupNode({
direction: "horizontal",
sizes: [0.5, 0.5],
children: [createPaneNode("bottom-left"), createPaneNode("bottom-right")],
}),
],
});
expect(findAdjacentPane(root, "top", "down")).toBe("bottom-left");
expect(findAdjacentPane(root, "bottom-right", "up")).toBe("top");
});
it("skips hidden panes", () => {
const root = createGroupNode({
direction: "horizontal",
sizes: [0.3, 0.3, 0.4],
children: [createPaneNode("left"), createPaneNode("hidden", true), createPaneNode("right")],
});
expect(findAdjacentPane(root, "left", "right")).toBe("right");
expect(findAdjacentPane(root, "hidden", "right")).toBeNull();
});
});