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

test("Pasting a quoted Windows mention preserves its directory separators", WEB, async ({ t3, screen, browser, app }) => {
  const project = await t3.project("server");
  const thread = await t3.thread({ project, title: "Quoted Windows file mention", messages: ["Start"] });
  await t3.open(thread);
  await screen.getByText("first fixture turn complete", { exact: false }).waitFor();
  await screen.getByText("Syncing messages", { exact: false }).waitFor({ state: "hidden" });
  await screen.getByRole("textbox").click();
  await browser.evaluate(() => {
    const clipboardData = new DataTransfer();
    clipboardData.setData("text/plain", '@"C:\\My Files\\notes.md" ');
    document.querySelector('[role="textbox"]')!.dispatchEvent(new ClipboardEvent("paste", { clipboardData, bubbles: true, cancelable: true }));
  });
  await app.screenshot("quoted-windows-file-mention");
  await expect(screen.getByRole("button", "Preview C:\\My Files\\notes.md", { exact: true })).toBeVisible();
});
