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

test("Quoted message search finds accents inside words", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("demo");
  const first = await t3.thread({ project, title: "First notes", messages: ["Start"] });
  const second = await t3.thread({ project, title: "Second notes", messages: ["Start"] });
  for (const [thread, message] of [[first, "résumé draft"], [second, "re\u0301sume\u0301 draft"]] as const) {
    await t3.open(thread);
    await screen.getByText("first fixture turn complete").waitFor();
    const composer = screen.getByRole("textbox");
    await composer.fill(message);
    await composer.press("Enter");
    await screen.getByText("second fixture turn complete").waitFor();
  }
  await browser.keyboard.press("Control+k");
  const palette = screen.getByRole("dialog", "Command palette");
  await palette.getByRole("combobox").fill('"draft"');
  await palette.getByText("First notes", { exact: true }).waitFor();
  await palette.getByText("Second notes", { exact: true }).waitFor();
  await app.screenshot("control-both-messages-indexed");
  await palette.getByRole("combobox").fill('"resume draft"');
  await palette.getByText("First notes", { exact: true }).waitFor();
  await app.screenshot("quoted-message-results");
  await expect(palette.getByText("Second notes", { exact: true })).toBeVisible();
});
