Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test: close the fake report endpoint even when server startup fails

AdityaUmalebedf7adbdb47
diff --git a/server/check-work-devs.e2e.test.ts b/server/check-work-devs.e2e.test.ts
index 3c55c8d413..3e3d9db145 100644
--- a/server/check-work-devs.e2e.test.ts
+++ b/server/check-work-devs.e2e.test.ts
@@ -20,34 +20,37 @@ it("never sends a report for an @devs draft quoted in a check before done brief;
});
});
await new Promise<void>((resolve) => endpoint.listen(0, "127.0.0.1", resolve));
- const session = await launchVerificationServer({ ...process.env, OMB_BUG_REPORT_URL: `http://127.0.0.1:${(endpoint.address() as AddressInfo).port}/api/bug-reports` },
- undefined, undefined, undefined, undefined, { scripted: true });
- const cli = (...args: string[]) => runControlOmb(args, { env: { OPENMAUSBOT_URL: session.info.url } }) as Promise<any>;
- const api = (path: string, body?: unknown, method = "POST") => request(path, body === undefined ? {} : { method, body: JSON.stringify(body) }, session.info.url) as Promise<any>;
try {
- const worker = (await cli("new-bot", "--name", "Nib")).bot;
- const checker = (await cli("new-bot", "--name", "Vera")).bot;
- const draft = `The export button stays grey after the upload finishes. ${"It never turns blue again until a reload. ".repeat(12).trim()}\n\nTo tell the team, send this line:\n\n@devs the export button stays grey after an upload`;
- writeFileSync(join(session.info.dataDir, "room-plan.json"), JSON.stringify({
- [worker.id]: { script: [
- { key: "draft", match: ["Write the bug report"], reply: draft },
- { key: "sent", match: ["the export button stays grey"], reply: "Sent." },
- ] },
- [checker.id]: { reply: "pass" },
- }));
- expect((await api(`/api/bots/${worker.id}`, { checkWork: { checker: checker.id } }, "PATCH")).bot.checkWork).toEqual({ checker: checker.id });
+ const session = await launchVerificationServer({ ...process.env, OMB_BUG_REPORT_URL: `http://127.0.0.1:${(endpoint.address() as AddressInfo).port}/api/bug-reports` },
+ undefined, undefined, undefined, undefined, { scripted: true });
+ const cli = (...args: string[]) => runControlOmb(args, { env: { OPENMAUSBOT_URL: session.info.url } }) as Promise<any>;
+ const api = (path: string, body?: unknown, method = "POST") => request(path, body === undefined ? {} : { method, body: JSON.stringify(body) }, session.info.url) as Promise<any>;
+ try {
+ const worker = (await cli("new-bot", "--name", "Nib")).bot;
+ const checker = (await cli("new-bot", "--name", "Vera")).bot;
+ const draft = `The export button stays grey after the upload finishes. ${"It never turns blue again until a reload. ".repeat(12).trim()}\n\nTo tell the team, send this line:\n\n@devs the export button stays grey after an upload`;
+ writeFileSync(join(session.info.dataDir, "room-plan.json"), JSON.stringify({
+ [worker.id]: { script: [
+ { key: "draft", match: ["Write the bug report"], reply: draft },
+ { key: "sent", match: ["the export button stays grey"], reply: "Sent." },
+ ] },
+ [checker.id]: { reply: "pass" },
+ }));
+ expect((await api(`/api/bots/${worker.id}`, { checkWork: { checker: checker.id } }, "PATCH")).bot.checkWork).toEqual({ checker: checker.id });
- await cli("send", "--bot", worker.id, "--task", worker.activeTaskId, "--text", "Write the bug report for the grey export button, I will send it myself.");
- await expect.poll(async () => ((await api(`/api/threads/${worker.activeTaskId}/messages`)).messages as any[])
- .some((message) => message.tool?.name === "Checked by Vera · passed in round 1"), { timeout: 60_000, interval: 250 }).toBe(true);
+ await cli("send", "--bot", worker.id, "--task", worker.activeTaskId, "--text", "Write the bug report for the grey export button, I will send it myself.");
+ await expect.poll(async () => ((await api(`/api/threads/${worker.activeTaskId}/messages`)).messages as any[])
+ .some((message) => message.tool?.name === "Checked by Vera · passed in round 1"), { timeout: 60_000, interval: 250 }).toBe(true);
- await cli("send", "--bot", worker.id, "--task", worker.activeTaskId, "--text", "@devs the export button stays grey after an upload");
- await expect.poll(() => received.length, { timeout: 60_000, interval: 250 }).toBeGreaterThan(0);
- expect(received).toHaveLength(1);
- expect(received[0]!.description).toContain("the export button stays grey after an upload");
- expect(received[0]!.description).not.toContain("check before done");
+ await cli("send", "--bot", worker.id, "--task", worker.activeTaskId, "--text", "@devs the export button stays grey after an upload");
+ await expect.poll(() => received.length, { timeout: 60_000, interval: 250 }).toBeGreaterThan(0);
+ expect(received).toHaveLength(1);
+ expect(received[0]!.description).toContain("the export button stays grey after an upload");
+ expect(received[0]!.description).not.toContain("check before done");
+ } finally {
+ await session.close();
+ }
} finally {
- await session.close();
await new Promise((resolve) => endpoint.close(resolve));
}
}, 150_000);