Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(person-first): restore the fetch hook when the fixture fails to launch
erywim257a42ac6e3f
diff --git a/server/person-first.e2e.test.ts b/server/person-first.e2e.test.tsindex bae29e969c..5c393ec096 100644--- a/server/person-first.e2e.test.ts+++ b/server/person-first.e2e.test.ts@@ -8,7 +8,7 @@ import { join } from "node:path";import { DatabaseSync } from "node:sqlite";import { expect, it } from "vitest";-import { launchVerificationServer, runControlOmb } from "../scripts/control-omb.ts";+import { launchVerificationServer, runControlOmb, type VerificationServer } from "../scripts/control-omb.ts";import { removeTempDir } from "./testing/cleanup.ts";import { hostTimeout } from "./testing/host-timeout.ts";@@ -78,12 +78,13 @@ it("never queues an indeterminate steer again through person-first", async () =>const gate = join(folder, "hold.never");const owner = randomBytes(32).toString("base64url");const realFetch = globalThis.fetch;- globalThis.fetch = (input, init = {}) => realFetch(input, { ...init,- headers: { ...Object.fromEntries(new Headers(init.headers)), "x-openmausbot-desktop-owner": owner } });- const fixture = await launchVerificationServer({ ...process.env, OMB_TEST_DESKTOP_OWNER_TOKEN: owner, OMB_PERSON_FIRST_MS: "1500",- FAKE_CODEX_COMMAND: HELD_COMMAND, FAKE_CODEX_COMMAND_GATE: gate, FAKE_CODEX_STEER_HANG: "1" },- undefined, undefined, undefined, undefined, undefined, ["codex"]);+ let launched: VerificationServer | undefined;try {+ globalThis.fetch = (input, init = {}) => realFetch(input, { ...init,+ headers: { ...Object.fromEntries(new Headers(init.headers)), "x-openmausbot-desktop-owner": owner } });+ const fixture = (launched = await launchVerificationServer({ ...process.env, OMB_TEST_DESKTOP_OWNER_TOKEN: owner, OMB_PERSON_FIRST_MS: "1500",+ FAKE_CODEX_COMMAND: HELD_COMMAND, FAKE_CODEX_COMMAND_GATE: gate, FAKE_CODEX_STEER_HANG: "1" },+ undefined, undefined, undefined, undefined, undefined, ["codex"]));const api = async (method: string, path: string, body?: unknown) => {const response = await fetch(fixture.info.url + path, { method, headers: { "content-type": "application/json", origin: fixture.info.url },...(body === undefined ? {} : { body: JSON.stringify(body) }) });@@ -121,7 +122,7 @@ it("never queues an indeterminate steer again through person-first", async () =>expect(held(await transcript()), "the indeterminate steer is not run again").toHaveLength(1);} finally {globalThis.fetch = realFetch;- await fixture.close();+ await launched?.close();await removeTempDir(folder);}}, hostTimeout(90_000));