mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 06:27:27 +00:00
perf(test): trim module resets in config suites
This commit is contained in:
@@ -1,12 +1,13 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import {
|
import {
|
||||||
DEFAULT_AGENT_MAX_CONCURRENT,
|
DEFAULT_AGENT_MAX_CONCURRENT,
|
||||||
DEFAULT_SUBAGENT_MAX_CONCURRENT,
|
DEFAULT_SUBAGENT_MAX_CONCURRENT,
|
||||||
resolveAgentMaxConcurrent,
|
resolveAgentMaxConcurrent,
|
||||||
resolveSubagentMaxConcurrent,
|
resolveSubagentMaxConcurrent,
|
||||||
} from "./agent-limits.js";
|
} from "./agent-limits.js";
|
||||||
|
import { loadConfig } from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("agent concurrency defaults", () => {
|
describe("agent concurrency defaults", () => {
|
||||||
@@ -51,8 +52,6 @@ describe("agent concurrency defaults", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.maxConcurrent).toBe(DEFAULT_AGENT_MAX_CONCURRENT);
|
expect(cfg.agents?.defaults?.maxConcurrent).toBe(DEFAULT_AGENT_MAX_CONCURRENT);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { loadConfig } from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("config compaction settings", () => {
|
describe("config compaction settings", () => {
|
||||||
@@ -33,8 +34,6 @@ describe("config compaction settings", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.compaction?.reserveTokensFloor).toBe(12_345);
|
expect(cfg.agents?.defaults?.compaction?.reserveTokensFloor).toBe(12_345);
|
||||||
@@ -68,8 +67,6 @@ describe("config compaction settings", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.compaction?.mode).toBe("safeguard");
|
expect(cfg.agents?.defaults?.compaction?.mode).toBe("safeguard");
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
import { loadConfig } from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("config discord", () => {
|
describe("config discord", () => {
|
||||||
@@ -55,8 +56,6 @@ describe("config discord", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.channels?.discord?.enabled).toBe(true);
|
expect(cfg.channels?.discord?.enabled).toBe(true);
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import {
|
||||||
|
loadConfig,
|
||||||
|
migrateLegacyConfig,
|
||||||
|
readConfigFileSnapshot,
|
||||||
|
validateConfigObject,
|
||||||
|
} from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("legacy config detection", () => {
|
describe("legacy config detection", () => {
|
||||||
it('accepts imessage.dmPolicy="open" with allowFrom "*"', async () => {
|
it('accepts imessage.dmPolicy="open" with allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { imessage: { dmPolicy: "open", allowFrom: ["*"] } },
|
channels: { imessage: { dmPolicy: "open", allowFrom: ["*"] } },
|
||||||
});
|
});
|
||||||
@@ -16,8 +20,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults imessage.dmPolicy to pairing when imessage section exists", async () => {
|
it("defaults imessage.dmPolicy to pairing when imessage section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { imessage: {} } });
|
const res = validateConfigObject({ channels: { imessage: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -25,8 +27,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults imessage.groupPolicy to allowlist when imessage section exists", async () => {
|
it("defaults imessage.groupPolicy to allowlist when imessage section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { imessage: {} } });
|
const res = validateConfigObject({ channels: { imessage: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -34,8 +34,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults discord.groupPolicy to allowlist when discord section exists", async () => {
|
it("defaults discord.groupPolicy to allowlist when discord section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { discord: {} } });
|
const res = validateConfigObject({ channels: { discord: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -43,8 +41,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults slack.groupPolicy to allowlist when slack section exists", async () => {
|
it("defaults slack.groupPolicy to allowlist when slack section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { slack: {} } });
|
const res = validateConfigObject({ channels: { slack: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -52,8 +48,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults msteams.groupPolicy to allowlist when msteams section exists", async () => {
|
it("defaults msteams.groupPolicy to allowlist when msteams section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { msteams: {} } });
|
const res = validateConfigObject({ channels: { msteams: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -61,8 +55,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("rejects unsafe executable config values", async () => {
|
it("rejects unsafe executable config values", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { imessage: { cliPath: "imsg; rm -rf /" } },
|
channels: { imessage: { cliPath: "imsg; rm -rf /" } },
|
||||||
audio: { transcription: { command: ["whisper", "--model", "base"] } },
|
audio: { transcription: { command: ["whisper", "--model", "base"] } },
|
||||||
@@ -73,16 +65,12 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("accepts tools audio transcription without cli", async () => {
|
it("accepts tools audio transcription without cli", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
audio: { transcription: { command: ["whisper", "--model", "base"] } },
|
audio: { transcription: { command: ["whisper", "--model", "base"] } },
|
||||||
});
|
});
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
});
|
});
|
||||||
it("accepts path-like executable values with spaces", async () => {
|
it("accepts path-like executable values with spaces", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { imessage: { cliPath: "/Applications/Imsg Tools/imsg" } },
|
channels: { imessage: { cliPath: "/Applications/Imsg Tools/imsg" } },
|
||||||
audio: {
|
audio: {
|
||||||
@@ -94,8 +82,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
});
|
});
|
||||||
it('rejects discord.dm.policy="open" without allowFrom "*"', async () => {
|
it('rejects discord.dm.policy="open" without allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { discord: { dm: { policy: "open", allowFrom: ["123"] } } },
|
channels: { discord: { dm: { policy: "open", allowFrom: ["123"] } } },
|
||||||
});
|
});
|
||||||
@@ -105,8 +91,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('rejects slack.dm.policy="open" without allowFrom "*"', async () => {
|
it('rejects slack.dm.policy="open" without allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { slack: { dm: { policy: "open", allowFrom: ["U123"] } } },
|
channels: { slack: { dm: { policy: "open", allowFrom: ["U123"] } } },
|
||||||
});
|
});
|
||||||
@@ -116,8 +100,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("rejects legacy agent.model string", async () => {
|
it("rejects legacy agent.model string", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
agent: { model: "anthropic/claude-opus-4-5" },
|
agent: { model: "anthropic/claude-opus-4-5" },
|
||||||
});
|
});
|
||||||
@@ -127,8 +109,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("migrates telegram.requireMention to channels.telegram.groups.*.requireMention", async () => {
|
it("migrates telegram.requireMention to channels.telegram.groups.*.requireMention", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
telegram: { requireMention: false },
|
telegram: { requireMention: false },
|
||||||
});
|
});
|
||||||
@@ -139,8 +119,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.channels?.telegram?.requireMention).toBeUndefined();
|
expect(res.config?.channels?.telegram?.requireMention).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates messages.tts.enabled to messages.tts.auto", async () => {
|
it("migrates messages.tts.enabled to messages.tts.auto", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
messages: { tts: { enabled: true } },
|
messages: { tts: { enabled: true } },
|
||||||
});
|
});
|
||||||
@@ -149,8 +127,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.messages?.tts?.enabled).toBeUndefined();
|
expect(res.config?.messages?.tts?.enabled).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates legacy model config to agent.models + model lists", async () => {
|
it("migrates legacy model config to agent.models + model lists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
agent: {
|
agent: {
|
||||||
model: "anthropic/claude-opus-4-5",
|
model: "anthropic/claude-opus-4-5",
|
||||||
@@ -184,8 +160,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -210,8 +184,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -238,8 +210,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
expect(cfg.auth?.profiles?.["anthropic:claude-cli"]?.mode).toBe("token");
|
expect(cfg.auth?.profiles?.["anthropic:claude-cli"]?.mode).toBe("token");
|
||||||
|
|
||||||
@@ -260,8 +230,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -286,8 +254,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -318,8 +284,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -348,8 +312,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -382,8 +344,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
@@ -406,8 +366,6 @@ describe("legacy config detection", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { migrateLegacyConfig, validateConfigObject } from "./config.js";
|
||||||
|
|
||||||
describe("legacy config detection", () => {
|
describe("legacy config detection", () => {
|
||||||
it("rejects routing.allowFrom", async () => {
|
it("rejects routing.allowFrom", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
routing: { allowFrom: ["+15555550123"] },
|
routing: { allowFrom: ["+15555550123"] },
|
||||||
});
|
});
|
||||||
@@ -13,8 +12,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("rejects routing.groupChat.requireMention", async () => {
|
it("rejects routing.groupChat.requireMention", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
routing: { groupChat: { requireMention: false } },
|
routing: { groupChat: { requireMention: false } },
|
||||||
});
|
});
|
||||||
@@ -24,8 +21,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("migrates routing.allowFrom to channels.whatsapp.allowFrom when whatsapp configured", async () => {
|
it("migrates routing.allowFrom to channels.whatsapp.allowFrom when whatsapp configured", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
routing: { allowFrom: ["+15555550123"] },
|
routing: { allowFrom: ["+15555550123"] },
|
||||||
channels: { whatsapp: {} },
|
channels: { whatsapp: {} },
|
||||||
@@ -35,8 +30,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.routing?.allowFrom).toBeUndefined();
|
expect(res.config?.routing?.allowFrom).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("drops routing.allowFrom when whatsapp missing", async () => {
|
it("drops routing.allowFrom when whatsapp missing", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
routing: { allowFrom: ["+15555550123"] },
|
routing: { allowFrom: ["+15555550123"] },
|
||||||
});
|
});
|
||||||
@@ -45,8 +38,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.routing?.allowFrom).toBeUndefined();
|
expect(res.config?.routing?.allowFrom).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates routing.groupChat.requireMention to channels whatsapp/telegram/imessage groups when whatsapp configured", async () => {
|
it("migrates routing.groupChat.requireMention to channels whatsapp/telegram/imessage groups when whatsapp configured", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
routing: { groupChat: { requireMention: false } },
|
routing: { groupChat: { requireMention: false } },
|
||||||
channels: { whatsapp: {} },
|
channels: { whatsapp: {} },
|
||||||
@@ -66,8 +57,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.routing?.groupChat?.requireMention).toBeUndefined();
|
expect(res.config?.routing?.groupChat?.requireMention).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates routing.groupChat.requireMention to telegram/imessage when whatsapp missing", async () => {
|
it("migrates routing.groupChat.requireMention to telegram/imessage when whatsapp missing", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
routing: { groupChat: { requireMention: false } },
|
routing: { groupChat: { requireMention: false } },
|
||||||
});
|
});
|
||||||
@@ -86,8 +75,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.routing?.groupChat?.requireMention).toBeUndefined();
|
expect(res.config?.routing?.groupChat?.requireMention).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates routing.groupChat.mentionPatterns to messages.groupChat.mentionPatterns", async () => {
|
it("migrates routing.groupChat.mentionPatterns to messages.groupChat.mentionPatterns", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
routing: { groupChat: { mentionPatterns: ["@openclaw"] } },
|
routing: { groupChat: { mentionPatterns: ["@openclaw"] } },
|
||||||
});
|
});
|
||||||
@@ -98,8 +85,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.routing?.groupChat?.mentionPatterns).toBeUndefined();
|
expect(res.config?.routing?.groupChat?.mentionPatterns).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates routing agentToAgent/queue/transcribeAudio to tools/messages/media", async () => {
|
it("migrates routing agentToAgent/queue/transcribeAudio to tools/messages/media", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
routing: {
|
routing: {
|
||||||
agentToAgent: { enabled: true, allow: ["main"] },
|
agentToAgent: { enabled: true, allow: ["main"] },
|
||||||
@@ -174,8 +159,6 @@ describe("legacy config detection", () => {
|
|||||||
expect(res.config?.audio).toBeUndefined();
|
expect(res.config?.audio).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates agent config into agents.defaults and tools", async () => {
|
it("migrates agent config into agents.defaults and tools", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
agent: {
|
agent: {
|
||||||
model: "openai/gpt-5.2",
|
model: "openai/gpt-5.2",
|
||||||
@@ -213,8 +196,6 @@ describe("legacy config detection", () => {
|
|||||||
expect((res.config as { agent?: unknown }).agent).toBeUndefined();
|
expect((res.config as { agent?: unknown }).agent).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("migrates top-level memorySearch to agents.defaults.memorySearch", async () => {
|
it("migrates top-level memorySearch to agents.defaults.memorySearch", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
memorySearch: {
|
memorySearch: {
|
||||||
provider: "local",
|
provider: "local",
|
||||||
@@ -231,8 +212,6 @@ describe("legacy config detection", () => {
|
|||||||
expect((res.config as { memorySearch?: unknown }).memorySearch).toBeUndefined();
|
expect((res.config as { memorySearch?: unknown }).memorySearch).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("merges top-level memorySearch into agents.defaults.memorySearch", async () => {
|
it("merges top-level memorySearch into agents.defaults.memorySearch", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
memorySearch: {
|
memorySearch: {
|
||||||
provider: "local",
|
provider: "local",
|
||||||
@@ -259,8 +238,6 @@ describe("legacy config detection", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("keeps nested agents.defaults.memorySearch values when merging legacy defaults", async () => {
|
it("keeps nested agents.defaults.memorySearch values when merging legacy defaults", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
memorySearch: {
|
memorySearch: {
|
||||||
query: {
|
query: {
|
||||||
@@ -290,8 +267,6 @@ describe("legacy config detection", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("migrates tools.bash to tools.exec", async () => {
|
it("migrates tools.bash to tools.exec", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
tools: {
|
tools: {
|
||||||
bash: { timeoutSec: 12 },
|
bash: { timeoutSec: 12 },
|
||||||
@@ -302,8 +277,6 @@ describe("legacy config detection", () => {
|
|||||||
expect((res.config?.tools as { bash?: unknown } | undefined)?.bash).toBeUndefined();
|
expect((res.config?.tools as { bash?: unknown } | undefined)?.bash).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("accepts per-agent tools.elevated overrides", async () => {
|
it("accepts per-agent tools.elevated overrides", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
tools: {
|
tools: {
|
||||||
elevated: {
|
elevated: {
|
||||||
@@ -334,8 +307,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("rejects telegram.requireMention", async () => {
|
it("rejects telegram.requireMention", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
telegram: { requireMention: true },
|
telegram: { requireMention: true },
|
||||||
});
|
});
|
||||||
@@ -345,8 +316,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("rejects gateway.token", async () => {
|
it("rejects gateway.token", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
gateway: { token: "legacy-token" },
|
gateway: { token: "legacy-token" },
|
||||||
});
|
});
|
||||||
@@ -356,8 +325,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("migrates gateway.token to gateway.auth.token", async () => {
|
it("migrates gateway.token to gateway.auth.token", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
gateway: { token: "legacy-token" },
|
gateway: { token: "legacy-token" },
|
||||||
});
|
});
|
||||||
@@ -367,8 +334,6 @@ describe("legacy config detection", () => {
|
|||||||
expect((res.config?.gateway as { token?: string })?.token).toBeUndefined();
|
expect((res.config?.gateway as { token?: string })?.token).toBeUndefined();
|
||||||
});
|
});
|
||||||
it("keeps gateway.bind tailnet", async () => {
|
it("keeps gateway.bind tailnet", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { migrateLegacyConfig, validateConfigObject } = await import("./config.js");
|
|
||||||
const res = migrateLegacyConfig({
|
const res = migrateLegacyConfig({
|
||||||
gateway: { bind: "tailnet" as const },
|
gateway: { bind: "tailnet" as const },
|
||||||
});
|
});
|
||||||
@@ -382,8 +347,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('rejects telegram.dmPolicy="open" without allowFrom "*"', async () => {
|
it('rejects telegram.dmPolicy="open" without allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { telegram: { dmPolicy: "open", allowFrom: ["123456789"] } },
|
channels: { telegram: { dmPolicy: "open", allowFrom: ["123456789"] } },
|
||||||
});
|
});
|
||||||
@@ -393,8 +356,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('accepts telegram.dmPolicy="open" with allowFrom "*"', async () => {
|
it('accepts telegram.dmPolicy="open" with allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { telegram: { dmPolicy: "open", allowFrom: ["*"] } },
|
channels: { telegram: { dmPolicy: "open", allowFrom: ["*"] } },
|
||||||
});
|
});
|
||||||
@@ -404,8 +365,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults telegram.dmPolicy to pairing when telegram section exists", async () => {
|
it("defaults telegram.dmPolicy to pairing when telegram section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { telegram: {} } });
|
const res = validateConfigObject({ channels: { telegram: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -413,8 +372,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults telegram.groupPolicy to allowlist when telegram section exists", async () => {
|
it("defaults telegram.groupPolicy to allowlist when telegram section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { telegram: {} } });
|
const res = validateConfigObject({ channels: { telegram: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -422,8 +379,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults telegram.streamMode to partial when telegram section exists", async () => {
|
it("defaults telegram.streamMode to partial when telegram section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { telegram: {} } });
|
const res = validateConfigObject({ channels: { telegram: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -431,8 +386,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('rejects whatsapp.dmPolicy="open" without allowFrom "*"', async () => {
|
it('rejects whatsapp.dmPolicy="open" without allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: {
|
channels: {
|
||||||
whatsapp: { dmPolicy: "open", allowFrom: ["+15555550123"] },
|
whatsapp: { dmPolicy: "open", allowFrom: ["+15555550123"] },
|
||||||
@@ -444,8 +397,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('accepts whatsapp.dmPolicy="open" with allowFrom "*"', async () => {
|
it('accepts whatsapp.dmPolicy="open" with allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { whatsapp: { dmPolicy: "open", allowFrom: ["*"] } },
|
channels: { whatsapp: { dmPolicy: "open", allowFrom: ["*"] } },
|
||||||
});
|
});
|
||||||
@@ -455,8 +406,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults whatsapp.dmPolicy to pairing when whatsapp section exists", async () => {
|
it("defaults whatsapp.dmPolicy to pairing when whatsapp section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { whatsapp: {} } });
|
const res = validateConfigObject({ channels: { whatsapp: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -464,8 +413,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults whatsapp.groupPolicy to allowlist when whatsapp section exists", async () => {
|
it("defaults whatsapp.groupPolicy to allowlist when whatsapp section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { whatsapp: {} } });
|
const res = validateConfigObject({ channels: { whatsapp: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -473,8 +420,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('rejects signal.dmPolicy="open" without allowFrom "*"', async () => {
|
it('rejects signal.dmPolicy="open" without allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { signal: { dmPolicy: "open", allowFrom: ["+15555550123"] } },
|
channels: { signal: { dmPolicy: "open", allowFrom: ["+15555550123"] } },
|
||||||
});
|
});
|
||||||
@@ -484,8 +429,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('accepts signal.dmPolicy="open" with allowFrom "*"', async () => {
|
it('accepts signal.dmPolicy="open" with allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: { signal: { dmPolicy: "open", allowFrom: ["*"] } },
|
channels: { signal: { dmPolicy: "open", allowFrom: ["*"] } },
|
||||||
});
|
});
|
||||||
@@ -495,8 +438,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults signal.dmPolicy to pairing when signal section exists", async () => {
|
it("defaults signal.dmPolicy to pairing when signal section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { signal: {} } });
|
const res = validateConfigObject({ channels: { signal: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -504,8 +445,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("defaults signal.groupPolicy to allowlist when signal section exists", async () => {
|
it("defaults signal.groupPolicy to allowlist when signal section exists", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({ channels: { signal: {} } });
|
const res = validateConfigObject({ channels: { signal: {} } });
|
||||||
expect(res.ok).toBe(true);
|
expect(res.ok).toBe(true);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
@@ -513,8 +452,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it("accepts historyLimit overrides per provider and account", async () => {
|
it("accepts historyLimit overrides per provider and account", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
messages: { groupChat: { historyLimit: 12 } },
|
messages: { groupChat: { historyLimit: 12 } },
|
||||||
channels: {
|
channels: {
|
||||||
@@ -542,8 +479,6 @@ describe("legacy config detection", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('rejects imessage.dmPolicy="open" without allowFrom "*"', async () => {
|
it('rejects imessage.dmPolicy="open" without allowFrom "*"', async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
channels: {
|
channels: {
|
||||||
imessage: { dmPolicy: "open", allowFrom: ["+15555550123"] },
|
imessage: { dmPolicy: "open", allowFrom: ["+15555550123"] },
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ import fs from "node:fs/promises";
|
|||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
import { loadConfig, validateConfigObject } from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("multi-agent agentDir validation", () => {
|
describe("multi-agent agentDir validation", () => {
|
||||||
it("rejects shared agents.list agentDir", async () => {
|
it("rejects shared agents.list agentDir", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const shared = path.join(tmpdir(), "openclaw-shared-agentdir");
|
const shared = path.join(tmpdir(), "openclaw-shared-agentdir");
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
agents: {
|
agents: {
|
||||||
@@ -46,9 +45,7 @@ describe("multi-agent agentDir validation", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const spy = vi.spyOn(console, "error").mockImplementation(() => {});
|
const spy = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
expect(() => loadConfig()).toThrow(/duplicate agentDir/i);
|
expect(() => loadConfig()).toThrow(/duplicate agentDir/i);
|
||||||
expect(spy.mock.calls.flat().join(" ")).toMatch(/Duplicate agentDir/i);
|
expect(spy.mock.calls.flat().join(" ")).toMatch(/Duplicate agentDir/i);
|
||||||
spy.mockRestore();
|
spy.mockRestore();
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { readConfigFileSnapshot, validateConfigObject } from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("config strict validation", () => {
|
describe("config strict validation", () => {
|
||||||
it("rejects unknown fields", async () => {
|
it("rejects unknown fields", async () => {
|
||||||
vi.resetModules();
|
|
||||||
const { validateConfigObject } = await import("./config.js");
|
|
||||||
const res = validateConfigObject({
|
const res = validateConfigObject({
|
||||||
agents: { list: [{ id: "pi" }] },
|
agents: { list: [{ id: "pi" }] },
|
||||||
customUnknownField: { nested: "value" },
|
customUnknownField: { nested: "value" },
|
||||||
@@ -27,8 +26,6 @@ describe("config strict validation", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { readConfigFileSnapshot } = await import("./config.js");
|
|
||||||
const snap = await readConfigFileSnapshot();
|
const snap = await readConfigFileSnapshot();
|
||||||
|
|
||||||
expect(snap.valid).toBe(false);
|
expect(snap.valid).toBe(false);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import fs from "node:fs/promises";
|
import fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { loadConfig } from "./config.js";
|
||||||
import { withTempHome } from "./test-helpers.js";
|
import { withTempHome } from "./test-helpers.js";
|
||||||
|
|
||||||
describe("config pruning defaults", () => {
|
describe("config pruning defaults", () => {
|
||||||
@@ -18,8 +19,6 @@ describe("config pruning defaults", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.contextPruning?.mode).toBeUndefined();
|
expect(cfg.agents?.defaults?.contextPruning?.mode).toBeUndefined();
|
||||||
@@ -57,8 +56,6 @@ describe("config pruning defaults", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("cache-ttl");
|
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("cache-ttl");
|
||||||
@@ -92,8 +89,6 @@ describe("config pruning defaults", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("cache-ttl");
|
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("cache-ttl");
|
||||||
@@ -115,8 +110,6 @@ describe("config pruning defaults", () => {
|
|||||||
"utf-8",
|
"utf-8",
|
||||||
);
|
);
|
||||||
|
|
||||||
vi.resetModules();
|
|
||||||
const { loadConfig } = await import("./config.js");
|
|
||||||
const cfg = loadConfig();
|
const cfg = loadConfig();
|
||||||
|
|
||||||
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("off");
|
expect(cfg.agents?.defaults?.contextPruning?.mode).toBe("off");
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { withTempHome } from "../../test/helpers/temp-home.js";
|
import { withTempHome } from "../../test/helpers/temp-home.js";
|
||||||
|
import { normalizeConfigPaths } from "./normalize-paths.js";
|
||||||
|
|
||||||
describe("normalizeConfigPaths", () => {
|
describe("normalizeConfigPaths", () => {
|
||||||
it("expands tilde for path-ish keys only", async () => {
|
it("expands tilde for path-ish keys only", async () => {
|
||||||
await withTempHome(async (home) => {
|
await withTempHome(async (home) => {
|
||||||
vi.resetModules();
|
|
||||||
const { normalizeConfigPaths } = await import("./normalize-paths.js");
|
|
||||||
|
|
||||||
const cfg = normalizeConfigPaths({
|
const cfg = normalizeConfigPaths({
|
||||||
tools: { exec: { pathPrepend: ["~/bin"] } },
|
tools: { exec: { pathPrepend: ["~/bin"] } },
|
||||||
plugins: { load: { paths: ["~/plugins/a"] } },
|
plugins: { load: { paths: ["~/plugins/a"] } },
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
describe("logger import side effects", () => {
|
describe("logger import side effects", () => {
|
||||||
beforeEach(() => {
|
|
||||||
vi.resetModules();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user