From 8ab84bceb3203dd7e6ccac6aa987a368f69fa769 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 11 Apr 2026 05:52:03 +0100 Subject: [PATCH] test: make talk and compaction config checks pure --- src/config/talk.normalize.test.ts | 41 ++++++------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/src/config/talk.normalize.test.ts b/src/config/talk.normalize.test.ts index d996189b1c4..f1150b05278 100644 --- a/src/config/talk.normalize.test.ts +++ b/src/config/talk.normalize.test.ts @@ -1,25 +1,7 @@ -import fs from "node:fs/promises"; -import os from "node:os"; -import path from "node:path"; import { describe, expect, it } from "vitest"; import { TALK_TEST_PROVIDER_ID } from "../test-utils/talk-test-provider.js"; -import { createConfigIO } from "./io.js"; import { buildTalkConfigResponse, normalizeTalkSection } from "./talk.js"; -async function withTempConfig( - config: unknown, - run: (configPath: string) => Promise, -): Promise { - const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-talk-")); - const configPath = path.join(dir, "openclaw.json"); - await fs.writeFile(configPath, JSON.stringify(config, null, 2)); - try { - await run(configPath); - } finally { - await fs.rm(dir, { recursive: true, force: true }); - } -} - describe("talk normalization", () => { it("keeps core Talk normalization generic and ignores legacy provider-flat fields", () => { const normalized = normalizeTalkSection({ @@ -137,20 +119,13 @@ describe("talk normalization", () => { }); }); - it("does not inject provider apiKey defaults during snapshot materialization", async () => { - await withTempConfig( - { - talk: { - voiceId: "voice-123", - }, - }, - async (configPath) => { - const io = createConfigIO({ configPath }); - const snapshot = await io.readConfigFileSnapshot(); - expect(snapshot.config.talk?.provider).toBeUndefined(); - expect(snapshot.config.talk?.providers?.elevenlabs?.voiceId).toBe("voice-123"); - expect(snapshot.config.talk?.providers?.elevenlabs?.apiKey).toBeUndefined(); - }, - ); + it("does not inject provider apiKey defaults during snapshot materialization", () => { + const payload = buildTalkConfigResponse({ + voiceId: "voice-123", + }); + + expect(payload?.provider).toBe("elevenlabs"); + expect(payload?.resolved?.config.voiceId).toBe("voice-123"); + expect(payload?.resolved?.config.apiKey).toBeUndefined(); }); });