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

test("File mentions preserve __init__.py and remain searchable", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("Python mention demo", { "pkg/__init__.py": "# Package entry point\n" });
  const thread = await t3.thread({ project, title: "Package maintenance", messages: ["Ready to edit the package."] });
  await t3.open(thread);
  const composer = screen.getByRole("textbox");
  await composer.fill("Fix @__init__");
  await screen.getByRole("option").filter({ hasText: "__init__.py" }).tap();
  await composer.press("Enter");
  await screen.getByText("second fixture turn complete", { exact: false }).waitFor({ state: "visible" });
  await screen.getByRole("combobox", "Search threads").fill("__init__.py");
  await screen.getByText("You: Fix", { exact: false }).or(screen.getByText("No threads found")).waitFor({ state: "visible" });
  await app.screenshot("sent-mention-and-search");
  const sent = browser.locator('[data-user-message-body="true"]').last();
  await expect(browser.locator('[data-message-role="user"] strong')).toHaveCount(0);
  await expect(sent).toHaveText("Fix __init__.py");
  await expect(screen.getByText("You: Fix __init__.py", { exact: false })).toBeVisible();
});
