import { test, expect } from "@playwright/test"; import { join } from "node:path"; // By relative path, as frame-scan.spec.ts imports the kit: plain .mjs. import { MIRROR_SLUG, CREATOR_SLUG, writeMirrorCorpus } from "../../common/testing/mirrors/mirrorCorpus.mjs"; import { resetData, testPaths } from "./helpers"; // The Mirror stage (release 31, lane D) on a synthetic mirror channel (the // kit's VOD archive of a creator on two platforms): no scan yet and the Scan // button, the mirror-scan job, then the totals both ways, the status filter, // the rows linking the creator's copies. A channel with no `mirror` has no // Mirror stage. test("Mirror stage: Scan enqueues mirror-scan; the totals, the filter, the rows", async ({ page }) => { test.setTimeout(120_000); await resetData("empty"); await writeMirrorCorpus(join(testPaths().transcriptsDir, "channels")); await page.goto(`/channels/${MIRROR_SLUG}?stage=mirror`); const stage = page.getByRole("region", { name: "Mirror stage" }); await expect(stage.getByLabel("mirror scan missing")).toBeVisible(); await expect(page.getByLabel("Mirror stage summary")).toHaveText("Not scanned."); await stage.getByRole("button", { name: "Scan", exact: true }).click(); await expect(page.getByLabel("Mirror scan output")).toContainText("@@mirror-scan", { timeout: 60_000 }); await page.reload(); await expect(page.getByLabel("Mirror stage summary")).toHaveText( "3 of 6 videos the only copy; the mirror holds 2 of 3 the creator removed.", ); const totals = stage.getByLabel("mirror totals"); await expect(totals).toContainText("3 of 6 videos are the only copy (2023-03-01 – 2023-03-20)."); await expect(stage.getByLabel("mirror creator removed")).toHaveText( "The creator removed 3 videos in this window; the mirror holds 2.", ); await expect(stage.getByLabel("mirror presence by platform")).toContainText("youtube: 1 public, 2 removed, 3 none"); const rows = stage.getByLabel("mirror videos").locator("tbody tr"); await expect(rows).toHaveCount(6); const filter = stage.getByLabel("mirror status filter"); await filter.getByRole("button", { name: "Only copy 3" }).click(); await expect(rows).toHaveCount(3); await expect(stage.locator('tbody tr[data-status="only-copy"]')).toHaveCount(3); await filter.getByRole("button", { name: "Never uploaded 1" }).click(); await expect(rows).toHaveCount(1); await expect(rows.first()).toHaveAttribute("aria-label", "mirror video vod-m5"); await filter.getByRole("button", { name: "Creator deleted 1" }).click(); const m2 = stage.getByLabel("mirror video vod-m2"); await expect(m2.getByRole("link", { name: "Oven Lawsuit Explained And Toaster Recall", exact: true }).first()).toHaveAttribute( "href", `/channels/${CREATOR_SLUG}/videos/yt-s2`, ); await expect(m2).toContainText("deleted"); await expect(m2.getByRole("link", { name: "Oven Lawsuit Explained And Toaster Recall", exact: true }).nth(1)).toHaveAttribute( "href", "/channels/synth-streamer-rumble/videos/v1abd-oven-lawsuit", ); await filter.getByRole("button", { name: "All 6" }).click(); await expect(rows).toHaveCount(6); await expect(stage.getByRole("button", { name: "Scan again", exact: true })).toBeVisible(); // A channel that is no mirror has no Mirror stage. await page.goto(`/channels/${CREATOR_SLUG}`); await expect(page.getByLabel("pipeline stages")).toBeVisible(); await expect(page.getByLabel("Mirror stage tab")).toHaveCount(0); });