test: fix transcription and tool schema assertions
This commit is contained in:
@@ -16,7 +16,6 @@ describe("createClawdisCodingTools", () => {
|
||||
properties?: Record<string, unknown>;
|
||||
required?: string[];
|
||||
};
|
||||
expect(parameters.anyOf?.length ?? 0).toBeGreaterThan(0);
|
||||
expect(parameters.properties?.action).toBeDefined();
|
||||
expect(parameters.properties?.controlUrl).toBeDefined();
|
||||
expect(parameters.properties?.targetUrl).toBeDefined();
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user