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

main
tsx 37 lines 1.31 KB
Raw
1 import { expect, it } from "vite-plus/test";
2 import { userEvent } from "vite-plus/test/browser";
3
4 import { render } from "../../../test/render";
5 import { Combobox, ComboboxSearchInput } from "./combobox";
6 import { MenuSearchInput } from "./menu";
7
8 it.each(["combobox", "menu"] as const)(
9 "focuses the %s search when clicking anywhere in its row",
10 async (kind) => {
11 await using screen = await render(
12 <div className="w-96" data-testid="search-row">
13 {kind === "combobox" ? (
14 <Combobox>
15 <ComboboxSearchInput aria-label="Search options" />
16 </Combobox>
17 ) : (
18 <MenuSearchInput aria-label="Search options" />
19 )}
20 </div>,
21 { router: false /* input focus does not involve navigation */ },
22 );
23 const row = screen.getByTestId("search-row");
24 const field = screen.getByRole(kind === "combobox" ? "combobox" : "textbox", {
25 name: "Search options",
26 });
27 const { width, height } = row.element().getBoundingClientRect();
28
29 for (const x of [4, width / 2, width - 20, width - 4]) {
30 field.element().blur();
31 await userEvent.click(row, { position: { x, y: height / 2 } });
32 await expect.element(field).toHaveFocus();
33 }
34 await userEvent.keyboard("project");
35 await expect.element(field).toHaveValue("project");
36 },
37 );