Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2import { page } from "vite-plus/test/browser";
3
4import { render } from "../../test/render";
5import { openCommandPalette } from "../commandPaletteBus";
6import { useCommandPaletteStore } from "../commandPaletteStore";
7import { CommandPalette } from "./CommandPalette";
8
9function setup() {
10 useCommandPaletteStore.setState(useCommandPaletteStore.getInitialState(), true);
11}
12
13describe("CommandPalette open intents", () => {
14 it("opens New thread in... with focus in the search input, not the Back button", async () => {
15 setup();
16 await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
17
18 openCommandPalette({ open: "new-thread-in" });
19
20 await expect.element(page.getByPlaceholder("Search...")).toHaveFocus();
21 });
22
23 it("opens a search intent with its query in the focused input", async () => {
24 setup();
25 await using _screen = await render(<CommandPalette>{null}</CommandPalette>);
26
27 openCommandPalette({ query: "acme" });
28
29 const input = page.getByPlaceholder("Search commands, projects, and threads...");
30 await expect.element(input).toHaveFocus();
31 await expect.element(input).toHaveValue("acme");
32 });
33});