"use strict"; // Navigation icons: one mapping by stable IDs for all sidebar modes and the plugin taskbar. const test = require("node:test"); const assert = require("node:assert/strict"); const fs = require("node:fs"); const path = require("node:path"); const icons = require("../src/renderer/vendor/lucide/icons"); const { ICON_BY_KEY, FALLBACK, iconName } = require("../src/renderer/navIcons"); const { PluginRegistry } = require("../src/main/plugins/pluginRegistry"); test("every core view and bundled plugin has its own existing icon; unknown plugins fall back to puzzle", () => { const html = fs.readFileSync(path.join(__dirname, "../src/renderer/index.html"), "utf8"); const views = [...html.matchAll(/class="nav-button[^"]*" data-view="([a-z]+)"/g)].map((match) => match[1]); assert.ok(views.length >= 7); const registry = new PluginRegistry(fs.mkdtempSync(path.join(require("node:os").tmpdir(), "chj-icons-")), null, { bundledRoot: path.join(__dirname, "../src/main/firstPartyPlugins") }); const keys = [...views, ...registry.listInstalled().map((plugin) => `plugin:${plugin.id}`)]; const names = keys.map((key) => iconName(key)); for (const [index, key] of keys.entries()) { assert.notEqual(names[index], FALLBACK, `${key} has a specific icon`); assert.ok(icons[names[index]]?.length, `${names[index]} exists in the vendored set`); } assert.equal(new Set(names).size, names.length, "no two known modules share an icon"); assert.equal(iconName("plugin:example.unknown"), "puzzle"); assert.ok(icons.puzzle.length); for (const name of Object.values(ICON_BY_KEY)) assert.ok(icons[name], `mapped icon ${name} is vendored`); assert.ok(fs.readFileSync(path.join(__dirname, "../src/renderer/vendor/lucide/LICENSE.txt"), "utf8").startsWith("ISC License")); });