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

test("RTF previews retain named spaces and nonbreaking hyphens", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("RTF preview", {
    "contacts.rtf": String.raw`{\rtf1\ansi{\fonttbl\f0\fnil Monospaced;}Account\emspace Name\enspace Jean\_ Luc\par}`,
  });
  const thread = await t3.thread({ project, title: "Review contacts", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByText("fixture turn complete", { exact: false }).waitFor({ state: "visible", timeout: 120_000 });
  await browser.keyboard.press("Control+p");
  await screen.getByPlaceholder("Search files…").fill("contacts.rtf");
  await screen.getByRole("option", "contacts.rtf", { exact: false }).tap();
  const document = browser.frameLocator('iframe[title^="contacts.rtf"]');
  await document.getByText("Account", { exact: false }).waitFor({ state: "visible", timeout: 120_000 });
  await app.screenshot("rtf-preview");
  await expect(document.getByText("Account\u2003Name\u2002Jean\u2011 Luc", { exact: true })).toBeVisible();
});
