mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:10:44 +00:00
test(config): remove runtime legacy compat wrapper
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { __testing, resolveCliChannelOptions } from "./channel-options.js";
|
||||
import { __testing as startupMetadataTesting } from "./startup-metadata.js";
|
||||
|
||||
const readFileSyncMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
@@ -23,6 +24,7 @@ vi.mock("../channels/ids.js", () => ({
|
||||
describe("resolveCliChannelOptions", () => {
|
||||
afterEach(() => {
|
||||
__testing.resetPrecomputedChannelOptionsForTests();
|
||||
startupMetadataTesting.clearStartupMetadataCache();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import type { OpenClawConfig } from "../../../config/types.openclaw.js";
|
||||
import { normalizeBaseCompatibilityConfigValues } from "./legacy-config-compatibility-base.js";
|
||||
|
||||
export function normalizeRuntimeCompatibilityConfigValues(cfg: OpenClawConfig): {
|
||||
config: OpenClawConfig;
|
||||
changes: string[];
|
||||
} {
|
||||
const changes: string[] = [];
|
||||
const next = normalizeBaseCompatibilityConfigValues(cfg, changes);
|
||||
return { config: next, changes };
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { isDeepStrictEqual } from "node:util";
|
||||
import type { OpenClawConfig } from "../../../config/types.openclaw.js";
|
||||
import { applyLegacyDoctorMigrations } from "./legacy-config-compat.js";
|
||||
import { normalizeRuntimeCompatibilityConfigValues } from "./legacy-config-runtime-migrate.js";
|
||||
|
||||
export function applyRuntimeLegacyConfigMigrations(raw: unknown): {
|
||||
next: Record<string, unknown> | null;
|
||||
changes: string[];
|
||||
} {
|
||||
if (!raw || typeof raw !== "object") {
|
||||
return { next: null, changes: [] };
|
||||
}
|
||||
|
||||
const original = raw as Record<string, unknown>;
|
||||
const migrated = applyLegacyDoctorMigrations(original);
|
||||
const base = (migrated.next ?? original) as OpenClawConfig;
|
||||
const normalized = normalizeRuntimeCompatibilityConfigValues(base);
|
||||
const next = normalized.config as OpenClawConfig & Record<string, unknown>;
|
||||
const changes = [...migrated.changes, ...normalized.changes];
|
||||
|
||||
if (changes.length === 0 || isDeepStrictEqual(next, original)) {
|
||||
return { next: null, changes: [] };
|
||||
}
|
||||
return { next, changes };
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js";
|
||||
import {
|
||||
getConfigValueAtPath,
|
||||
parseConfigPath,
|
||||
@@ -940,7 +939,7 @@ describe("config strict validation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts legacy messages.tts provider keys via auto-migration and reports legacyIssues", async () => {
|
||||
it("reports legacy messages.tts provider keys without read-time auto-migration", async () => {
|
||||
const raw = {
|
||||
messages: {
|
||||
tts: {
|
||||
@@ -953,29 +952,13 @@ describe("config strict validation", () => {
|
||||
},
|
||||
};
|
||||
const issues = findLegacyConfigIssues(raw);
|
||||
const migrated = applyRuntimeLegacyConfigMigrations(raw);
|
||||
|
||||
expect(issues.some((issue) => issue.path === "messages.tts")).toBe(true);
|
||||
expect(migrated.next).not.toBeNull();
|
||||
|
||||
const next = migrated.next as {
|
||||
messages?: {
|
||||
tts?: {
|
||||
providers?: {
|
||||
elevenlabs?: {
|
||||
apiKey?: string;
|
||||
voiceId?: string;
|
||||
};
|
||||
};
|
||||
elevenlabs?: unknown;
|
||||
};
|
||||
};
|
||||
} | null;
|
||||
expect(next?.messages?.tts?.providers?.elevenlabs).toEqual({
|
||||
expect(raw.messages.tts.elevenlabs).toEqual({
|
||||
apiKey: "test-key",
|
||||
voiceId: "voice-1",
|
||||
});
|
||||
expect(next?.messages?.tts?.elevenlabs).toBeUndefined();
|
||||
expect(raw.messages.tts).not.toHaveProperty("providers");
|
||||
});
|
||||
|
||||
it("rejects legacy sandbox perSession without read-time auto-migration", async () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js";
|
||||
import { normalizeCompatibilityConfigValues } from "../commands/doctor-legacy-config.js";
|
||||
import { createConfigIO } from "./io.js";
|
||||
import { normalizeExecSafeBinProfilesInConfig } from "./normalize-exec-safe-bin.js";
|
||||
import type { OpenClawConfig } from "./types.openclaw.js";
|
||||
@@ -155,7 +155,7 @@ describe("config io paths", () => {
|
||||
});
|
||||
|
||||
it("moves WhatsApp shared access defaults into accounts.default during runtime compat", () => {
|
||||
const migrated = applyRuntimeLegacyConfigMigrations({
|
||||
const migrated = normalizeCompatibilityConfigValues({
|
||||
channels: {
|
||||
whatsapp: {
|
||||
enabled: true,
|
||||
@@ -171,9 +171,8 @@ describe("config io paths", () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const next = migrated.next as OpenClawConfig | null;
|
||||
expect(next?.channels?.whatsapp?.accounts?.default).toMatchObject({
|
||||
} as OpenClawConfig);
|
||||
expect(migrated.config.channels?.whatsapp?.accounts?.default).toMatchObject({
|
||||
dmPolicy: "allowlist",
|
||||
allowFrom: ["+15550001111"],
|
||||
groupPolicy: "open",
|
||||
|
||||
Reference in New Issue
Block a user