Skip to content

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

test: wait for recorded computer handoff event

Zhehui Bi2a678908ae84
diff --git a/server/index.test.ts b/server/index.test.ts
index dbc750b6f4..0f6c8642ec 100644
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@ -3632,12 +3632,13 @@ describe("harness HTTP API", () => {
(group: { id: string }) => group.id === roomId,
).messages;
expect(roomMessages.some((message) => (message.tool?.name ?? "").startsWith("Waiting for its turn on this computer"))).toBe(true);
- const roomEvents = ((await api("GET", `/api/threads/${room.threadId}/events`)).body.entries as Array<{ kind: string; data: any }>)
+ const roomEvents = async () => ((await api("GET", `/api/threads/${room.threadId}/events`)).body.entries as Array<{ kind: string; data: any }>)
.filter((entry) => entry.kind === "runtime").map((entry) => entry.data);
- expect(roomEvents.find((event) => event.type === "turn.wait_started")).toMatchObject({
+ await expect.poll(async () => (await roomEvents()).find((event) => event.type === "turn.wait_started"), { timeout: 5_000 }).toMatchObject({
resource: expect.stringMatching(/^computer:/),
});
- expect(roomEvents.find((event) => event.type === "turn.wait_ended")).toMatchObject({
+ // The activity chip can arrive before the runtime event is recorded.
+ await expect.poll(async () => (await roomEvents()).find((event) => event.type === "turn.wait_ended"), { timeout: 5_000 }).toMatchObject({
outcome: "acquired",
});
expect(promptsOnBoat()).toBe(0);