evOo-local/apps/api/src/runs.test.ts
cynarAI 54658ee689
feat: autopilot progress, composer start and morning summary (#146)
The autopilot's start line counts its steps and folds open to the latest
checkpoints, and its result reads as a card. The composer's plus menu
starts an autopilot with the draft as the order and a choice of until
done, tomorrow morning or a time. Today lists the autopilots that run,
wait or ended within a day, and their step runs no longer show one by
one. Autopilot runs send no completion or failure push; only a pause
notifies.


Claude-Session: https://claude.ai/code/session_01UmSCnoCgXqBp2fU3vwz4o1

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-05 04:45:49 +02:00

70 lines
2.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { activityNotificationsEnabled, activityPromptSnippet } from "./runs.js";
describe("run activity copy", () => {
it("presents structured agent messages instead of their internal wake prompt", () => {
expect(
activityPromptSnippet({
trigger: "bot_message",
prompt: "[bot] A message just arrived from another bot with internal routing data",
sourceBlocks: [
{
kind: "bot_message_received",
fromBotId: "maya",
fromBotName: "Maya",
text: "Please check the release workflow.",
intent: "request",
},
],
}),
).toBe("Maya asked: Please check the release workflow.");
});
it("names an autopilot step by the user's order", () => {
expect(
activityPromptSnippet({
trigger: "autopilot",
prompt:
"Autopilot: continue the user's order on your own.\nOrder: Tidy the tickets\nUntil: done",
}),
).toBe("Tidy the tickets");
});
it("names a delegated task by its title instead of its wake prompt", () => {
expect(
activityPromptSnippet({
trigger: "delegation",
prompt: '[task] Researcher finished the task you delegated: "Owl facts".',
sourceBlocks: [
{
kind: "task",
taskId: "task-1",
assigneeBotId: "researcher",
assigneeBotName: "Researcher",
title: "Owl facts",
text: "Collect owl facts.",
status: "done",
},
],
}),
).toBe("Owl facts");
});
it("fails closed when an agent message has no valid structured source", () => {
expect(
activityPromptSnippet({
trigger: "bot_message",
prompt: "[bot] private internal routing envelope",
sourceBlocks: [{ kind: "text", text: "not a peer message" }],
}),
).toBe("Message from another agent");
});
});
describe("run activity notification preference", () => {
it("silences only direct messages", () => {
expect(activityNotificationsEnabled(null, false)).toBe(false);
expect(activityNotificationsEnabled("group-1", false)).toBe(true);
});
});