Initial upload to Gitea

This commit is contained in:
antonn committed 2026-11-30 16:32:37 +00:00
1 parent 78193254ad
commit 8478998cae
1485 files changed
+461025 -42348

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const root = path.join(__dirname, "..");
const views = fs.readdirSync(path.join(root, "views"), { recursive: true })
.filter(file => file.endsWith(".ejs"))
.map(file => path.join("views", file));
const browserAssets = [
...views,
"dev-templates/index-real.html",
"public/css/bot.css",
"public/css/dashboard.css",
"public/js/bot.js",
"public/js/settings.js",
];
function assertLocalImage(url) {
assert.match(url, /^\/images\/[\w.-]+$/);
assert.ok(fs.statSync(path.join(root, "public", url), { throwIfNoEntry: false })?.isFile(), url);
}
test("panel pages and browser assets do not switch to jsDelivr", () => {
for (const file of browserAssets) {
const source = fs.readFileSync(path.join(root, file), "utf8");
assert.doesNotMatch(source, /cdn-fallback|adp:cdn-down|adp_cdn|cdn\.jsdelivr\.net\/gh\/antonndev\/adcdn/i, file);
if (file.endsWith(".ejs") || file.endsWith(".html")) {
assert.doesNotMatch(source, /cdn\.jsdelivr\.net/i, file);
assert.doesNotMatch(source, /<(?:img|source)\b[^>]*\bsrc=["']https?:\/\//i, file);
}
for (const [url] of source.matchAll(/\/images\/[\w.-]+\.(?:avif|gif|ico|jpe?g|png|svg|webm|webp)\b/g)) {
assertLocalImage(url);
}
}
for (const script of ["cdn-fallback.js", "cdn-fallback.min.js"]) {
assert.ok(!fs.existsSync(path.join(root, "public", "js", script)), script);
}
});
test("bundled template images and version logos point to served local files", () => {
for (const { templateImage } of require("../templates.json")) {
if (templateImage) assertLocalImage(templateImage);
}
for (const { logo } of require("../versions.json").providers) {
if (logo) assertLocalImage(logo);
}
});
test("settings preloads the original sidebar toggle SVG before styles and scripts", () => {
const settings = fs.readFileSync(path.join(root, "views", "settings.ejs"), "utf8");
const firstScript = settings.indexOf("<script");
assert.ok(firstScript >= 0);
assert.match(settings.slice(0, firstScript), /<link rel="preload" as="image" href="\/images\/minimize-icon\.svg" fetchpriority="high">/);
assert.match(settings, /aria-label="Toggle Sidebar">\s*<img src="\/images\/minimize-icon\.svg"/);
});
test("dashboard Topbar uses the same Terminal, Settings, and sign-out glyphs as Status", () => {
const dashboard = fs.readFileSync(path.join(root, "views", "index.ejs"), "utf8");
const status = fs.readFileSync(path.join(root, "views", "status.ejs"), "utf8");
function buttonIcon(source, marker) {
const buttons = Array.from(source.matchAll(/<button\b[^>]*>[\s\S]*?<\/button>/g), ([button]) => button);
const button = buttons.find(markup => markup.slice(0, markup.indexOf(">")).includes(marker));
assert.ok(button, marker);
const icon = button.match(/<span class="nav-option__icon">([\s\S]*?)<\/span>/)?.[1].trim();
assert.match(icon, /^<i class="fa-solid fa-[\w-]+"><\/i>$/, marker);
return icon;
}
for (const [dashboardButton, statusButton] of [
['id="openSshTerminalBtn"', 'id="openSshTerminalBtn"'],
['title="Settings"', 'title="Settings"'],
['id="logoutBtn"', 'class="nav-option nav-option--back"'],
]) {
assert.equal(buttonIcon(dashboard, dashboardButton), buttonIcon(status, statusButton), dashboardButton);
}
assert.match(dashboard, /<link rel="preload" as="font"[^>]*href="\/vendor\/fontawesome\/webfonts\/fa-solid-900\.woff2">/);
});