/// <reference lib="dom" />
import { expect } from "e2e";
import { test, WEB } from "./t3.ts";

test("Prose thread links after leading indented code become chips", WEB, async({t3,app,browser,screen})=>{
 const project=await t3.project("examples");
 const thread=await t3.thread({project,title:"Context examples",messages:["Start"]});
 await t3.open(thread);
 const composer=screen.getByRole("textbox");
 await composer.tap();
 await browser.evaluate((threadId:string)=>{
  const env=decodeURIComponent(window.location.pathname.split("/")[1]!);
  const clip=new DataTransfer();
  clip.setData("text/plain",`    ~~~\n\nReal context: <t3-thread://v2/${env}/${threadId}>`);
  document.activeElement!.dispatchEvent(new ClipboardEvent("paste",{clipboardData:clip,bubbles:true,cancelable:true}));
 },thread.threadId);
 await composer.getByText("Real context:",{exact:false}).waitFor();
 await app.screenshot("prose-after-indented-code");
 await expect(composer.getByText("Context examples",{exact:true})).toBeVisible();
});
