GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(web): cover the right panel toggle opening and closing the panel by andreivcodes · Pull Request #10642 · pingdotgg/t3code

test(web): cover the right panel toggle opening and closing the panel #10642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreivcodes wants to merge 1 commit into pingdotgg:main from andreivcodes:test/right-panel-toggle-opens-panel

Uh oh!

There was an error while loading. Please reload this page.

Closed

test(web): cover the right panel toggle opening and closing the panel #10642

Changes from all commits
Commits
Show all changes
1 commit
Select commit
a80da74
test(web): cover the right panel toggle opening and closing the panel
MilkRoadPRO Sep 8, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
test(web): cover the right panel toggle opening and closing the panel
The header toggle for the right panel has regressed several times (#8016,
#9517, #9591) with nothing guarding it. This mounts the real control against
the real right-panel store and checks that one press opens the panel, the next
closes it, surfaces survive a close, the toggle only touches its own thread,
and an unavailable toggle stays disabled.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@MilkRoadPRO @claude
MilkRoadPRO and claude committed Sep 8, 2026
commit a80da7460282d427b9b1a7d808e10b51c8f55c28

There are no files selected for viewing

141 changes: 141 additions & 0 deletions 141 apps/web/src/components/chat/PanelLayoutControls.test.tsx
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import { type EnvironmentId, ThreadId } from "@t3tools/contracts";
import { act, type ReactElement, type ReactNode } from "react";
import { create, type ReactTestInstance, type ReactTestRenderer } from "react-test-renderer";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";

import { selectThreadRightPanelState, useRightPanelStore } from "../../rightPanelStore";

// Tooltips position through floating-ui, which needs a window. The hover
// hint is not under test; the button beneath it is.
vi.mock("../ui/tooltip", () => ({
Tooltip: ({ children }: { children: ReactNode }) => children,
TooltipTrigger: ({ children }: { children: ReactNode }) => children,
TooltipPopup: () => null,
}));

import { PanelLayoutControls } from "./PanelLayoutControls";

const threadA = scopeThreadRef("env-1" as EnvironmentId, ThreadId.make("thread-A"));
const threadB = scopeThreadRef("env-1" as EnvironmentId, ThreadId.make("thread-B"));

/**
* Stands in for ChatView and the pull-requests route: both read the thread's
* panel state from the store and hand the toggle a store-backed handler.
*/
function RightPanelToggleProbe({
threadRef,
available = true,
}: {
threadRef: typeof threadA;
available?: boolean;
}) {
const panelState = useRightPanelStore((state) =>
selectThreadRightPanelState(state.byThreadKey, threadRef),
);
return (
<PanelLayoutControls
terminalAvailable={available}
terminalOpen={false}
terminalShortcutLabel={null}
rightPanelAvailable={available}
rightPanelOpen={panelState.isOpen}
rightPanelShortcutLabel={null}
liveAgentCount={0}
onToggleTerminal={() => undefined}
onToggleRightPanel={() => useRightPanelStore.getState().toggleVisibility(threadRef)}
/>
);
}

let renderer: ReactTestRenderer | undefined;

async function mount(element: ReactElement) {
await act(() => {
renderer = create(element);
});
}

/** The one button a user, a screen reader, or the command palette reaches as the panel toggle. */
function rightPanelToggle(): ReactTestInstance {
const buttons = renderer!.root.findAll(
(node) =>
node.type === "button" &&
typeof node.props["aria-label"] === "string" &&
node.props["aria-label"].startsWith("Toggle right panel"),
);
expect(buttons).toHaveLength(1);
return buttons[0]!;
}

async function press(button: ReactTestInstance) {
await act(() => {
button.props.onClick({ defaultPrevented: false, nativeEvent: {}, preventDefault() {} });
});
}

const isOpen = (threadRef: typeof threadA) =>
selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, threadRef).isOpen;

beforeEach(() => {
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
useRightPanelStore.setState({ byThreadKey: {}, userActionRevisionByThreadKey: {} });
});

afterEach(async () => {
await act(() => renderer?.unmount());
renderer = undefined;
vi.unstubAllGlobals();
});

describe("right panel toggle", () => {
it("opens the panel on press and closes it on the next press", async () => {
await mount(<RightPanelToggleProbe threadRef={threadA} />);
expect(rightPanelToggle().props["aria-pressed"]).toBe(false);

// A thread with no surfaces yet still opens, to the panel's empty state.
await press(rightPanelToggle());
expect(isOpen(threadA)).toBe(true);
expect(rightPanelToggle().props["aria-pressed"]).toBe(true);

// One press is one toggle: a double-fired handler would land back on closed.
await press(rightPanelToggle());
expect(isOpen(threadA)).toBe(false);
expect(rightPanelToggle().props["aria-pressed"]).toBe(false);
});

it("keeps surfaces through a close so reopening restores them", async () => {
useRightPanelStore.getState().open(threadA, "diff");
await mount(<RightPanelToggleProbe threadRef={threadA} />);
expect(rightPanelToggle().props["aria-pressed"]).toBe(true);

await press(rightPanelToggle());
expect(isOpen(threadA)).toBe(false);

await press(rightPanelToggle());
const reopened = selectThreadRightPanelState(
useRightPanelStore.getState().byThreadKey,
threadA,
);
expect(reopened.isOpen).toBe(true);
expect(reopened.activeSurfaceId).toBe("diff");
});

it("only affects the thread it belongs to", async () => {
await mount(<RightPanelToggleProbe threadRef={threadA} />);
await press(rightPanelToggle());
expect(isOpen(threadA)).toBe(true);
expect(isOpen(threadB)).toBe(false);

await act(() => renderer!.update(<RightPanelToggleProbe threadRef={threadB} />));
expect(rightPanelToggle().props["aria-pressed"]).toBe(false);
});

it("is disabled without a project and leaves the panel closed", async () => {
await mount(<RightPanelToggleProbe threadRef={threadA} available={false} />);
expect(rightPanelToggle().props.disabled).toBe(true);

await press(rightPanelToggle());
expect(isOpen(threadA)).toBe(false);
});
});
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.