feat: type the plugin host record, move plugin strings out of core and add lint checks

This commit is contained in:
LukeGus committed 2026-09-29 13:08:39 -05:00
1 parent bba06f7ff6
commit b8bbcd2196
626 files changed
+23884 -4590

No files matched your search

@@ -1,26 +1,14 @@
import { describe, expect, it } from "vitest";
import {
parseProxmoxJumpHosts,
serializeProxmoxJumpHosts,
} from "../../src/backend/proxmox-jump-hosts.js";
import { parseProxmoxJumpHosts } from "../../src/backend/proxmox-jump-hosts.js";
describe("Proxmox jump-host persistence", () => {
const jumpHosts = [{ hostId: 7 }, { hostId: 9 }];
it("serializes resolved arrays before inserting a synced guest", () => {
expect(serializeProxmoxJumpHosts(jumpHosts)).toBe(
'[{"hostId":7},{"hostId":9}]',
);
});
it("keeps stored JSON strings stable", () => {
const stored = '[{"hostId":7}]';
expect(serializeProxmoxJumpHosts(stored)).toBe(stored);
expect(parseProxmoxJumpHosts(stored)).toEqual([{ hostId: 7 }]);
it("reads a resolved array or a stored JSON string", () => {
expect(parseProxmoxJumpHosts([{ hostId: 7 }])).toEqual([{ hostId: 7 }]);
expect(parseProxmoxJumpHosts('[{"hostId":7}]')).toEqual([{ hostId: 7 }]);
});
it("turns missing or malformed values into null", () => {
expect(serializeProxmoxJumpHosts(null)).toBeNull();
expect(serializeProxmoxJumpHosts("invalid")).toBeNull();
expect(parseProxmoxJumpHosts(null)).toBeNull();
expect(parseProxmoxJumpHosts("invalid")).toBeNull();
});
});
@@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest";
import { guestPluginSettings } from "../../src/backend/routes.js";
describe("guestPluginSettings", () => {
it("names the plugin that keeps each switch an imported guest needs", () => {
expect(guestPluginSettings("rdp", true)).toEqual({
"remote-desktop": { enableRdp: true, rdpPort: 3389 },
docker: { enableDocker: true },
});
expect(guestPluginSettings("ssh", false)).toEqual({});
});
});
@@ -38,6 +38,25 @@ describe(`${manifest.id} activate`, () => {
}
});
it("reads its switches from its own host settings", async () => {
rendered = await renderWithApp(plugin, { manifest, locales });
const host = (settings: Record<string, unknown>) => ({
id: "1",
name: "pve",
ip: "10.0.0.1",
port: 22,
pluginSettings: { proxmox: settings },
});
const ids = (settings: Record<string, unknown>) =>
rendered!.registered.hostActionsFor(host(settings)).map((a) => a.id);
expect(ids({ enableProxmox: true })).toContain("proxmox-discover");
expect(ids({})).not.toContain("proxmox-discover");
expect(ids({ enableProxmoxStats: true })).toContain("proxmox-stats");
expect(plugin.proxmoxSettings(host({ enableProxmoxStats: true }))).toEqual({
enableProxmoxStats: true,
});
});
it("removes everything it registered on deactivate", async () => {
const app = await renderWithApp(plugin, { manifest, locales });
await app.deactivate();