mirror of
https://github.com/YuzuZensai/Termix.git
synced 2026-11-12 12:26:36 +00:00
v26.10.5 (#1710)
* 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>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user