import { expect, test } from "@playwright/test"; import { CHANNEL_SLUG, VIDEO_CHAT_SMALL, VIDEO_TRANSCRIPT_ONLY, } from "./fixtures/data"; import { expectModalOpen, installRoutes } from "./helpers"; test.use({ permissions: ["clipboard-read", "clipboard-write"], }); test.describe("video modal — share URL", () => { test.beforeEach(async ({ page }) => { await installRoutes(page); }); test("transcript mode share URL omits vm", async ({ page, context }) => { await context.grantPermissions(["clipboard-read", "clipboard-write"]); await page.goto( `/?v=${CHANNEL_SLUG}/${VIDEO_TRANSCRIPT_ONLY}&t=51`, ); await expectModalOpen(page); await page .getByRole("button", { name: "Copy share link at current time" }) .click(); const clip = await page.evaluate(() => navigator.clipboard.readText()); const url = new URL(clip); expect(url.searchParams.get("v")).toBe( `${CHANNEL_SLUG}/${VIDEO_TRANSCRIPT_ONLY}`, ); expect(url.searchParams.get("vm")).toBeNull(); // Rumble share URL uses urlTime, not currentTime, so t=51 round-trips. expect(url.searchParams.get("t")).toBe("51"); }); test("chat mode share URL includes vm=chat", async ({ page, context }) => { await context.grantPermissions(["clipboard-read", "clipboard-write"]); await page.goto( `/?v=${CHANNEL_SLUG}/${VIDEO_CHAT_SMALL}&vm=chat&t=11`, ); await expectModalOpen(page); await expect(page.getByText(/chat message number 0/).first()).toBeVisible(); await page .getByRole("button", { name: "Copy share link at current time" }) .click(); const clip = await page.evaluate(() => navigator.clipboard.readText()); const url = new URL(clip); expect(url.searchParams.get("vm")).toBe("chat"); expect(url.searchParams.get("t")).toBe("11"); }); });