| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import { createElement, type ReactNode } from "react";
- import { renderToStaticMarkup } from "react-dom/server";
- import { describe, expect, it, vi } from "vitest";
- import { V4_PRIMARY_PANE_ID } from "@/v4/paneLayoutStore.js";
- import {
- resolvePaneActiveSelectionSideChatSessionId,
- WorkbenchLeafPane,
- type WorkbenchShellBinding,
- } from "@/v4/WorkbenchPane.js";
- vi.mock("@/v4/SessionPane.js", async () => {
- const React = await import("react");
- return {
- SessionPane: () =>
- React.createElement("div", { "data-testid": "mock-session-pane" }),
- };
- });
- vi.mock("@/v4/V4ConversationContext.js", async () => {
- const React = await import("react");
- return {
- V4PaneConversationProvider: ({ children }: { children: ReactNode }) =>
- React.createElement("div", { "data-testid": "mock-provider" }, children),
- };
- });
- function renderWorkbenchPane({
- focused,
- showFocusIndicator,
- }: {
- focused: boolean;
- showFocusIndicator: boolean;
- }): string {
- const shell = {
- workspacePath: "/repo",
- sessionId: "sess-primary",
- } as unknown as WorkbenchShellBinding;
- return renderToStaticMarkup(
- createElement(WorkbenchLeafPane, {
- paneId: V4_PRIMARY_PANE_ID,
- rect: { left: "0%", top: "0%", width: "100%", height: "100%" },
- focused,
- showFocusIndicator,
- canSplit: true,
- shellWorkspaceKey: "/repo",
- binding: null,
- shell,
- onFocusRequest: vi.fn(),
- onSplit: vi.fn(),
- onClosePane: vi.fn(),
- onConfirmRestoredSession: vi.fn(),
- onBindSession: vi.fn(),
- }),
- );
- }
- describe("WorkbenchLeafPane inactive visual state", () => {
- it("dims only non-focused panes when the workbench has multiple panes", () => {
- const inactiveMarkup = renderWorkbenchPane({
- focused: false,
- showFocusIndicator: true,
- });
- const activeMarkup = renderWorkbenchPane({
- focused: true,
- showFocusIndicator: true,
- });
- const singlePaneMarkup = renderWorkbenchPane({
- focused: false,
- showFocusIndicator: false,
- });
- expect(inactiveMarkup).toContain('data-v4-pane-inactive-overlay="true"');
- expect(inactiveMarkup).toContain("pointer-events-none");
- expect(inactiveMarkup).toContain("z-30");
- expect(activeMarkup).not.toContain('data-v4-pane-inactive-overlay="true"');
- expect(singlePaneMarkup).not.toContain(
- 'data-v4-pane-inactive-overlay="true"',
- );
- });
- });
- describe("resolvePaneActiveSelectionSideChatSessionId", () => {
- it("routes the active auxiliary child to a split pane that owns the shell active task", () => {
- expect(
- resolvePaneActiveSelectionSideChatSessionId(
- "sess-split",
- "sess-split",
- "sess-side",
- ),
- ).toBe("sess-side");
- });
- it("does not leak the active auxiliary child to another pane", () => {
- expect(
- resolvePaneActiveSelectionSideChatSessionId(
- "sess-primary",
- "sess-split",
- "sess-side",
- ),
- ).toBeNull();
- });
- });
|