feat(orchestrator): add recent events API and monitor script
This commit is contained in:
@@ -28,6 +28,7 @@ describe("AgentsController", () => {
|
||||
subscribe: ReturnType<typeof vi.fn>;
|
||||
getInitialSnapshot: ReturnType<typeof vi.fn>;
|
||||
createHeartbeat: ReturnType<typeof vi.fn>;
|
||||
getRecentEvents: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -65,6 +66,7 @@ describe("AgentsController", () => {
|
||||
timestamp: new Date().toISOString(),
|
||||
data: { heartbeat: true },
|
||||
}),
|
||||
getRecentEvents: vi.fn().mockReturnValue([]),
|
||||
};
|
||||
|
||||
// Create controller with mocked services
|
||||
@@ -362,4 +364,39 @@ describe("AgentsController", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRecentEvents", () => {
|
||||
it("should return recent events with default limit", () => {
|
||||
eventsService.getRecentEvents.mockReturnValue([
|
||||
{
|
||||
type: "task.completed",
|
||||
timestamp: "2026-02-17T15:00:00.000Z",
|
||||
taskId: "task-123",
|
||||
},
|
||||
]);
|
||||
|
||||
const result = controller.getRecentEvents();
|
||||
|
||||
expect(eventsService.getRecentEvents).toHaveBeenCalledWith(100);
|
||||
expect(result).toEqual({
|
||||
events: [
|
||||
{
|
||||
type: "task.completed",
|
||||
timestamp: "2026-02-17T15:00:00.000Z",
|
||||
taskId: "task-123",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse and pass custom limit", () => {
|
||||
controller.getRecentEvents("25");
|
||||
expect(eventsService.getRecentEvents).toHaveBeenCalledWith(25);
|
||||
});
|
||||
|
||||
it("should fallback to default when limit is invalid", () => {
|
||||
controller.getRecentEvents("invalid");
|
||||
expect(eventsService.getRecentEvents).toHaveBeenCalledWith(100);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user