mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: move tailscale device discovery and settings into a plugin
Adds plugins/tailscale/ with a devices sidebar tab, admin settings section, and re-auth dialog. Host Metrics tailscale manager card and SSH re-auth banner parsing stay in core.
This commit is contained in:
1 parent
5fbd5fb7e2
commit
8742c5d381
27 files changed
+850
-266
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { AdminTailscaleSection } from "../../../../../plugins/tailscale/frontend/AdminTailscaleSection";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
describe("AdminTailscaleSection", () => {
|
||||
it("renders the API key and base URL fields and saves on click", async () => {
|
||||
const user = userEvent.setup();
|
||||
const handleSave = vi.fn();
|
||||
render(
|
||||
<AdminTailscaleSection
|
||||
open
|
||||
onToggle={vi.fn()}
|
||||
tailscaleApiKey="tskey-api-abc"
|
||||
setTailscaleApiKey={vi.fn()}
|
||||
tailscaleApiBaseUrl="https://api.tailscale.com/api/v2"
|
||||
setTailscaleApiBaseUrl={vi.fn()}
|
||||
handleSaveTailscaleApiKey={handleSave}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
(
|
||||
screen.getByPlaceholderText(
|
||||
"tskey-api-... / hskey-api-...",
|
||||
) as HTMLInputElement
|
||||
).value,
|
||||
).toBe("tskey-api-abc");
|
||||
expect(
|
||||
(
|
||||
screen.getByPlaceholderText(
|
||||
"https://api.tailscale.com/api/v2",
|
||||
) as HTMLInputElement
|
||||
).value,
|
||||
).toBe("https://api.tailscale.com/api/v2");
|
||||
|
||||
await user.click(screen.getByText("common.save"));
|
||||
expect(handleSave).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("does not render its content when closed", () => {
|
||||
render(
|
||||
<AdminTailscaleSection
|
||||
open={false}
|
||||
onToggle={vi.fn()}
|
||||
tailscaleApiKey=""
|
||||
setTailscaleApiKey={vi.fn()}
|
||||
tailscaleApiBaseUrl=""
|
||||
setTailscaleApiBaseUrl={vi.fn()}
|
||||
handleSaveTailscaleApiKey={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.queryByPlaceholderText("tskey-api-... / hskey-api-..."),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user