// The intro module: the brand it draws is configurable (render.intro.brand, // .suffix, .projectUrl); unset, the page is the Archilyzer intro's. import { test } from "node:test"; import assert from "node:assert/strict"; import { INTRO_PROJECT_URL, INTRO_SUFFIX, introErrors, introOf, introSitePrefix } from "yt-dlp-transcript-common/lib/report/intro.mjs"; import { introHtml, swapPlan, lockupParts, PROJECT_URL_TEXT } from "../chrome-intro.mjs"; import { brandKit } from "../brand.mjs"; import { introEntry } from "../intro.mjs"; import intro, { validateIntroSettings } from "./intro.mjs"; const kit = brandKit("archilyzer-media"); const base = { style: "boot-dark", mark: "chime", seconds: 4.75, width: 1920, height: 1080, fps: 30, kit }; const SITE = { name: "Jeralyzer", lead: "Jer", url: "jeralyzer.pages.dev" }; test("the brand's knobs are refused by name and read only when set", () => { assert.deepEqual(introErrors({ style: "boot", brand: "archilyzer-media", suffix: "lyzer", projectUrl: "x.pages.dev" }), []); assert.deepEqual(introErrors({ style: "boot", projectUrl: false }), []); assert.match(introErrors({ style: "boot", brand: "Not An Id" })[0], /render\.intro\.brand must be a brand kit's id/); assert.match(introErrors({ style: "boot", suffix: "ly zer" })[0], /render\.intro\.suffix/); assert.match(introErrors({ style: "boot", projectUrl: "" })[0], /render\.intro\.projectUrl/); assert.match(validateIntroSettings({ style: "boot", brand: "someone-else" })[0], /is not a brand kit — one of archilyzer-media/); assert.equal("brand" in introOf({ intro: "boot" }), false, "an intro without them reads as it did"); assert.deepEqual(introOf({ intro: { style: "boot", suffix: "lytics", projectUrl: false } }).projectUrl, false); const entry = introEntry({ intro: { style: "boot", brand: "archilyzer-media", suffix: "lytics" } }); assert.equal(entry.brand, "archilyzer-media"); assert.equal(entry.suffix, "lytics"); assert.equal("projectUrl" in entry, false); }); test("the defaults keep today's page; the suffix and the project URL change the swap", () => { assert.equal(PROJECT_URL_TEXT, INTRO_PROJECT_URL); assert.equal(introHtml({ ...base, site: SITE }), introHtml({ ...base, site: SITE, suffix: INTRO_SUFFIX, projectUrl: INTRO_PROJECT_URL })); assert.equal(introSitePrefix("Jeralyzer"), "Jera"); assert.equal(introSitePrefix("Jeralytics", "lytics"), "Jera"); const parts = lockupParts(kit); const plain = swapPlan({ parts, site: SITE }); const none = swapPlan({ parts, site: SITE, projectUrl: false }); const other = swapPlan({ parts, site: SITE, projectUrl: "https://example.org/" }); assert.deepEqual(plain.urls.map((u) => u.text), ["jeralyzer.pages.dev", "archilyzer.pages.dev"]); assert.deepEqual(none.urls.map((u) => u.text), ["jeralyzer.pages.dev"]); assert.deepEqual(other.urls.map((u) => u.text), ["jeralyzer.pages.dev", "example.org"]); // A suffix the name does not end in swaps the whole word. const whole = swapPlan({ parts, site: SITE, suffix: "lytics" }); assert.ok(whole.glyphs.length > plain.glyphs.length); }); test("the intro module: a segment with its home, its validator and its docs", () => { assert.equal(intro.kind, "segment"); assert.equal(intro.configKey, "render.intro"); assert.deepEqual(intro.validate({ style: "boot" }, {}), []); assert.ok(intro.docs.rows.some((r) => r[0].includes("render.intro.brand"))); });