mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 01:10:42 +00:00
fix: deprecate models add command (#71175)
This commit is contained in:
@@ -3,12 +3,12 @@ import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||
import {
|
||||
isCommandFlagEnabled,
|
||||
isModelsWriteEnabled,
|
||||
isRestartEnabled,
|
||||
isNativeCommandsExplicitlyDisabled,
|
||||
resolveNativeCommandsEnabled,
|
||||
resolveNativeSkillsEnabled,
|
||||
} from "./commands.js";
|
||||
import { validateConfigObjectWithPlugins } from "./validation.js";
|
||||
|
||||
beforeEach(() => {
|
||||
setActivePluginRegistry(
|
||||
@@ -201,24 +201,6 @@ describe("isRestartEnabled", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isModelsWriteEnabled", () => {
|
||||
it("defaults to enabled unless explicitly false", () => {
|
||||
expect(isModelsWriteEnabled(undefined)).toBe(true);
|
||||
expect(isModelsWriteEnabled({})).toBe(true);
|
||||
expect(isModelsWriteEnabled({ commands: {} })).toBe(true);
|
||||
expect(isModelsWriteEnabled({ commands: { modelsWrite: true } })).toBe(true);
|
||||
expect(isModelsWriteEnabled({ commands: { modelsWrite: false } })).toBe(false);
|
||||
});
|
||||
|
||||
it("ignores inherited modelsWrite flags", () => {
|
||||
expect(
|
||||
isModelsWriteEnabled({
|
||||
commands: Object.create({ modelsWrite: false }) as Record<string, unknown>,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isCommandFlagEnabled", () => {
|
||||
it("requires own boolean true", () => {
|
||||
expect(isCommandFlagEnabled({ commands: { bash: true } }, "bash")).toBe(true);
|
||||
@@ -233,3 +215,17 @@ describe("isCommandFlagEnabled", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deprecated commands compatibility", () => {
|
||||
it("ignores legacy modelsWrite during validation", () => {
|
||||
const result = validateConfigObjectWithPlugins({
|
||||
commands: { text: true, modelsWrite: false },
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (result.ok) {
|
||||
expect(result.config.commands).toMatchObject({ text: true });
|
||||
expect(Object.hasOwn(result.config.commands ?? {}, "modelsWrite")).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user