Spaces:
Paused
Paused
Download console/src/api/modules/harness.test.ts from mysticaldragon/HF: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/api/modules/harness.test.ts
- Command line
-
hf download hf://spaces/mysticaldragon/HF/console/src/api/modules/harness.test.ts
-
curl -L -o harness.test.ts https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/api/modules/harness.test.ts
2.34 kB
| 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, | |
| }); | |
| }); | |
| }); | |