feat: load plugin frontends at runtime and remove plugin ids from the shell

This commit is contained in:
LukeGus committed 2026-09-22 20:15:52 -05:00
1 parent 49f0286a14
commit e88d5a52e3
721 files changed
+54265 -44416

No files matched your search

+43 -10
View File
@@ -1,5 +1,5 @@
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key }),
@@ -7,6 +7,10 @@ vi.mock("react-i18next", () => ({
import { HostStatusCard } from "@/dashboard/DashboardTab";
import type { Host } from "@/types/ui-types";
import {
registerHostAction,
resetHostContributions,
} from "@/sidebar/host-contributions";
afterEach(cleanup);
@@ -42,20 +46,49 @@ describe("HostStatusCard", () => {
});
});
describe("dashboard protocol routing", () => {
describe("dashboard host routing", () => {
const Icon = (() => null) as never;
beforeEach(() => {
registerHostAction({
id: "desk-connect",
titleKey: "x",
icon: Icon,
kind: "connect",
priority: 50,
tabType: "desk",
when: (host) => (host as Record<string, unknown>).enableDesk === true,
});
registerHostAction({
id: "shell-connect",
titleKey: "x",
icon: Icon,
kind: "connect",
priority: 100,
tabType: "shell",
when: (host) => (host as Record<string, unknown>).enableShell === true,
});
registerHostAction({
id: "stats",
titleKey: "x",
icon: Icon,
kind: "open",
overview: true,
tabType: "stats",
when: (host) => (host as Record<string, unknown>).enableShell === true,
});
});
afterEach(resetHostContributions);
it.each([
[{ enableRdp: true }, "rdp"],
[{ enableVnc: true }, "vnc"],
[{ enableTelnet: true }, "telnet"],
[{ enableSsh: true, enableRdp: true }, "host-metrics"],
] as const)("opens the enabled protocol for %j", (protocols, expected) => {
[{ enableDesk: true }, "desk"],
[{ enableShell: true, enableDesk: true }, "stats"],
] as const)("opens the right view for %j", (flags, expected) => {
const host = {
id: "1",
name: "Remote host",
ip: "192.0.2.1",
enableSsh: false,
...protocols,
} as Host;
...flags,
} as unknown as Host;
const onOpenTab = vi.fn();
render(
<HostStatusCard
@@ -20,7 +20,7 @@ describe("registerDashboardCard seam", () => {
registerDashboardCard({
id: FAKE_CARD_ID,
titleKey: "nav.fakePluginItem",
render: () => null,
component: () => null,
});
expect(registeredDashboardCardList().map((c) => c.id)).toContain(