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

test("Initial Hindi and Thai titles omit the incomplete syllable", WEB, async ({ t3, app, browser, screen }) => {
  const project = await t3.project("demo");
  const thread = await t3.thread({ project, title: "Earlier work", messages: ["first"] });
  await t3.open(thread);
  const titles: string[] = [];
  for (const [label, prompt] of [
    ["hindi", "इस फ़ाइल में लॉगिन के बाद सभी सेटिंग्स को सहेजने की समस्या को ठीक करें"],
    ["thai", "ช่วยตรวจสอบปัญหาการบันทึกการตั้งค่าใหม่ในหน้านี้ที่บ้านได้ไหมครับผม"],
  ]) {
    await screen.getByRole("button", "New thread in demo", { exact: true }).tap();
    await screen.getByRole("textbox").fill(prompt!);
    await screen.getByRole("textbox").press("Enter");
    await browser.locator('[data-sidebar-row]').filter({ hasText: prompt!.slice(0, 20) }).waitFor();
    titles.push(await browser.evaluate(() => document.title));
    await app.screenshot(label!);
  }
  expect(titles[0]).toContain("इस फ़ाइल में लॉगिन के बाद सभी सेटिंग्स को सहेजने...");
  expect(titles[1]).toContain("ช่วยตรวจสอบปัญหาการบันทึกการตั้งค่าใหม่ในหน้านี้...");
});
