Files
radicle-desktop/tests/e2e/clipboard.spec.ts
T
Rūdolfs Ošiņš 7728c9272e Start e2e specs at a route that exists
/repos is no longer a route, so specs fell back to the inbox and logged a
routing error. The inbox opens the first-launch guide, so tests now start
with it dismissed. The router now logs the URL it couldn't resolve
instead of just "URL".
2026-10-01 18:16:29 +02:00

33 lines
1.2 KiB
TypeScript

import { expect, markdownRid, test } from "@tests/support/fixtures.js";
import { chromium } from "playwright";
// We explicitly run all clipboard tests within the context of a single test
// so that we don't run into race conditions, because there is no way to isolate
// the clipboard in Playwright yet.
test("copy to clipboard", async () => {
const browser = await chromium.launch();
const context = await browser.newContext();
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
const page = await context.newPage();
await page.goto("/inbox");
// Reset system clipboard to a known state.
await page.evaluate<string>("navigator.clipboard.writeText('')");
// Repo ID.
{
const repoLink = page.getByRole("link", { name: "markdown" });
await repoLink.click({ button: "right" });
await page.getByRole("menuitem", { name: "Copy RID" }).click();
const clipboardContent = await page.evaluate<string>(
"navigator.clipboard.readText()",
);
expect(clipboardContent).toBe(markdownRid);
}
// Clear the system clipboard contents so developers don't wonder why there's
// random stuff in their clipboard after running tests.
await page.evaluate<string>("navigator.clipboard.writeText('')");
});