import { test, expect } from "@playwright/test"; import { readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import * as urls from "./urls"; // --------------------------------------------------------------------------- // "Cut from the stored media URL" (release 32 R6) in umtool: offered beside a // window fetch only when the record stores a media file address the editor can // cut from (an Odysee record's CDN file: e2e/fixtures/make-fixture.mjs, // stored-url-fixture on testchan-odysee/odv1), off by default, and ticked it // rides to the editor as `storedUrl: "fallback"` (the editor stub records it). // A project whose records store none offers nothing (stored-url-plain-fixture // on vid10: its own project and source, which nothing fetches). // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); const FIXTURE = path.join(HERE, "..", ".e2e-song"); const STORED = "reports/stored-url-fixture"; const PLAIN = "reports/stored-url-plain-fixture"; const STUB_LOG = path.join(FIXTURE, "editor-stub.requests.json"); const asked = (): Record[] => { try { return JSON.parse(readFileSync(STUB_LOG, "utf8")) as Record[]; } catch { return []; } }; test("the stored-URL answer: a record that stores its CDN file, one that does not", async ({ request, baseURL }) => { const yes = await request.get(`${baseURL}/api/cited/stored?channel=testchan-odysee&video=odv1`); expect(await yes.json()).toEqual({ stored: true, host: "player.odycdn.com", platform: "odysee" }); const clip = await request.get(`${baseURL}/api/cited/stored?project=${encodeURIComponent(STORED)}&clip=s01`); expect((await clip.json()).stored).toBe(true); const no = await request.get(`${baseURL}/api/cited/stored?channel=testchan&video=vid10`); expect(await no.json()).toEqual({ stored: false }); }); test("Fetch unfetched clips offers it only where a record stores one; ticked, the editor is asked with it", async ({ page }) => { test.setTimeout(120_000); // No stored URL among the clips: no option. await page.goto(urls.section(PLAIN, "timeline")); await expect(page.getByRole("button", { name: /unfetched clip/i })).toBeVisible(); await expect(page.locator("[data-stored-url-option]")).toHaveCount(0); await page.goto(urls.section(STORED, "timeline")); const option = page.locator("[data-stored-url-option]"); await expect(option).toBeVisible(); await expect(option).toContainText("Cut from the stored media URL"); await expect(option).toContainText("Odysee only"); const box = option.getByRole("checkbox"); await expect(box).not.toBeChecked(); await box.check(); const before = asked().length; await page.getByRole("button", { name: /fetch 1 unfetched clip/i }).click(); await expect(page.locator("[data-fetch-unfetched-msg]")).toContainText(/fetched 1 clip/, { timeout: 90_000 }); const ask = asked().slice(before).find((a) => a.manifest === "stored-url-fixture"); expect(ask).toMatchObject({ channelSlug: "testchan-odysee", videoId: "odv1", storedUrl: "fallback", requestedBy: "umtool" }); });