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

test("Greek prefix ending in sigma keeps the thread available", WEB, async ({ t3, app, screen }) => {
  const project = await t3.project("Search demo");
  await runPromise(run("git", ["remote", "add", "origin", "https://github.com/pingdotgg/t3code.git"], { cwd: project }));
  const thread = await t3.thread({ project, title: "ΒΑΣΗ", messages: ["Start"] });
  await t3.open(thread);
  await t3.open("/pull-requests?repository=pingdotgg%2Ft3code&number=36927&selectedUrl=https%3A%2F%2Fgithub.com%2Fpingdotgg%2Ft3code%2Fpull%2F36927");
  await screen.getByRole("button", "More pull request actions", { exact: true }).tap();
  await screen.getByRole("menuitem", "Link to thread", { exact: true }).tap();
  const dialog = screen.getByRole("dialog");
  const row = dialog.getByText("ΒΑΣΗ", { exact: true });
  await row.waitFor();
  await dialog.getByPlaceholder("Search threads or projects...").fill("ΒΑ");
  await row.waitFor();
  await dialog.getByPlaceholder("Search threads or projects...").fill("ΒΑΣ");
  await app.screenshot("greek-sigma-search");
  expect(await row.isVisible(), "ΒΑΣ finds ΒΑΣΗ in the thread picker").toBe(true);
});
