mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 16:50:23 +00:00
fix(test): align runtime config expectations
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applyRuntimeLegacyConfigMigrations } from "../commands/doctor/shared/runtime-compat-api.js";
|
||||
import {
|
||||
getConfigValueAtPath,
|
||||
parseConfigPath,
|
||||
@@ -474,6 +475,7 @@ describe("config strict validation", () => {
|
||||
|
||||
const snap = await readConfigFileSnapshot();
|
||||
|
||||
expect(snap.issues).toEqual([]);
|
||||
expect(snap.valid).toBe(true);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "memorySearch")).toBe(true);
|
||||
expect(snap.sourceConfig.agents?.defaults?.memorySearch).toMatchObject({
|
||||
@@ -742,113 +744,113 @@ describe("config strict validation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts legacy channel streaming aliases via auto-migration and reports legacyIssues", async () => {
|
||||
await withTempHome(async (home) => {
|
||||
await writeOpenClawConfig(home, {
|
||||
channels: {
|
||||
telegram: {
|
||||
streamMode: "block",
|
||||
chunkMode: "newline",
|
||||
blockStreaming: true,
|
||||
draftChunk: {
|
||||
minChars: 120,
|
||||
},
|
||||
},
|
||||
discord: {
|
||||
streaming: false,
|
||||
blockStreamingCoalesce: {
|
||||
idleMs: 250,
|
||||
},
|
||||
accounts: {
|
||||
work: {
|
||||
streamMode: "block",
|
||||
draftChunk: {
|
||||
maxChars: 900,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
googlechat: {
|
||||
streamMode: "append",
|
||||
accounts: {
|
||||
work: {
|
||||
streamMode: "replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
slack: {
|
||||
streaming: true,
|
||||
nativeStreaming: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const snap = await readConfigFileSnapshot();
|
||||
|
||||
expect(snap.valid).toBe(true);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.telegram")).toBe(true);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.discord")).toBe(true);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.discord.accounts")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.googlechat")).toBe(true);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.googlechat.accounts")).toBe(
|
||||
true,
|
||||
);
|
||||
expect(snap.legacyIssues.some((issue) => issue.path === "channels.slack")).toBe(true);
|
||||
expect(snap.sourceConfig.channels?.telegram).toMatchObject({
|
||||
streaming: {
|
||||
mode: "block",
|
||||
it("accepts legacy channel streaming aliases via auto-migration and reports legacyIssues", () => {
|
||||
const raw = {
|
||||
channels: {
|
||||
telegram: {
|
||||
streamMode: "block",
|
||||
chunkMode: "newline",
|
||||
block: {
|
||||
enabled: true,
|
||||
blockStreaming: true,
|
||||
draftChunk: {
|
||||
minChars: 120,
|
||||
},
|
||||
preview: {
|
||||
chunk: {
|
||||
minChars: 120,
|
||||
},
|
||||
discord: {
|
||||
streaming: false,
|
||||
blockStreamingCoalesce: {
|
||||
idleMs: 250,
|
||||
},
|
||||
accounts: {
|
||||
work: {
|
||||
streamMode: "block",
|
||||
draftChunk: {
|
||||
maxChars: 900,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
(snap.sourceConfig.channels?.telegram as Record<string, unknown> | undefined)?.streamMode,
|
||||
).toBeUndefined();
|
||||
expect(snap.sourceConfig.channels?.discord).toMatchObject({
|
||||
streaming: {
|
||||
mode: "off",
|
||||
block: {
|
||||
coalesce: {
|
||||
idleMs: 250,
|
||||
googlechat: {
|
||||
streamMode: "append",
|
||||
accounts: {
|
||||
work: {
|
||||
streamMode: "replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(snap.sourceConfig.channels?.discord?.accounts?.work).toMatchObject({
|
||||
streaming: {
|
||||
mode: "block",
|
||||
preview: {
|
||||
chunk: {
|
||||
maxChars: 900,
|
||||
},
|
||||
slack: {
|
||||
streaming: true,
|
||||
nativeStreaming: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const migrated = applyRuntimeLegacyConfigMigrations(raw);
|
||||
expect(migrated.next).not.toBeNull();
|
||||
|
||||
if (!migrated.next) {
|
||||
return;
|
||||
}
|
||||
const channels = (
|
||||
migrated.next as {
|
||||
channels?: {
|
||||
telegram?: unknown;
|
||||
discord?: { accounts?: { work?: unknown } };
|
||||
googlechat?: { accounts?: { work?: unknown } };
|
||||
slack?: unknown;
|
||||
};
|
||||
}
|
||||
).channels;
|
||||
expect(channels?.telegram).toMatchObject({
|
||||
streaming: {
|
||||
mode: "block",
|
||||
chunkMode: "newline",
|
||||
block: {
|
||||
enabled: true,
|
||||
},
|
||||
preview: {
|
||||
chunk: {
|
||||
minChars: 120,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
(snap.sourceConfig.channels?.googlechat as Record<string, unknown> | undefined)?.streamMode,
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
(
|
||||
snap.sourceConfig.channels?.googlechat?.accounts?.work as
|
||||
| Record<string, unknown>
|
||||
| undefined
|
||||
)?.streamMode,
|
||||
).toBeUndefined();
|
||||
expect(snap.sourceConfig.channels?.slack).toMatchObject({
|
||||
streaming: {
|
||||
mode: "partial",
|
||||
nativeTransport: false,
|
||||
},
|
||||
});
|
||||
expect((channels?.telegram as Record<string, unknown> | undefined)?.streamMode).toBeUndefined();
|
||||
expect(channels?.discord).toMatchObject({
|
||||
streaming: {
|
||||
mode: "off",
|
||||
block: {
|
||||
coalesce: {
|
||||
idleMs: 250,
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
expect(channels?.discord?.accounts?.work).toMatchObject({
|
||||
streaming: {
|
||||
mode: "block",
|
||||
preview: {
|
||||
chunk: {
|
||||
maxChars: 900,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(channels?.googlechat).toMatchObject({
|
||||
accounts: {
|
||||
work: {},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
(channels?.googlechat as Record<string, unknown> | undefined)?.streamMode,
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
(channels?.googlechat?.accounts?.work as Record<string, unknown> | undefined)?.streamMode,
|
||||
).toBeUndefined();
|
||||
expect(channels?.slack).toMatchObject({
|
||||
streaming: {
|
||||
mode: "partial",
|
||||
nativeTransport: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user