import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("Ctrl+F from a Files tree row focuses file search", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("sample", {
    "README.md": "# Sample project\n",
    "src/index.ts": "export const greeting = 'hello';\n",
    "src/lib/util.ts": "export const double = (n: number) => n * 2;\n",
  });
  await t3.thread({ project, title: "Files panel shortcut", messages: ["Start"] });
  await t3.open();
  await screen.getByRole("button", "Files panel shortcut, Done, sample", { exact: true }).tap();
  await screen.getByRole("button", "Toggle right panel", { exact: true }).tap();
  await screen.getByText("Files", { exact: true }).tap();
  await screen.getByRole("treeitem", "src", { exact: true }).tap();
  await app.screenshot("tree-row-focused");
  await browser.keyboard.press("Control+f");
  await app.screenshot("after-ctrl-f");
  await expect(screen.getByRole("searchbox", "Search sample files")).toBeFocused();
});
