mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 06:35:24 +00:00
feat: harden plugin api for separate repos, signed updates and generic external login
This commit is contained in:
1 parent
fb9c168b6b
commit
80944301dd
310 files changed
+6577
-4927
No files matched your search
@@ -48,9 +48,7 @@ describe("ssh-terminal activate", () => {
|
||||
const history = server.mock.services.get(
|
||||
"terminal.history",
|
||||
) as TerminalHistoryV1;
|
||||
const listed = await server.mock.ctx.asUser("user-1", () =>
|
||||
history.list(1, 10),
|
||||
);
|
||||
const listed = await server.mock.actAs("user-1", () => history.list(1, 10));
|
||||
expect(listed.map((entry) => entry.command)).toEqual(["df -h"]);
|
||||
});
|
||||
|
||||
@@ -59,7 +57,7 @@ describe("ssh-terminal activate", () => {
|
||||
const live = server.mock.services.get(
|
||||
"sessions.live#ssh",
|
||||
) as LiveSessionsV1;
|
||||
const other = await server.mock.ctx.asUser("user-2", async () =>
|
||||
const other = await server.mock.actAs("user-2", async () =>
|
||||
live.listForUser("user-1"),
|
||||
);
|
||||
expect(other).toEqual([]);
|
||||
|
||||
@@ -264,7 +264,7 @@ describe("storeImageViaSftp", () => {
|
||||
stream.destroyed = true;
|
||||
};
|
||||
streams.push(stream);
|
||||
stream.end = (data: Buffer) => {
|
||||
(stream as { end: unknown }).end = (data: Buffer) => {
|
||||
if (behavior.stallWrite) return;
|
||||
queueMicrotask(() => {
|
||||
if (behavior.writeError) {
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("MemoryAgent", () => {
|
||||
expect((parsed as ParsedKey).verify(data, signature)).toBe(true);
|
||||
|
||||
client.destroy();
|
||||
stream.destroy();
|
||||
(stream as unknown as { destroy: () => void }).destroy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -98,7 +98,7 @@ describe("MemoryAgent unsupported extension framing", () => {
|
||||
expect(replies[1][0]).toBe(12); // The following identities request succeeds.
|
||||
expect(replies[1].readUInt32BE(1)).toBe(1);
|
||||
} finally {
|
||||
stream.destroy();
|
||||
(stream as unknown as { destroy: () => void }).destroy();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -23,7 +23,6 @@ vi.mock(
|
||||
|
||||
vi.mock("@termix/plugin-sdk/ui", () => ({
|
||||
useIsMobile: () => false,
|
||||
useTabsSafe: () => ({ previewTerminalTheme: null }),
|
||||
}));
|
||||
|
||||
import { TerminalTabContent } from "../../../src/frontend/terminal/TerminalTabContent";
|
||||
|
||||
@@ -56,8 +56,22 @@ vi.mock("@termix/plugin-sdk/frontend", async (importOriginal) => ({
|
||||
slotId === "terminal.toolbar" ? slots.toolbar : [],
|
||||
useHostActions: () => slots.hostActions,
|
||||
useTabs: () => slots.tabs,
|
||||
usePluginUiPreferences: () => ({
|
||||
values: uiPrefs.values,
|
||||
set: uiPrefs.set,
|
||||
}),
|
||||
}));
|
||||
|
||||
const uiPrefs = vi.hoisted(() => {
|
||||
const values: Record<string, unknown> = {};
|
||||
return {
|
||||
values,
|
||||
set: vi.fn((key: string, value: unknown) => {
|
||||
values[key] = value;
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("@termix/plugin-sdk/ui", async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
useIsMobile: () => mobileApi.isMobile,
|
||||
@@ -111,6 +125,8 @@ function renderToolbar(
|
||||
|
||||
// jsdom lacks the pointer APIs Radix Select needs to open its popup.
|
||||
beforeEach(() => {
|
||||
for (const key of Object.keys(uiPrefs.values)) delete uiPrefs.values[key];
|
||||
uiPrefs.set.mockClear();
|
||||
Element.prototype.hasPointerCapture ??= () => false;
|
||||
Element.prototype.setPointerCapture ??= () => {};
|
||||
Element.prototype.releasePointerCapture ??= () => {};
|
||||
@@ -406,9 +422,7 @@ describe("TerminalToolbar Phase 1", () => {
|
||||
screen.getByRole("option", { name: "Expanded with metrics" }),
|
||||
);
|
||||
await waitFor(() =>
|
||||
expect(localStorage.getItem("termix-terminal-toolbar-density")).toBe(
|
||||
"expanded",
|
||||
),
|
||||
expect(uiPrefs.set).toHaveBeenCalledWith("toolbarDensity", "expanded"),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -561,7 +575,7 @@ describe("TerminalToolbar Phase 1", () => {
|
||||
});
|
||||
expect(collapsedMover).toBeVisible();
|
||||
expect(
|
||||
container.querySelector(".terminal-toolbar-collapsed-shell"),
|
||||
container.querySelector("[data-toolbar-collapsed]"),
|
||||
).toBeInTheDocument();
|
||||
collapsedMover.focus();
|
||||
expect(toolbar).toHaveClass("focus-within:opacity-100");
|
||||
@@ -1018,12 +1032,21 @@ describe("TerminalToolbar Phase 1", () => {
|
||||
});
|
||||
|
||||
it("uses the host display mode without overwriting the saved one", () => {
|
||||
localStorage.setItem("termix-terminal-toolbar-density", "labeled");
|
||||
uiPrefs.values.toolbarDensity = "labeled";
|
||||
uiPrefs.set.mockClear();
|
||||
renderToolbar({ host: withSettings({ terminalToolbarDisplay: "icon" }) });
|
||||
expect(screen.queryByText("Upload image")).toBeNull();
|
||||
expect(localStorage.getItem("termix-terminal-toolbar-density")).toBe(
|
||||
"labeled",
|
||||
);
|
||||
expect(uiPrefs.set).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("moves a density saved in this browser into the plugin preferences", () => {
|
||||
localStorage.setItem("termix-terminal-toolbar-density", "icon");
|
||||
uiPrefs.set.mockClear();
|
||||
renderToolbar();
|
||||
expect(uiPrefs.set).toHaveBeenCalledWith("toolbarDensity", "icon");
|
||||
expect(
|
||||
localStorage.getItem("termix-terminal-toolbar-density"),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("stays fully visible when fading is off", () => {
|
||||
|
||||
Reference in new issue
Block a user