mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 06:35:24 +00:00
feat: type the plugin host record, move plugin strings out of core and add lint checks
This commit is contained in:
1 parent
bba06f7ff6
commit
b8bbcd2196
626 files changed
+23884
-4590
No files matched your search
@@ -78,6 +78,7 @@ const {
|
||||
writeHostPluginSettings,
|
||||
applyPluginHostImportSettings,
|
||||
setHostPluginEnabled,
|
||||
checkHostPluginSettingsInput,
|
||||
} = await import("../../../database/routes/host-plugin-settings.js");
|
||||
|
||||
function manifest(id: string, host: unknown): PluginManifest {
|
||||
@@ -453,3 +454,38 @@ describe("share levels, legacy fields and generic writes", () => {
|
||||
expect(await setHostPluginEnabled("missing", [3], true)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("checkHostPluginSettingsInput", () => {
|
||||
it("passes declared keys through to the plugin that owns them", () => {
|
||||
loaded.push({ id: "docker", manifest: DOCKER, state: "active" });
|
||||
const result = checkHostPluginSettingsInput({
|
||||
docker: { enableDocker: true, socketPath: "/run/docker.sock" },
|
||||
});
|
||||
expect(result.errors).toEqual([]);
|
||||
expect(result.skipped).toEqual([]);
|
||||
expect(result.writes).toEqual([
|
||||
{
|
||||
manifest: DOCKER,
|
||||
values: { enableDocker: true, socketPath: "/run/docker.sock" },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("refuses a key the plugin does not declare and a value it rejects", () => {
|
||||
loaded.push({ id: "docker", manifest: DOCKER, state: "active" });
|
||||
const { errors } = checkHostPluginSettingsInput({
|
||||
docker: { dockerConfig: {}, enableDocker: "sure" },
|
||||
});
|
||||
expect(errors).toHaveLength(2);
|
||||
expect(errors[0]).toContain("docker.dockerConfig");
|
||||
expect(errors[1]).toContain("docker.enableDocker");
|
||||
});
|
||||
|
||||
it("skips a plugin that is not running", () => {
|
||||
loaded.push({ id: "docker", manifest: DOCKER, state: "disabled" });
|
||||
const result = checkHostPluginSettingsInput({
|
||||
docker: { enableDocker: true },
|
||||
});
|
||||
expect(result).toEqual({ writes: [], skipped: ["docker"], errors: [] });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user