mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 23:40:23 +00:00
test: trim config migration smoke coverage
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyLegacyDoctorMigrations } from "../commands/doctor/shared/legacy-config-migrate.js";
|
||||
import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js";
|
||||
import {
|
||||
getConfigValueAtPath,
|
||||
@@ -760,224 +759,6 @@ describe("config strict validation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts legacy channel streaming aliases via auto-migration and reports legacyIssues", () => {
|
||||
const raw = {
|
||||
channels: {
|
||||
discord: {
|
||||
accounts: {
|
||||
work: {
|
||||
streamMode: "block",
|
||||
draftChunk: {
|
||||
maxChars: 900,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const migrated = applyLegacyDoctorMigrations(raw);
|
||||
expect(migrated.next).not.toBeNull();
|
||||
|
||||
if (!migrated.next) {
|
||||
return;
|
||||
}
|
||||
const channels = (
|
||||
migrated.next as {
|
||||
channels?: {
|
||||
discord?: { accounts?: { work?: unknown } };
|
||||
};
|
||||
}
|
||||
).channels;
|
||||
expect(channels?.discord?.accounts?.work).toMatchObject({
|
||||
streaming: {
|
||||
mode: "block",
|
||||
preview: {
|
||||
chunk: {
|
||||
maxChars: 900,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts legacy nested channel allow aliases via auto-migration and reports legacyIssues", () => {
|
||||
const raw = {
|
||||
channels: {
|
||||
slack: {
|
||||
channels: {
|
||||
ops: {
|
||||
allow: false,
|
||||
},
|
||||
},
|
||||
accounts: {
|
||||
work: {
|
||||
channels: {
|
||||
general: {
|
||||
allow: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
googlechat: {
|
||||
groups: {
|
||||
"spaces/aaa": {
|
||||
allow: false,
|
||||
},
|
||||
},
|
||||
accounts: {
|
||||
work: {
|
||||
groups: {
|
||||
"spaces/bbb": {
|
||||
allow: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
discord: {
|
||||
guilds: {
|
||||
"100": {
|
||||
channels: {
|
||||
general: {
|
||||
allow: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accounts: {
|
||||
work: {
|
||||
guilds: {
|
||||
"200": {
|
||||
channels: {
|
||||
help: {
|
||||
allow: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const issues = findLegacyConfigIssues(raw);
|
||||
const migrated = applyRuntimeLegacyConfigMigrations(raw);
|
||||
|
||||
expect(issues.some((issue) => issue.path === "channels.slack")).toBe(true);
|
||||
expect(issues.some((issue) => issue.path === "channels.slack.accounts")).toBe(true);
|
||||
expect(issues.some((issue) => issue.path === "channels.googlechat")).toBe(true);
|
||||
expect(issues.some((issue) => issue.path === "channels.googlechat.accounts")).toBe(true);
|
||||
expect(issues.some((issue) => issue.path === "channels.discord")).toBe(true);
|
||||
expect(issues.some((issue) => issue.path === "channels.discord.accounts")).toBe(true);
|
||||
expect(migrated.next).not.toBeNull();
|
||||
|
||||
const next = migrated.next as {
|
||||
channels?: {
|
||||
slack?: {
|
||||
channels?: {
|
||||
ops?: {
|
||||
enabled?: boolean;
|
||||
allow?: unknown;
|
||||
};
|
||||
};
|
||||
};
|
||||
googlechat?: {
|
||||
groups?: {
|
||||
"spaces/aaa"?: {
|
||||
enabled?: boolean;
|
||||
allow?: unknown;
|
||||
};
|
||||
};
|
||||
};
|
||||
discord?: {
|
||||
guilds?: {
|
||||
"100"?: {
|
||||
channels?: {
|
||||
general?: {
|
||||
enabled?: boolean;
|
||||
allow?: unknown;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} | null;
|
||||
expect(next?.channels?.slack?.channels?.ops).toMatchObject({
|
||||
enabled: false,
|
||||
});
|
||||
expect(next?.channels?.googlechat?.groups?.["spaces/aaa"]).toMatchObject({
|
||||
enabled: false,
|
||||
});
|
||||
expect(next?.channels?.discord?.guilds?.["100"]?.channels?.general).toMatchObject({
|
||||
enabled: false,
|
||||
});
|
||||
expect(next?.channels?.slack?.channels?.ops?.allow).toBeUndefined();
|
||||
expect(next?.channels?.googlechat?.groups?.["spaces/aaa"]?.allow).toBeUndefined();
|
||||
expect(next?.channels?.discord?.guilds?.["100"]?.channels?.general?.allow).toBeUndefined();
|
||||
});
|
||||
|
||||
it("accepts legacy discord voice tts provider keys via auto-migration and reports legacyIssues", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
await writeOpenClawConfig(home, {
|
||||
channels: {
|
||||
discord: {
|
||||
voice: {
|
||||
tts: {
|
||||
provider: "elevenlabs",
|
||||
elevenlabs: {
|
||||
voiceId: "voice-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
accounts: {
|
||||
main: {
|
||||
voice: {
|
||||
tts: {
|
||||
edge: {
|
||||
voice: "en-US-AvaNeural",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const snap = await readConfigFileSnapshot();
|
||||
|
||||
expect(snap.valid).toBe(true);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.discord.voice.tts")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.discord.accounts")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(snap.sourceConfig.channels?.discord?.voice?.tts?.providers?.elevenlabs).toEqual({
|
||||
voiceId: "voice-1",
|
||||
});
|
||||
expect(
|
||||
snap.sourceConfig.channels?.discord?.accounts?.main?.voice?.tts?.providers?.microsoft,
|
||||
).toEqual({
|
||||
voice: "en-US-AvaNeural",
|
||||
});
|
||||
expect(
|
||||
(snap.sourceConfig.channels?.discord?.voice?.tts as Record<string, unknown> | undefined)
|
||||
?.elevenlabs,
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
(
|
||||
snap.sourceConfig.channels?.discord?.accounts?.main?.voice?.tts as
|
||||
| Record<string, unknown>
|
||||
| undefined
|
||||
)?.edge,
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("does not treat resolved-only gateway.bind aliases as source-literal legacy or invalid", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
await writeOpenClawConfig(home, {
|
||||
|
||||
Reference in New Issue
Block a user