mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 23:51:32 +00:00
Refactor the Control UI around route-owned page lifecycle and state while preserving existing behavior and design.
Prepared head SHA: bd51b6fa76
Co-authored-by: Shakker <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
// Control UI tests cover plugin activation behavior.
|
|
import { describe, expect, it } from "vitest";
|
|
import { isPluginEnabledInConfigSnapshot } from "./plugin-activation.ts";
|
|
|
|
describe("isPluginEnabledInConfigSnapshot", () => {
|
|
it("uses the supplied default when config has not loaded yet", () => {
|
|
expect(
|
|
isPluginEnabledInConfigSnapshot({ hash: "hash-1" }, "memory-wiki", {
|
|
enabledByDefault: false,
|
|
}),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("treats bundled default-off plugins as disabled when config is present but silent", () => {
|
|
expect(
|
|
isPluginEnabledInConfigSnapshot(
|
|
{
|
|
hash: "hash-1",
|
|
config: {
|
|
plugins: {},
|
|
},
|
|
},
|
|
"memory-wiki",
|
|
{
|
|
enabledByDefault: false,
|
|
},
|
|
),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("returns true when the plugin is explicitly enabled", () => {
|
|
expect(
|
|
isPluginEnabledInConfigSnapshot(
|
|
{
|
|
hash: "hash-1",
|
|
config: {
|
|
plugins: {
|
|
entries: {
|
|
"memory-wiki": {
|
|
enabled: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"memory-wiki",
|
|
{ enabledByDefault: false },
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("returns false when plugins.allow excludes the plugin", () => {
|
|
expect(
|
|
isPluginEnabledInConfigSnapshot(
|
|
{
|
|
hash: "hash-1",
|
|
config: {
|
|
plugins: {
|
|
allow: ["memory-core"],
|
|
entries: {
|
|
"memory-wiki": {
|
|
enabled: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"memory-wiki",
|
|
{ enabledByDefault: false },
|
|
),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("keeps default-on plugins enabled when config is silent", () => {
|
|
expect(
|
|
isPluginEnabledInConfigSnapshot({ hash: "hash-1" }, "browser", {
|
|
enabledByDefault: true,
|
|
}),
|
|
).toBe(true);
|
|
});
|
|
});
|