import { test } from "node:test"; import assert from "node:assert/strict"; import { mkdtemp, rm, writeFile } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { connectedArchivesHere } from "./sources"; // list_sources offers the archives the editor connected (demo epic D1): read // from settings.json through the one resolver, TRANSCRIPT_SITE_URL's added. test("the MCP lists the connected archives from settings.json, the environment's after them", async () => { const dir = await mkdtemp(path.join(os.tmpdir(), "mcp-archives-")); try { const file = path.join(dir, "settings.json"); await writeFile(file, JSON.stringify({ remoteArchives: [{ id: "stub", origin: "https://stub.test/", title: "Stub", addedAt: "2026-11-11T00:00:00Z" }] })); const list = connectedArchivesHere(file, { TRANSCRIPT_SITE_URL: "https://other.test" }); assert.deepEqual( list.map((a) => [a.id, a.origin, a.fromEnv ?? false]), [ ["stub", "https://stub.test", false], ["other-test", "https://other.test", true], ], ); assert.deepEqual(connectedArchivesHere(path.join(dir, "missing.json"), {}), []); } finally { await rm(dir, { recursive: true, force: true }); } });