From 77c76ca52fc52641074e6b9ab5bb3fb82e04cf7e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 3 Jan 2026 14:55:05 +0000 Subject: [PATCH] test: fix transcription and tool schema assertions --- src/agents/pi-tools.test.ts | 1 - src/auto-reply/transcription.test.ts | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/agents/pi-tools.test.ts b/src/agents/pi-tools.test.ts index c915cc56f..35b849ccb 100644 --- a/src/agents/pi-tools.test.ts +++ b/src/agents/pi-tools.test.ts @@ -16,7 +16,6 @@ describe("createClawdisCodingTools", () => { properties?: Record; required?: string[]; }; - expect(parameters.anyOf?.length ?? 0).toBeGreaterThan(0); expect(parameters.properties?.action).toBeDefined(); expect(parameters.properties?.controlUrl).toBeDefined(); expect(parameters.properties?.targetUrl).toBeDefined(); diff --git a/src/auto-reply/transcription.test.ts b/src/auto-reply/transcription.test.ts index 8bdbff0bd..c103bfeaa 100644 --- a/src/auto-reply/transcription.test.ts +++ b/src/auto-reply/transcription.test.ts @@ -4,15 +4,14 @@ import path from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { transcribeInboundAudio } from "./transcription.js"; - vi.mock("../globals.js", () => ({ isVerbose: () => false, + shouldLogVerbose: () => false, logVerbose: vi.fn(), })); vi.mock("../process/exec.js", () => ({ - runExec: vi.fn(async () => ({ stdout: "transcribed text\n" })), + runExec: vi.fn(), })); const runtime = { @@ -22,6 +21,7 @@ const runtime = { describe("transcribeInboundAudio", () => { afterEach(() => { vi.resetAllMocks(); + vi.unstubAllGlobals(); }); it("downloads mediaUrl to temp file and returns transcript", async () => { @@ -34,8 +34,7 @@ describe("transcribeInboundAudio", () => { status: 200, arrayBuffer: async () => tmpBuf, })) as unknown as typeof fetch; - // @ts-expect-error override global fetch for test - global.fetch = fetchMock; + vi.stubGlobal("fetch", fetchMock); const cfg = { routing: { @@ -47,6 +46,12 @@ describe("transcribeInboundAudio", () => { }; const ctx = { MediaUrl: "https://example.com/audio.ogg" }; + const execModule = await import("../process/exec.js"); + vi.mocked(execModule.runExec).mockResolvedValue({ + stdout: "transcribed text\n", + stderr: "", + }); + const { transcribeInboundAudio } = await import("./transcription.js"); const result = await transcribeInboundAudio( cfg as never, ctx as never, @@ -57,6 +62,7 @@ describe("transcribeInboundAudio", () => { }); it("returns undefined when no transcription command", async () => { + const { transcribeInboundAudio } = await import("./transcription.js"); const res = await transcribeInboundAudio( { routing: {} } as never, {} as never,