Files
RustProxy/tests/panel_icons_contract.js
T
2026-11-07 13:56:11 +01:00

46 lines
2.7 KiB
JavaScript

const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const root = path.join(__dirname, "..");
const read = relative => fs.readFileSync(path.join(root, relative), "utf8");
const preferences = read("src/admin/web/app/preferences.js");
const icons = read("src/admin/web/app/icons.js");
const core = read("src/admin/web/app/core.js");
const html = read("src/admin/web/index.html");
const css = read("src/admin/web/css/10-base.css");
const overviewCss = read("src/admin/web/css/30-overview.css");
const integrations = read("src/admin/web/integrations.js");
const metricsPartial = read("src/admin/web/partials/overview-metrics.html");
const pl = JSON.parse(read("langs/pl_pl.json"));
const openapi = JSON.parse(read("src/admin/openapi.json"));
assert.match(html, /id="ui-interface-icons"[^>]*type="checkbox"/);
assert.match(preferences, /interface_icons:\s*false/);
assert.match(preferences, /applyAdminInterfaceIcons\(value\.interface_icons\)/);
assert.match(preferences, /saveAppearancePreference\(\{ interface_icons: next \}/);
assert.match(preferences, /interface:\s*\{[^}]*interface_icons:\s*false/);
assert.match(core, /rustProxyIcons\?\.refresh\?\.\(\)/);
assert.match(icons, /dataset\.interfaceIcons !== "true"/);
assert.match(icons, /aria-hidden", "true"/);
assert.match(icons, /data\.panel|dataset\.panel/);
assert.match(icons, /MutationObserver/);
assert.match(icons, /if \(target\.dataset\.httpSettingsTab\) return "network"/);
assert.match(icons, /#web-service-preset-apply.*return "wand"/);
assert.match(icons, /#tunnels-open.*return null/);
assert.match(icons, /#logs-menu > summary/);
assert.match(integrations, /listener-h2-settings-link.*uiIconName = "settings"/);
assert.match(integrations, /listener-h3-settings-link.*uiIconName = "settings"/);
assert.match(metricsPartial, /stat-corner-badge[^>]+data-ui-icon-name="none"[^>]+id="tunnels-open"/);
assert.match(overviewCss, /\.stat-corner-badge/);
assert.equal(pl.translations.interfaceIconsHelp, "Dodaje semantyczne ikony SVG do nawigacji, akcji, zakładek i okien dialogowych.");
assert.match(css, /html\[data-interface-icons="true"\]/);
assert.equal(openapi.components.schemas.AdminPreferences.properties.interface_icons.default, false);
assert.equal(openapi.components.schemas.AdminPreferences.properties.interface_icons.type, "boolean");
for (const icon of ["plus", "save", "check", "trash", "edit", "refresh", "settings", "search", "key", "certificate", "shield", "network", "database", "wand", "grid", "activity", "book"]) {
assert.ok(new RegExp(`\\b${icon}:`).test(icons), `missing semantic SVG icon definition: ${icon}`);
}
console.log("Panel SVG icon preference contract: OK");