The best way to control Claude Code, Codex and more from any computer or phone

main
tsx 42 lines 1.86 KB
Raw
1 import { page, userEvent } from "vite-plus/test/browser";
2 import { describe, expect, it, vi } from "vite-plus/test";
3
4 import { render } from "../../test/render";
5
6 vi.mock(import("../state/server"), async (original) => {
7 const actual = await original();
8 const { Atom } = await import("effect/reactivity");
9 const { compileResolvedKeybindingsConfig } = await import("@t3tools/shared/keybindings");
10 const keybindings = compileResolvedKeybindingsConfig([
11 { key: "mod+b", command: "sidebar.toggle", when: "!terminalFocus" },
12 ]);
13 return { ...actual, primaryServerKeybindingsAtom: Atom.make(keybindings) };
14 });
15 // The thread list needs live environments; the shortcut lives in the shell around it.
16 vi.mock(import("./Sidebar"), () => ({ default: (() => null) as never }));
17
18 import { AppSidebarLayout } from "./AppSidebarLayout";
19
20 describe("sidebar toggle shortcut", () => {
21 it("leaves the key to a focused terminal when its rule excludes terminalFocus", async () => {
22 await page.viewport(1280, 800);
23 using _platform = vi.spyOn(navigator, "platform", "get").mockReturnValue("Linux x86_64");
24 await using screen = await render(
25 <AppSidebarLayout>
26 <div data-terminal-owner="drawer">
27 <textarea aria-label="Terminal input" />
28 </div>
29 <button type="button">Outside</button>
30 </AppSidebarLayout>,
31 );
32 const wrapper = screen.container.querySelector('[data-slot="sidebar-wrapper"]')!;
33
34 await userEvent.click(screen.getByRole("textbox", { name: "Terminal input" }));
35 await userEvent.keyboard("{Control>}b{/Control}");
36 expect(wrapper.getAttribute("data-sidebar-state")).toBe("expanded");
37
38 await userEvent.click(screen.getByRole("button", { name: "Outside" }));
39 await userEvent.keyboard("{Control>}b{/Control}");
40 await vi.waitFor(() => expect(wrapper.getAttribute("data-sidebar-state")).toBe("collapsed"));
41 });
42 });