feat: make each plugin an npm workspace built by a termix-plugin CLI

This commit is contained in:
LukeGus committed 2026-09-22 15:09:50 -05:00
1 parent 4758016f41
commit 5796186a1c
448 files changed
+3087 -2003

No files matched your search

@@ -0,0 +1,49 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const authApiMock = vi.hoisted(() => ({ get: vi.fn(), patch: vi.fn() }));
const handleApiErrorMock = vi.hoisted(() => vi.fn());
vi.mock("@/main-axios", () => ({
authApi: authApiMock,
statsApi: { get: vi.fn(), patch: vi.fn() },
handleApiError: handleApiErrorMock,
}));
import { getTailscaleDevices } from "../../src/frontend/tailscale-api";
beforeEach(() => {
vi.clearAllMocks();
});
describe("getTailscaleDevices", () => {
it("preserves configured-key state when discovery fails", async () => {
authApiMock.get.mockRejectedValue({
isAxiosError: true,
response: {
data: {
devices: [],
hasApiKey: true,
error: "Failed to fetch Tailscale devices",
},
},
});
await expect(getTailscaleDevices()).resolves.toEqual({
devices: [],
hasApiKey: true,
error: "Failed to fetch Tailscale devices",
});
expect(handleApiErrorMock).not.toHaveBeenCalled();
});
it("uses normal API error handling when no structured state is available", async () => {
const error = { isAxiosError: true, response: { data: {} } };
authApiMock.get.mockRejectedValue(error);
await expect(getTailscaleDevices()).rejects.toBe(error);
expect(handleApiErrorMock).toHaveBeenCalledWith(
error,
"fetch Tailscale devices",
);
});
});