mirror of
https://github.com/YuzuZensai/Termix.git
synced 2026-11-12 09:37:05 +00:00
* feat: add an auto or fixed columns picker to card grids * feat: add safe mode that only runs layout and theme plugins * docs: add simple layout to plugin table * fix: ask for local network access in the macOS app * feat: allow plugin registries on listed private hosts (#1705) * chore: add private registry hosts to the changelog * feat: use the proxy for plugin registry downloads * fix: allow changing connection origin on shared hosts * chore: update translations and plugin pins * chore: lint, format, and bump version to 26.10.5 --------- Co-authored-by: Lukas <80832688+0skater0@users.noreply.github.com>
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import { afterEach, describe, expect, it } from "vitest";
|
|
import {
|
|
mayRunInSafeMode,
|
|
safeModeOn,
|
|
safeModePluginIds,
|
|
} from "../../plugins/safe-mode.js";
|
|
import type { PluginManifest } from "../../plugins/manifest.js";
|
|
|
|
function plugin(id: string, manifest: Partial<PluginManifest> = {}) {
|
|
return { id, manifest: { id, ...manifest } as PluginManifest };
|
|
}
|
|
|
|
const plugins = [
|
|
plugin("layout", {
|
|
contributes: { layouts: [{ id: "classic" }] },
|
|
dependencies: { helper: "^1.0.0" },
|
|
} as Partial<PluginManifest>),
|
|
plugin("themes", {
|
|
contributes: { themes: [{ id: "dark" }] },
|
|
} as Partial<PluginManifest>),
|
|
plugin("helper"),
|
|
plugin("docker"),
|
|
];
|
|
|
|
afterEach(() => {
|
|
delete process.env.TERMIX_SAFE_MODE;
|
|
});
|
|
|
|
describe("safeModeOn", () => {
|
|
it("reads 1 and true, anything else is off", () => {
|
|
expect(safeModeOn()).toBe(false);
|
|
process.env.TERMIX_SAFE_MODE = "1";
|
|
expect(safeModeOn()).toBe(true);
|
|
process.env.TERMIX_SAFE_MODE = " TRUE ";
|
|
expect(safeModeOn()).toBe(true);
|
|
process.env.TERMIX_SAFE_MODE = "0";
|
|
expect(safeModeOn()).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("safeModePluginIds", () => {
|
|
it("keeps layout and theme plugins and what they depend on", () => {
|
|
expect([...safeModePluginIds(plugins)].sort()).toEqual([
|
|
"helper",
|
|
"layout",
|
|
"themes",
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("mayRunInSafeMode", () => {
|
|
it("lets every plugin run when safe mode is off", () => {
|
|
expect(mayRunInSafeMode("docker", plugins)).toBe(true);
|
|
});
|
|
|
|
it("only lets look plugins run when safe mode is on", () => {
|
|
process.env.TERMIX_SAFE_MODE = "1";
|
|
expect(mayRunInSafeMode("docker", plugins)).toBe(false);
|
|
expect(mayRunInSafeMode("layout", plugins)).toBe(true);
|
|
expect(mayRunInSafeMode("helper", plugins)).toBe(true);
|
|
});
|
|
});
|