mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
// Canvas tests cover config migration plugin behavior.
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
import { describe, expect, test } from "vitest";
|
|
import { migrateLegacyCanvasHostConfig } from "./config-migration.js";
|
|
|
|
describe("migrateLegacyCanvasHostConfig", () => {
|
|
test("moves legacy canvasHost into the Canvas plugin config", () => {
|
|
const result = migrateLegacyCanvasHostConfig({
|
|
canvasHost: {
|
|
enabled: false,
|
|
root: "~/canvas",
|
|
liveReload: false,
|
|
},
|
|
} as OpenClawConfig);
|
|
|
|
if (!result) {
|
|
throw new Error("expected Canvas config migration result");
|
|
}
|
|
expect(result.changes).toEqual(["migrated canvasHost to plugins.entries.canvas.config.host"]);
|
|
expect(result.config).toEqual({
|
|
plugins: {
|
|
entries: {
|
|
canvas: {
|
|
config: {
|
|
host: {
|
|
enabled: false,
|
|
root: "~/canvas",
|
|
liveReload: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
test("preserves plugin-owned Canvas host values when both shapes exist", () => {
|
|
const result = migrateLegacyCanvasHostConfig({
|
|
canvasHost: {
|
|
enabled: false,
|
|
root: "~/legacy-canvas",
|
|
liveReload: false,
|
|
},
|
|
plugins: {
|
|
entries: {
|
|
canvas: {
|
|
enabled: true,
|
|
config: {
|
|
host: {
|
|
root: "~/plugin-canvas",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
} as OpenClawConfig);
|
|
|
|
if (!result) {
|
|
throw new Error("expected Canvas config migration result");
|
|
}
|
|
expect(result.config).toEqual({
|
|
plugins: {
|
|
entries: {
|
|
canvas: {
|
|
enabled: true,
|
|
config: {
|
|
host: {
|
|
enabled: false,
|
|
root: "~/plugin-canvas",
|
|
liveReload: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
test("ignores configs without legacy canvasHost", () => {
|
|
expect(migrateLegacyCanvasHostConfig({} as OpenClawConfig)).toBeNull();
|
|
});
|
|
});
|