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

test("Automatic project monograms show lone Indic conjuncts once", WEB, async ({ t3, app, browser, screen }) => {
  const names = ["श्री", "क्ष", "శ్రీ"];
  let thread;
  for (const name of names) {
    const project = await t3.project(name);
    thread = await t3.thread({ project, title: `Monogram ${name}`, messages: ["Start"] });
  }
  await t3.open(thread);
  for (const name of names) await screen.getByText(name, { exact: true }).first().waitFor();
  await browser.locator("[data-slot=project-monogram] text").first().waitFor();
  await screen.getByText("first fixture turn complete", { exact: true }).waitFor();
  await screen.getByText("Syncing messages...", { exact: true }).waitFor({ state: "hidden" });
  await app.screenshot("lone-indic-project-monograms");
  const monograms = await browser.evaluate(() => [...document.querySelectorAll("[data-slot=project-monogram] text")].map((node) => node.textContent));
  expect([...new Set(monograms)].sort()).toEqual([...names].sort());
});
