Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

2.1 KB
Raw Blame
import { describe, it, expect, vi, beforeEach } from "vitest";
import { handleCompareEngines } from "./compare-engines.handler.js";

const executeMock = vi.fn();

const executor = { execute: executeMock };

describe("handleCompareEngines", () => {
  beforeEach(() => {
    executeMock.mockReset();
  });

  it("passes all params through to the compare_engines task", async () => {
    executeMock.mockResolvedValue({
      data: { overall_disagreement: 0.2, both_empty_window_count: 1, json_path: "/x/comparison.json", html_path: "/x/comparison.html" },
    });

    await handleCompareEngines({
      file_path: "/video.mp4",
      engine_a: "whispercpp",
      engine_b: "whisper-py",
      start_seconds: 10,
      duration_seconds: 60,
      window_seconds: 20,
      model_size: "base",
      language: "ka",
      output_dir: "/tmp/cmp",
    }, executor);

    expect(executeMock).toHaveBeenCalledWith("compare_engines", {
      file_path: "/video.mp4",
      engine_a: "whispercpp",
      engine_b: "whisper-py",
      start_seconds: 10,
      duration_seconds: 60,
      window_seconds: 20,
      model_size: "base",
      language: "ka",
      output_dir: "/tmp/cmp",
    });
  });

  it("returns a summary labeled as disagreement, not accuracy", async () => {
    executeMock.mockResolvedValue({
      data: { overall_disagreement: 0.35, both_empty_window_count: 0, json_path: "/x/comparison.json", html_path: "/x/comparison.html" },
    });

    const text = await handleCompareEngines({
      file_path: "/video.mp4",
      engine_a: "whispercpp",
      engine_b: "whisper-py",
    }, executor);

    const parsed = JSON.parse(text);

    expect(parsed.overall_disagreement).toBe(0.35);
    expect(parsed.note).toMatch(/disagreement/i);
    expect(parsed.note).toContain("not accuracy against a transcript");
  });

  it("throws when the backend returns no data", async () => {
    executeMock.mockResolvedValue({ data: undefined });
    await expect(
      handleCompareEngines({ file_path: "/video.mp4", engine_a: "whispercpp", engine_b: "whisper-py" }, executor),
    ).rejects.toThrow(/no data/i);
  });
});