import test from "node:test"; import assert from "node:assert/strict"; import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import type { Paths } from "yt-dlp-transcript-common/lib/paths"; import { siteChannelOptions } from "./channelOptions"; // Run with: pnpm -C editor exec tsx --test "app/sites/lib/channelOptions.test.ts" test("the site form's channel picker leaves remote-only channels out", async () => { const root = await mkdtemp(path.join(os.tmpdir(), "site-channel-options-")); try { const put = async (slug: string, config: Record) => { await mkdir(path.join(root, slug), { recursive: true }); await writeFile(path.join(root, slug, "config.json"), JSON.stringify({ handling: "youtube", ...config })); }; await put("own", { name: "Own", url: "https://www.youtube.com/@own" }); await put("remote", { name: "Remote", platform: "youtube", remoteOnly: true, remoteArchive: "https://stub.test", downloadMode: "manual" }); assert.deepEqual(await siteChannelOptions({ channelsDir: root } as unknown as Paths), [{ slug: "own", name: "Own" }]); } finally { await rm(root, { recursive: true, force: true }); } });