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

test("First project content search honors a three-star globstar", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("ws", {
    // Keep the initial native content scan warming so the first search uses git grep.
    ...Object.fromEntries(Array.from({ length: 5000 }, (_, i) => [`padding/source-${i}.txt`, "unrelated workspace content\n".repeat(2500)])),
    ".ignore": "archive/***/file\n",
    "archive/x/y/file": "needle-47962 hello\n",
    "archive/file": "needle-47962 hello\n",
    "keep.txt": "needle-47962 hello\n",
  });
  const thread = await t3.thread({ project, title: "Workspace ignore proof", messages: ["Start"], model: "multi-turn" });
  await t3.open(thread);
  await screen.getByRole("textbox").waitFor();
  await browser.keyboard.press("Control+Shift+f");
  const search = screen.getByRole("combobox", "Search in ws", { exact: true });
  await search.fill("needle-47962");
  await screen.getByText("keep.txt", { exact: true }).waitFor();
  await app.screenshot("first-content-search");
  await expect(screen.getByText("1 results in 1 files", { exact: true })).toBeVisible();
});
