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

const rtf = String.raw`{\rtf1\ansi\b \uc0\u55357 \u56960  Launch\b0  \i\uc1\u-10187?\u-8904?\i0}`;

test("RTF styled supplementary characters remain intact", WEB, async ({ t3, app, screen, browser }) => {
  const project = await t3.project("RTF preview", { "styled.rtf": rtf });
  const thread = await t3.thread({ project, title: "Review styled RTF", messages: ["Start"] });
  await browser.setViewport({ width: 1440, height: 1080 });
  await t3.open(thread);
  await screen.getByText("fixture turn complete", { exact: false }).waitFor();
  await browser.keyboard.press("Control+p");
  await screen.getByPlaceholder("Search files…").fill("styled.rtf");
  await screen.getByRole("option", "styled.rtf", { exact: false }).tap();
  await screen.getByText("1 page", { exact: false }).waitFor({ timeout: 120_000 });
  await screen.getByRole("button", "Maximize panel", { exact: true }).tap();
  const document = browser.frameLocator('iframe[title^="styled.rtf"]');
  await document.locator("body").waitFor();
  await app.screenshot("styled-characters");
  await expect(document.locator("strong").first()).toContainText("🚀");
  await expect(document.locator("em").first()).toHaveText("𝔸");
});
