Files
cobble/src/bots-queue/compose-computers-note.test.ts
T
tben 7edb5432c2 Make send_reply the only way a reply ends
A reply's prose alone was delivered as its answer, so a bot could say work had started when nothing was queued. Replies and task reports now close with send_reply({status, work?}): bare text is a draft, working must queue work or follow a real run, and queued work is cancelled with an unsent message. The review reads the declared status, and a task report no longer counts its own job as open work.
2026-11-19 10:29:15 +01:00

38 lines
1.7 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import composeComputersNote from "./compose-computers-note";
describe("composeComputersNote", () => {
test("lists each computer by ref, the current one first", () => {
const note = composeComputersNote({
computers: [
{ id: 4, name: "Scraper", kind: "sandbox", description: "Runs the crawlers" },
{ id: 1, name: "Main computer", kind: "main" },
],
});
expect(note).toContain(
"- [computer:4] Scraper (you're on it): Runs the crawlers\n- [computer:1] Main computer (main)",
);
expect(note).toContain("search_computers");
expect(note).toContain("send_reply");
expect(note).toContain("start_task");
});
test("tells the coordinator it can use and assign every computer", () => {
const computers = [{ id: 1, name: "Main computer", kind: "main" as const }];
expect(composeComputersNote({ computers, is_coordinator: true })).toContain("assign_computer");
expect(composeComputersNote({ computers })).not.toContain("assign_computer");
});
test("says so when the bot has no computer", () => {
expect(composeComputersNote({ computers: [] })).toContain("You have no computer");
});
test("doesn't deny browsing when the user's browser reaches the run", () => {
expect(composeComputersNote({ computers: [] })).toContain("open files or browse");
expect(composeComputersNote({ computers: [], has_browser: true })).not.toContain("browse");
expect(composeComputersNote({ computers: [], in_workspace: true, has_browser: true })).not.toContain("browse");
});
});