import { expect, test } from "@playwright/test"; import { expectModalOpen } from "./helpers"; import { installMissingSourceRoutes, slugOf, watchUrl } from "./fixtures/missing-source"; // A SOURCE NO LONGER PUBLIC (lane missing-source, slice 1). A video whose state // is members-only, private or deleted at its platform gets no player — no // embed, no request to the platform — but one sentence with the state and the // day, the platform link kept but marked, and its transcript working as for any // video. Unlisted keeps its player. The state comes from the fresh summaries // first: a transcript record cached in IndexedDB is never refreshed. const panel = (page: import("@playwright/test").Page) => page.getByTestId("source-missing"); const panelRegion = (page: import("@playwright/test").Page) => page.getByRole("region", { name: "Source availability" }); test.describe("export — a source no longer public", () => { test("members-only: the sentence, the marked link, no embed and no platform request", async ({ page }) => { const { platformHits } = await installMissingSourceRoutes(page); await page.goto(`/?v=${slugOf("synthmem001")}`); await expectModalOpen(page); await expect(panel(page)).toContainText( "This stream is no longer public on YouTube (members-only; first seen 19 Nov 2026). The transcript is kept here.", ); await expect(panelRegion(page)).toBeVisible(); const link = panel(page).getByRole("link", { name: "Open on YouTube (members-only)" }); await expect(link).toHaveAttribute("href", watchUrl("synthmem001")); await expect(link).toHaveAttribute("rel", /noopener/); await expect(page.locator("iframe")).toHaveCount(0); // The transcript follows a click with no player at all. const third = page.locator("li", { hasText: "third synth line" }); await third.getByRole("button").click(); await expect(third).toHaveClass(/bg-blue-950/); await page.waitForTimeout(500); expect(platformHits).toEqual([]); }); test("private with no day, and deleted with one", async ({ page }) => { await installMissingSourceRoutes(page); await page.goto(`/?v=${slugOf("synthpri001")}`); await expectModalOpen(page); await expect(panel(page)).toContainText( "This video is no longer public on YouTube (private). The transcript is kept here.", ); await expect(panel(page).getByRole("link", { name: "Open on YouTube (private)" })).toBeVisible(); await page.goto(`/?v=${slugOf("synthdel001")}`); await expectModalOpen(page); await expect(panel(page)).toContainText( "This video is no longer public on YouTube (removed; first seen 31 Dec 2025). The transcript is kept here.", ); await expect(panel(page).getByRole("link", { name: "Open on YouTube (removed)" })).toBeVisible(); // No address: the label, never an empty link. await page.goto(`/?v=${slugOf("synthnou001")}`); await expectModalOpen(page); await expect(panel(page)).toContainText("Open on YouTube (removed)"); await expect(panel(page).getByRole("link")).toHaveCount(0); await expect(page.locator('a[href=""]')).toHaveCount(0); }); test("unlisted and public keep their player", async ({ page }) => { const { platformHits } = await installMissingSourceRoutes(page); for (const id of ["synthunl001", "synthpub001"]) { await page.goto(`/?v=${slugOf(id)}`); await expectModalOpen(page); await expect(panel(page)).toHaveCount(0); } // The embed was asked for (and aborted by the mock). await expect.poll(() => platformHits.length).toBeGreaterThan(0); }); test("the fresh summaries win over a stale record, both ways", async ({ page }) => { // The summaries arrive well after the stale record: no embed is mounted // meanwhile, so the platform is never asked. const { platformHits } = await installMissingSourceRoutes(page, { summariesDelayMs: 1500 }); await page.goto(`/?v=${slugOf("synthstl001")}`); await expectModalOpen(page); await expect(page.getByRole("heading", { name: "Synth stale record" })).toBeVisible(); await expect(panel(page)).toContainText("(members-only; first seen 1 Oct 2026)"); await page.waitForTimeout(500); expect(platformHits).toEqual([]); await expect(page.locator("iframe")).toHaveCount(0); await page.goto(`/?v=${slugOf("synthbak001")}`); await expectModalOpen(page); // The record (loaded: its title is up) says removed; the summaries say // public, and they win once they land. await expect(page.getByRole("heading", { name: "Synth back again" })).toBeVisible(); await expect(panel(page)).toHaveCount(0); }); test("a search card's badge tooltip carries the day", async ({ page }) => { await installMissingSourceRoutes(page); await page.goto("/"); await page.getByTestId("query-builder").waitFor(); const scope = page.locator('[data-testid^="leaf-scope-"]').first(); await scope.selectOption({ label: "Title / channel" }); const input = page.locator('[data-testid^="leaf-query-"]').first(); await input.click(); await input.fill("synth"); await input.press("Enter"); const badge = page.getByTestId("state-badge-members_only").first(); await expect(badge).toHaveAttribute("title", /; first seen 19 Nov 2026$/); await expect(page.getByTestId("state-badge-private")).toHaveAttribute("title", "Made private on the source platform"); }); });