Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.5 KB
Raw Blame
/**
 * Regression test for #3390: getMitmStatus() in the Docker build stub must
 * return a safe "not available" status object instead of throwing STUB_ERROR.
 * When the stub throws, the AgentBridge state route propagates the error to
 * the UI, showing a red error banner instead of a graceful "stopped" state.
 */
import { describe, it } from "node:test";
import assert from "node:assert/strict";

describe("mitm manager.stub — Docker graceful degradation (#3390)", () => {
  it("getMitmStatus resolves without throwing", async () => {
    const { getMitmStatus } = await import("../../src/mitm/manager.stub.ts");
    await assert.doesNotReject(getMitmStatus);
  });

  it("getMitmStatus returns running=false", async () => {
    const { getMitmStatus } = await import("../../src/mitm/manager.stub.ts");
    const status = await getMitmStatus();
    assert.strictEqual(status.running, false);
  });

  it("getMitmStatus returns pid=null", async () => {
    const { getMitmStatus } = await import("../../src/mitm/manager.stub.ts");
    const status = await getMitmStatus();
    assert.strictEqual(status.pid, null);
  });

  it("startMitm still throws (MITM unavailable in container)", async () => {
    const { startMitm } = await import("../../src/mitm/manager.stub.ts");
    await assert.rejects(async () => startMitm("key", "pwd"), /stub/i);
  });

  it("getAllAgentsStatus returns empty array", async () => {
    const { getAllAgentsStatus } = await import("../../src/mitm/manager.stub.ts");
    assert.deepStrictEqual(getAllAgentsStatus(), []);
  });
});