commit 586c1ebc57d7befa1fd66538401895fe590b6fa3
parent f064aeb07f6cd5e3b44d8a6cb7e1d99257db687f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 07:37:39 -0500
e2e: the Local media page, from the New channel form to a local record
A Local Archive channel made through the form (playback left off, no URL),
its library previewed, a recording with provider metadata selected, one with
no .info.json prepared by hand (manual details, a recording date), both
imported by the job, and the local record's page showing "Local recording"
with no download card. The library is synthetic, under test-results/, and
checked unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
1 file changed, 79 insertions(+), 0 deletions(-)
diff --git a/editor/e2e/local-media.spec.ts b/editor/e2e/local-media.spec.ts
@@ -0,0 +1,79 @@
+// LOCAL MEDIA LIBRARY, slice 1 (lane/local-media): a Local Archive channel made
+// from the New channel form, its library previewed, one recording with
+// provider metadata and one prepared by hand imported, and the local record's
+// page — all through the UI, against a synthetic library the spec writes under
+// test-results/ (outside the test corpus, which the controllers require).
+// Nothing is fetched; the library's files are never changed.
+
+import { test, expect } from "@playwright/test";
+import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+import { resetData, testPaths } from "./helpers";
+
+const VTT = "WEBVTT\n\n00:00:01.000 --> 00:00:03.000\nA synthetic library cue\n";
+
+test("a Local Archive channel imports a library recording and a prepared one, playback left off", async ({ page }) => {
+ await resetData("empty");
+ const library = join(testPaths().root, "test-results", `local-library-${process.env.TEST_PARALLEL_INDEX ?? "0"}`);
+ await rm(library, { recursive: true, force: true });
+ await mkdir(library, { recursive: true });
+ await writeFile(join(library, "aaaaaaaaaaa.mp4"), "synthetic mp4 a");
+ await writeFile(join(library, "aaaaaaaaaaa.info.json"), JSON.stringify({
+ id: "aaaaaaaaaaa", title: "Library episode", webpage_url: "https://www.youtube.com/watch?v=aaaaaaaaaaa",
+ upload_date: "20200102", duration: 12, extractor_key: "Youtube",
+ }));
+ await writeFile(join(library, "aaaaaaaaaaa.vtt"), VTT);
+ await writeFile(join(library, "talk.mp4"), "synthetic mp4 talk");
+ await writeFile(join(library, "talk.vtt"), VTT);
+ const before = (await readdir(library)).sort();
+
+ await page.goto("/channels/new");
+ await page.getByLabel("Local Archive").check();
+ await page.locator('input[name="name"]').fill("Local Spec Library");
+ await page.locator('input[name="localDirectory"]').fill(library);
+ await page.getByRole("button", { name: "Create channel" }).click();
+ await expect(page).toHaveURL(/\/channels\/local-spec-library\/local-media$/);
+
+ const config = JSON.parse(await readFile(join(testPaths().transcriptsDir, "channels", "local-spec-library", "config.json"), "utf8"));
+ expect(config.localMedia).toEqual({ sourceId: "library-1", directory: library });
+ expect(config.url).toBeUndefined();
+
+ await page.getByRole("button", { name: "Preview library" }).click();
+ await expect(page.getByRole("status").filter({ hasText: "discovered" })).toHaveText(
+ "2 discovered · 1 new · 0 occupied · 1 need review",
+ );
+ await page.getByLabel("Import aaaaaaaaaaa.mp4").check();
+
+ await page.getByRole("button", { name: "Prepare details for talk.mp4" }).click();
+ const form = page.getByRole("form", { name: "Prepare details for talk.mp4" });
+ await form.getByLabel("Method").selectOption("manual");
+ await form.getByLabel("Title").fill("A prepared talk");
+ await form.getByLabel("Recording date (optional)").fill("2021-03-04");
+ await form.getByRole("button", { name: "Review details" }).click();
+ await expect(form.getByLabel("Prepared recording details")).toContainText("Recording date: 2021-03-04");
+ await form.getByRole("button", { name: "Use details for import" }).click();
+ await expect(page.getByLabel("Import talk.mp4")).toBeChecked();
+
+ await page.getByRole("button", { name: "Import selected (2)" }).click();
+ await expect(page.getByText(/Imported 2; already occupied 0; rejected 0/)).toBeVisible({ timeout: 30_000 });
+
+ const data = join(testPaths().transcriptsDir, "channels", "local-spec-library", "data");
+ const ids = (await readdir(data)).sort();
+ expect(ids).toHaveLength(2);
+ expect(ids).toContain("aaaaaaaaaaa");
+ const local = ids.find((id) => id.startsWith("local-"))!;
+ expect((await readdir(join(data, local))).sort()).toEqual(["external-media.json", "metadata.info.json", "transcript.en.vtt"]);
+ expect(JSON.parse(await readFile(join(data, local, "metadata.info.json"), "utf8")).title).toBe("A prepared talk");
+
+ // A local record's page names it a local recording, with no download card.
+ await page.goto(`/channels/local-spec-library/videos/${local}`);
+ await expect(page.getByLabel("Local recording")).toBeVisible();
+ await expect(page.getByRole("link", { name: "Open local media library" })).toBeVisible();
+ await expect(page.getByText("Download audio")).toHaveCount(0);
+
+ // Playback stayed off, and the library was never touched.
+ const after = JSON.parse(await readFile(join(testPaths().transcriptsDir, "channels", "local-spec-library", "config.json"), "utf8"));
+ expect(after.localMedia.playback).toBeUndefined();
+ expect((await readdir(library)).sort()).toEqual(before);
+ await rm(library, { recursive: true, force: true });
+});