Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

thread-link-paste-after-list-code.e2e.ts

40 lines1.5 KB

1/// <reference lib="dom" />
2import { expect } from "e2e";
3​
4import { environmentId, runPromise, test, WEB } from "./t3.ts";
5​
6test(
7 "A thread link pasted after a list code example becomes a chip",
8 WEB,
9 async ({ t3, app, browser, screen }) => {
10 const project = await t3.project("demo");
11 const source = await t3.thread({
12 project,
13 title: "Release checklist",
14 messages: ["Checklist"],
15 });
16 const target = await t3.thread({ project, title: "Release notes", messages: ["Notes"] });
17 const environment = await runPromise(environmentId(app.baseUrl ?? ""));
18 const href = `https://app.t3.codes/threads/${environment}/${encodeURIComponent(source.threadId)}`;
19 await t3.open(target);
20 await screen.getByRole("textbox").tap();
21​
22 await browser.evaluate((text) => {
23 const editor = document.activeElement;
24 if (!(editor instanceof HTMLElement) || !editor.isContentEditable) {
25 throw new Error("The composer is not focused");
26 }
27 const clipboardData = new DataTransfer();
28 clipboardData.setData("text/plain", text);
29 editor.dispatchEvent(
30 new ClipboardEvent("paste", { clipboardData, bubbles: true, cancelable: true }),
31 );
32 return null;
33 }, `- \`\`\`text\n example\n\nSee [Release checklist](${href})`);
34​
35 await app.screenshot("pasted-thread-link");
36 await expect(browser.locator('[role="textbox"] [data-slot="context-chip-label"]')).toHaveText(
37 "Release checklist",
38 );
39 },
40);