mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 14:40:20 +00:00
refactor(config): dedupe native command setting resolver
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveNativeSkillsEnabled } from "./commands.js";
|
||||
import {
|
||||
isNativeCommandsExplicitlyDisabled,
|
||||
resolveNativeCommandsEnabled,
|
||||
resolveNativeSkillsEnabled,
|
||||
} from "./commands.js";
|
||||
|
||||
describe("resolveNativeSkillsEnabled", () => {
|
||||
it("uses provider defaults for auto", () => {
|
||||
@@ -46,3 +50,50 @@ describe("resolveNativeSkillsEnabled", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveNativeCommandsEnabled", () => {
|
||||
it("follows the same provider default heuristic", () => {
|
||||
expect(resolveNativeCommandsEnabled({ providerId: "discord", globalSetting: "auto" })).toBe(
|
||||
true,
|
||||
);
|
||||
expect(resolveNativeCommandsEnabled({ providerId: "telegram", globalSetting: "auto" })).toBe(
|
||||
true,
|
||||
);
|
||||
expect(resolveNativeCommandsEnabled({ providerId: "slack", globalSetting: "auto" })).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it("honors explicit provider/global booleans", () => {
|
||||
expect(
|
||||
resolveNativeCommandsEnabled({
|
||||
providerId: "slack",
|
||||
providerSetting: true,
|
||||
globalSetting: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
resolveNativeCommandsEnabled({
|
||||
providerId: "discord",
|
||||
globalSetting: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isNativeCommandsExplicitlyDisabled", () => {
|
||||
it("returns true only for explicit false at provider or fallback global", () => {
|
||||
expect(
|
||||
isNativeCommandsExplicitlyDisabled({ providerSetting: false, globalSetting: true }),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isNativeCommandsExplicitlyDisabled({ providerSetting: undefined, globalSetting: false }),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isNativeCommandsExplicitlyDisabled({ providerSetting: true, globalSetting: false }),
|
||||
).toBe(false);
|
||||
expect(
|
||||
isNativeCommandsExplicitlyDisabled({ providerSetting: "auto", globalSetting: false }),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user