feat: plugins only see their own host settings in the browser

This commit is contained in:
LukeGus committed 2026-09-29 13:38:11 -05:00
1 parent 50d43e29fb
commit fb9c168b6b
17 files changed
+488 -52

No files matched your search

@@ -1,7 +1,11 @@
import { describe, it, expect, vi, afterEach } from "vitest";
import { toast } from "sonner";
import type { PluginApiClient } from "@termix/plugin-sdk/frontend";
import { hasMacAddress, wakeHost } from "../../src/frontend/host-action.js";
import {
hasMacAddress,
macAddressOf,
wakeHost,
} from "../../src/frontend/host-action.js";
vi.mock("sonner", () => ({
toast: { success: vi.fn(), error: vi.fn() },
@@ -24,6 +28,26 @@ function stubApi(overrides: Partial<PluginApiClient> = {}): PluginApiClient {
const t = (key: string) => key;
describe("macAddressOf", () => {
it("returns the trimmed MAC address a host keeps", () => {
expect(
macAddressOf({
pluginSettings: {
"wake-on-lan": { macAddress: " aa:bb:cc:dd:ee:ff " },
},
}),
).toBe("aa:bb:cc:dd:ee:ff");
});
it("is null without a host or an address", () => {
expect(macAddressOf(undefined)).toBeNull();
expect(macAddressOf({ pluginSettings: {} })).toBeNull();
expect(
macAddressOf({ pluginSettings: { "wake-on-lan": { macAddress: " " } } }),
).toBeNull();
});
});
describe("hasMacAddress", () => {
it("is true when the host's wake-on-lan settings carry a MAC address", () => {
expect(