mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-30 16:50:47 +08:00
Instead of trying to copy the RID of the first repo card, try to copy the one you later expect.
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { chromium } from "playwright";
|
|
|
|
import { expect, markdownRid, test } from "@tests/support/fixtures.js";
|
|
import { formatRepositoryId } from "@app/lib/utils";
|
|
|
|
// We explicitly run all clipboard tests withing 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("/repos");
|
|
|
|
// Reset system clipboard to a known state.
|
|
await page.evaluate<string>("navigator.clipboard.writeText('')");
|
|
|
|
// Repo ID.
|
|
{
|
|
await page.getByText(formatRepositoryId(markdownRid)).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('')");
|
|
});
|