Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const ROOT = path.join(__dirname, "..");
|
||||
const VIEWS_DIR = path.join(ROOT, "views");
|
||||
|
||||
const statusSource = fs.readFileSync(path.join(VIEWS_DIR, "status.ejs"), "utf8");
|
||||
|
||||
// The admin "create server wizard" modals (create / fork / port / startup / import /
|
||||
// resources) could never open on /status: dashboard.js only redirects to
|
||||
// /settings?panel=servers&create=server. They were removed from views/status.ejs
|
||||
// along with their dead style rules and the dead createConfirm click binding.
|
||||
const REMOVED_ELEMENT_IDS = [
|
||||
"createModal",
|
||||
"createConfirm",
|
||||
"createCancel",
|
||||
"createClose",
|
||||
"createSpinner",
|
||||
"createTitle",
|
||||
"forkModal",
|
||||
"forkConfirm",
|
||||
"portModal",
|
||||
"portConfirm",
|
||||
"startupModal",
|
||||
"startupConfirm",
|
||||
"importModal",
|
||||
"importConfirm",
|
||||
"resourcesModal",
|
||||
"resourcesConfirm",
|
||||
];
|
||||
|
||||
test("status.ejs no longer ships the dead create-server wizard modals", () => {
|
||||
for (const id of REMOVED_ELEMENT_IDS) {
|
||||
assert.ok(
|
||||
!statusSource.includes(`id="${id}"`),
|
||||
`views/status.ejs should not contain id="${id}"`
|
||||
);
|
||||
}
|
||||
// Stale port-range hint removed with the wizard (real validation is 1..65535).
|
||||
assert.ok(!statusSource.includes("35650"), "stale '35650' port hint should be gone");
|
||||
});
|
||||
|
||||
test("status.ejs no longer references the removed wizard elements at all", () => {
|
||||
// Covers CSS selectors (#createConfirm, ...), getElementById lookups, etc.
|
||||
for (const id of REMOVED_ELEMENT_IDS) {
|
||||
assert.ok(
|
||||
!statusSource.includes(id),
|
||||
`views/status.ejs should not reference "${id}" anywhere`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("status.ejs keeps the create redirect UX for createBtn and createBtnFooter", () => {
|
||||
const REDIRECT = "/settings?panel=servers&create=server";
|
||||
for (const btnId of ["createBtn", "createBtnFooter"]) {
|
||||
const marker = `var ${btnId} = document.getElementById('${btnId}');`;
|
||||
const at = statusSource.indexOf(marker);
|
||||
assert.ok(at !== -1, `status.ejs should still bind ${btnId}`);
|
||||
const block = statusSource.slice(at, at + 400);
|
||||
assert.ok(
|
||||
block.includes(REDIRECT),
|
||||
`${btnId} binding should still redirect to ${REDIRECT}`
|
||||
);
|
||||
}
|
||||
assert.ok(
|
||||
!statusSource.includes("getElementById('createConfirm')"),
|
||||
"dead createConfirm binding should be removed"
|
||||
);
|
||||
});
|
||||
|
||||
test("the create-server wizard ids were not moved into any other view", () => {
|
||||
const modalIds = [
|
||||
"createModal",
|
||||
"createConfirm",
|
||||
"forkModal",
|
||||
"portModal",
|
||||
"startupModal",
|
||||
"importModal",
|
||||
"resourcesModal",
|
||||
];
|
||||
|
||||
const ejsFiles = [];
|
||||
(function walk(dir) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) walk(full);
|
||||
else if (entry.name.endsWith(".ejs")) ejsFiles.push(full);
|
||||
}
|
||||
})(VIEWS_DIR);
|
||||
|
||||
assert.ok(ejsFiles.length > 0, "should find view templates under views/");
|
||||
for (const file of ejsFiles) {
|
||||
const src = fs.readFileSync(file, "utf8");
|
||||
for (const id of modalIds) {
|
||||
assert.ok(
|
||||
!src.includes(`id="${id}"`),
|
||||
`${path.relative(ROOT, file)} must not contain id="${id}"`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user