fix: proxmox guest sync, startup snippet sync, drop dead cloudflare ssh transport

This commit is contained in:
LukeGus committed 2026-09-28 21:59:37 -05:00
1 parent 44062e30d1
commit ffa872ebd3
19 files changed
+270 -292

No files matched your search

@@ -0,0 +1,109 @@
import { describe, it, expect } from "vitest";
import { registerHostProtocol } from "@/sidebar/host-protocols";
import type { Host } from "@/types/ui-types";
import {
buildStatusTooltip,
statusCheckEnabled,
} from "@/sidebar/tree/HostItem/HostItem";
// Minimal host factory – only the fields buildStatusTooltip reads.
function makeHost(overrides: Partial<Host> = {}): Host {
return {
id: 1,
name: "test-host",
ip: "127.0.0.1",
username: "user",
enableSsh: true,
enableRdp: false,
enableVnc: false,
enableTelnet: false,
statusCheckEnabled: true,
...overrides,
} as unknown as Host;
}
// Translator that returns human-readable labels, not key paths.
// This is what the review asked for: assert the rendered labels,
// not the key paths the translator falls back to when a resource is missing.
const t = (key: string): string =>
({
"hosts.status.available": "Available",
"hosts.status.reachable": "Reachable, not authenticated",
"hosts.status.offline": "Offline",
"hosts.status.monitoringDisabled": "Monitoring disabled",
})[key] ?? key;
describe("buildStatusTooltip", () => {
it("returns the translated 'Available' label for online status", () => {
const host = makeHost();
const tooltip = buildStatusTooltip(host, "online", t);
expect(tooltip).toContain("Available");
expect(tooltip).not.toContain("hosts.status.");
});
it("returns the translated 'Reachable, not authenticated' label for reachable status", () => {
const host = makeHost();
const tooltip = buildStatusTooltip(host, "reachable", t);
expect(tooltip).toContain("Reachable, not authenticated");
expect(tooltip).not.toContain("hosts.status.");
});
it("returns the translated 'Offline' label for offline status", () => {
const host = makeHost();
const tooltip = buildStatusTooltip(host, "offline", t);
expect(tooltip).toContain("Offline");
expect(tooltip).not.toContain("hosts.status.");
});
it("returns 'Monitoring disabled' when status check is disabled", () => {
const host = makeHost({ statusCheckEnabled: false });
const tooltip = buildStatusTooltip(host, "online", t);
expect(tooltip).toBe("Monitoring disabled");
});
it("includes protocol names in the tooltip when protocols are enabled", () => {
const dispose = registerHostProtocol({
id: "demo-desktop",
pluginId: "demo",
settingKey: "enableDemo",
defaultPort: 3389,
titleKey: "Demo Desktop",
icon: () => null,
});
const host = makeHost({
enableSsh: true,
pluginSettings: { demo: { enableDemo: true } },
});
const tooltip = buildStatusTooltip(host, "online", t);
dispose();
expect(tooltip).toContain("SSH");
expect(tooltip).toContain("Demo Desktop");
expect(tooltip).toContain("Available");
});
it("returns just the status label when no protocols are enabled", () => {
const host = makeHost({ enableSsh: false });
const tooltip = buildStatusTooltip(host, "online", t);
expect(tooltip).toBe("Available");
});
it("does not render key paths when a translator is supplied", () => {
const host = makeHost();
const tooltip = buildStatusTooltip(host, "online", t);
// The tooltip must never show the raw key path – that means the
// translation resource is missing, which is the bug #1265 fixed.
expect(tooltip).not.toMatch(/hosts\.status\./);
});
});
describe("statusCheckEnabled", () => {
it("returns true when statusCheckEnabled is not set (default)", () => {
const host = makeHost({ statusCheckEnabled: undefined });
expect(statusCheckEnabled(host)).toBe(true);
});
it("returns false when statusCheckEnabled is explicitly false", () => {
const host = makeHost({ statusCheckEnabled: false });
expect(statusCheckEnabled(host)).toBe(false);
});
});