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

test("Directory-only ignore keeps only the regular backslash-named file during search warm-up", WEB, async ({ t3, app, browser, screen }) => {
  const files: Record<string, string> = {
    ".ignore": "dir\\\\/\n",
    "dir\\/f": "scoutneedle\n",
    "src/dir\\": "scoutneedle\n",
  };
  const filler = "filler content with no matching search term\n".repeat(190);
  for (let i = 0; i < 60000; i++) files[`filler/${String(i).padStart(5, "0")}.txt`] = filler;
  const project = await t3.project("ignore-rule-demo", files);
  const thread = await t3.thread({ project, title: "Directory ignore search", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByText("first fixture turn complete", { exact: true }).waitFor();
  await browser.keyboard.press("Control+Shift+f");
  await screen.getByPlaceholder("Search in ignore-rule-demo").fill("scoutneedle");
  await screen.getByText(/results in .* files/).waitFor();
  await app.screenshot("first-search-during-index-warmup");
  await expect(screen.getByText("1 results in 1 files", { exact: true })).toBeVisible();
});
