Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(notifications): check scheduled, Run now and webhook notices end to end
Bugfixer 2548ccb967bc9
diff --git a/server/automation-reports.e2e.test.ts b/server/automation-reports.e2e.test.tsindex 6db01b12b2..970bf5060a 100644--- a/server/automation-reports.e2e.test.ts+++ b/server/automation-reports.e2e.test.ts@@ -61,7 +61,7 @@ async function server(env: NodeJS.ProcessEnv = {}) {const settled = (id: string, status = "completed") => expect.poll(async () => (await run(id))?.status, { timeout: 30_000 }).toBe(status);const reported = (id: string, state: string) => expect.poll(async () => (await run(id))?.report?.state, { timeout: 30_000 }).toBe(state);const savedBot = async () => (await api("GET", "/api/bots")).bots.find((candidate: any) => candidate.id === bot.id);- const notified = () => events!.frames.filter((frame) => frame.kind === "notify").map((frame) => frame.notification as { kind: string; threadId: string; body: string });+ const notified = () => events!.frames.filter((frame) => frame.kind === "notify").map((frame) => frame.notification as { kind: string; threadId: string; body: string; routine?: true });const header = (name: string) => `Routine ${JSON.stringify(name)} — do this now:`;/** Rows about these conversations in the workspace Chief's incidents conversation. */const chiefRows = async (...threadIds: string[]) => (await Promise.all((await api("GET", "/api/bots")).bots@@ -130,12 +130,25 @@ it("reports each run into the main chat as the bot's own line, writes nothing foexpect(saved.tasks.find((task: any) => task.threadId === s.main).unread, "a report that needs nothing from the person leaves the chat out of To review").toBe(false);const done = s.notified().filter((notification) => notification.kind === "done");expect(done).toEqual([expect.objectContaining({ threadId: s.main, body: "Inbox watch: Acme replied: they need the invoice by Friday." })]);+ expect(done[0], "a Run now is not a scheduled report").not.toHaveProperty("routine");for (const key of ["first", "second", "third"]) expect(s.toldOnlyReplyLeaves(key)).toBe(true);const transcript = await s.messages(all[1].threadId);expect(transcript.find((message) => message.role === "user")?.text).toContain(s.header("Inbox watch"));expect(transcript.findLast((message) => message.role === "bot" && message.kind === "text")?.text).toBe("Acme replied: they need the invoice by Friday.");}, 120_000);+it("marks the notice of a run its schedule started as a scheduled report", async () => {+ const s = await server();+ s.script([{ key: "due", match: ["Do the Morning digest check."], reply: "Two new orders overnight." }]);+ const { routine } = await s.api("POST", "/api/routines", { name: "Morning digest", prompt: "Do the Morning digest check.", botId: s.bot.id, schedule: { type: "once", at: Date.now() + 1_000 } }, 201);+ await expect.poll(async () => (await s.runs()).find((candidate) => candidate.routineId === routine.id)?.id, { timeout: 30_000 }).toEqual(expect.any(String));+ const id = (await s.runs()).find((candidate) => candidate.routineId === routine.id).id as string;+ await s.settled(id);+ await s.reported(id, "posted");+ expect(await s.run(id)).toMatchObject({ triggerSource: "schedule" });+ expect(s.notified().filter((notification) => notification.kind === "done")).toEqual([expect.objectContaining({ threadId: s.main, body: "Morning digest: Two new orders overnight.", routine: true })]);+}, 120_000);+it("opens a file a run linked in its report from the chat it reported to", async () => {const s = await server();s.script([@@ -326,6 +339,9 @@ it("reports an outside event's run into a chat of its own, not the main chat", aexpect(await s.lines()).toEqual([]);expect(await s.lines(done.resultsThreadId)).toEqual([expect.objectContaining({ text: "Drafted a follow-up for Ada.", automation: expect.objectContaining({ trigger: "webhook", name: "Sales form leads" }) })]);expect(s.toldOnlyReplyLeaves("lead")).toBe(true);+ const leadNotices = s.notified().filter((notification) => notification.kind === "done" && notification.threadId === done.resultsThreadId);+ expect(leadNotices, "an outside event's run is not a scheduled report").toEqual([expect.objectContaining({ body: "Sales form leads: Drafted a follow-up for Ada." })]);+ expect(leadNotices[0]).not.toHaveProperty("routine");const saved = await s.savedBot();expect(saved.threadId).toBe(s.main);expect(saved.tasks.find((task: any) => task.threadId === done.resultsThreadId)).toMatchObject({ title: "Sales form leads · Results" });