import { test, expect } from "@playwright/test"; import { channelStage, generateReport, pathExists, resetData, } from "./helpers"; test("shows empty state when there is no playlist", async ({ page }) => { await resetData("one-youtube-channel"); await generateReport(page, "test-youtube"); await page.goto(channelStage("test-youtube", "download")); await expect(page.getByText(/Undownloaded videos \(0\)/)).toBeVisible(); await expect(page.getByLabel("undownloaded videos empty")).toContainText( "All playlist videos are downloaded.", ); }); test("lists every playlist entry that is missing on disk", async ({ page }) => { await resetData("youtube-with-playlist"); await generateReport(page, "test-youtube"); await page.goto(channelStage("test-youtube", "download")); await expect(page.getByText(/Undownloaded videos \(4\)/)).toBeVisible(); const list = page.getByLabel("undownloaded videos list"); for (const id of [ "fake00000002", "fake00000003", "fake00000004", "fake00000005", ]) { await expect(list.getByLabel(`undownloaded video ${id}`)).toHaveAttribute( "href", `/channels/test-youtube/videos/${id}`, ); } // The already-downloaded entry must not appear. await expect( list.getByLabel("undownloaded video fake00000001"), ).toHaveCount(0); }); test("clicking an undownloaded entry lands on a usable video page", async ({ page, }) => { await resetData("youtube-with-playlist"); await generateReport(page, "test-youtube"); await page.goto(channelStage("test-youtube", "download")); await page.getByLabel("undownloaded video fake00000002").click(); await expect(page).toHaveURL(/\/videos\/fake00000002$/); // By name: the video title is an h2 (the channel layout owns the h1), and so // is every section heading beside it. await expect( page.getByRole("heading", { name: "fake00000002" }), ).toBeVisible(); await expect( page.getByRole("button", { name: /^Run download pipeline$/ }), ).toBeVisible(); await expect(page.getByLabel("download mode")).toBeVisible(); }); test("undownloaded list shrinks after a one-click whisper completes", async ({ page, }) => { await resetData("youtube-with-playlist"); await page.goto("/channels/test-youtube/videos/fake00000002"); await page.getByLabel("download mode").selectOption("whisper"); await page.getByRole("button", { name: /^Audio \+ Whisper$/ }).click(); await expect( page.getByLabel("Audio + Whisper for fake00000002 output"), ).toContainText("Transcribe fake00000002 done", { timeout: 30_000 }); expect( await pathExists( "test-transcripts/channels/test-youtube/data/fake00000002/transcript.json", ), ).toBe(true); await generateReport(page, "test-youtube"); await page.goto(channelStage("test-youtube", "download")); await expect(page.getByText(/Undownloaded videos \(3\)/)).toBeVisible(); await expect( page.getByLabel("undownloaded video fake00000002"), ).toHaveCount(0); });