Spaces:
Paused
Paused
File size: 2,338 Bytes
4e7644b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("../request", () => ({
request: vi.fn(),
}));
import { request } from "../request";
import { harnessApi } from "./harness";
describe("harnessApi", () => {
beforeEach(() => {
vi.mocked(request).mockResolvedValue(undefined);
});
afterEach(() => {
vi.clearAllMocks();
});
it("loads the provider catalog with a startup timeout", async () => {
await harnessApi.list();
expect(request).toHaveBeenCalledWith("/harnesses", {
timeout: 60_000,
});
});
it("starts Codex OAuth without exposing credentials", async () => {
await harnessApi.login("codex", false, {
binary: "/Applications/ChatGPT.app/Contents/Resources/codex",
});
expect(request).toHaveBeenCalledWith("/harnesses/codex/login", {
method: "POST",
body: JSON.stringify({
device_code: false,
settings: {
binary: "/Applications/ChatGPT.app/Contents/Resources/codex",
},
}),
timeout: 60_000,
});
});
it("logs Codex out through the harness API", async () => {
await harnessApi.logout("codex");
expect(request).toHaveBeenCalledWith("/harnesses/codex/logout", {
method: "POST",
body: JSON.stringify({ settings: {} }),
});
});
it("probes Codex with unsaved binary settings", async () => {
await harnessApi.status("codex", { binary: "/custom/codex" });
expect(request).toHaveBeenCalledWith("/harnesses/codex/status", {
method: "POST",
body: JSON.stringify({
settings: { binary: "/custom/codex" },
}),
timeout: 60_000,
});
});
it("loads models through a provider-neutral route", async () => {
await harnessApi.listModels("codex");
expect(request).toHaveBeenCalledWith("/harnesses/codex/models", {
timeout: 60_000,
});
});
it("discovers Provider-owned MCP through a read-only route", async () => {
await harnessApi.listMCP("codex");
expect(request).toHaveBeenCalledWith("/harnesses/codex/mcp", {
timeout: 60_000,
});
});
it("discovers Provider-owned Skills through a read-only route", async () => {
await harnessApi.listSkills("qoder");
expect(request).toHaveBeenCalledWith("/harnesses/qoder/skills", {
timeout: 60_000,
});
});
});
|