import { expect, test } from "@playwright/test"; import { CHANNEL_SLUG, VIDEO_TRANSCRIPT_ONLY } from "./fixtures/data"; import { expectModalOpen, installRoutes, urlParams } from "./helpers"; test.describe("video modal — snap-back when chat missing", () => { test.beforeEach(async ({ page }) => { await installRoutes(page); }); test("vm=chat on a transcript-only video reverts to transcript with notice", async ({ page, }) => { await page.goto( `/?v=${CHANNEL_SLUG}/${VIDEO_TRANSCRIPT_ONLY}&vm=chat`, ); await expectModalOpen(page); // Either snap-back branch surfaces a notice — "not available" when the // subs page has the slug but no live_chat, "Couldn't load" when the slug // is missing from the manifest entirely. Both indicate the user-facing // snap-back happened. await expect( page.locator('[role="status"]', { hasText: /(Live chat not available|Couldn't load live chat)/, }), ).toBeVisible(); // vm clears from the URL once snap-back fires. await expect .poll(async () => (await urlParams(page)).get("vm")) .toBeNull(); // Transcript content is now visible. await expect(page.getByText(/alpha line/)).toBeVisible(); // Toggle reads "Show live chat" (target state = chat). await expect( page.getByRole("button", { name: "Show live chat" }), ).toBeVisible(); }); });