feat(web): add orchestrator events widget with matrix signal visibility
All checks were successful
ci/woodpecker/push/web Pipeline was successful
All checks were successful
ci/woodpecker/push/web Pipeline was successful
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { OrchestratorEventsWidget } from "../OrchestratorEventsWidget";
|
||||
|
||||
describe("OrchestratorEventsWidget", () => {
|
||||
const mockFetch = vi.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
global.fetch = mockFetch as unknown as typeof fetch;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("renders loading state initially", () => {
|
||||
mockFetch.mockImplementation(
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
() => new Promise(() => {})
|
||||
);
|
||||
|
||||
render(<OrchestratorEventsWidget id="orchestrator-events-1" config={{}} />);
|
||||
expect(screen.getByText("Loading orchestrator events...")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders events and matrix signal count", async () => {
|
||||
mockFetch.mockResolvedValue({
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
events: [
|
||||
{
|
||||
type: "task.completed",
|
||||
timestamp: "2026-02-17T16:40:00.000Z",
|
||||
taskId: "TASK-1",
|
||||
data: { channelId: "room-123" },
|
||||
},
|
||||
{
|
||||
type: "agent.running",
|
||||
timestamp: "2026-02-17T16:41:00.000Z",
|
||||
taskId: "TASK-2",
|
||||
agentId: "agent-abc12345",
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
render(<OrchestratorEventsWidget id="orchestrator-events-1" config={{}} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("task.completed")).toBeInTheDocument();
|
||||
expect(screen.getByText("agent.running")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Matrix signals: 1/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("renders error state when API fails", async () => {
|
||||
mockFetch.mockResolvedValue({
|
||||
ok: false,
|
||||
status: 503,
|
||||
});
|
||||
|
||||
render(<OrchestratorEventsWidget id="orchestrator-events-1" config={{}} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Unable to load events: HTTP 503/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -10,6 +10,7 @@ import { widgetRegistry } from "../WidgetRegistry";
|
||||
import { TasksWidget } from "../TasksWidget";
|
||||
import { CalendarWidget } from "../CalendarWidget";
|
||||
import { QuickCaptureWidget } from "../QuickCaptureWidget";
|
||||
import { OrchestratorEventsWidget } from "../OrchestratorEventsWidget";
|
||||
|
||||
describe("WidgetRegistry", (): void => {
|
||||
it("should have a registry of widgets", (): void => {
|
||||
@@ -32,6 +33,11 @@ describe("WidgetRegistry", (): void => {
|
||||
expect(widgetRegistry.QuickCaptureWidget!.component).toBe(QuickCaptureWidget);
|
||||
});
|
||||
|
||||
it("should include OrchestratorEventsWidget in registry", (): void => {
|
||||
expect(widgetRegistry.OrchestratorEventsWidget).toBeDefined();
|
||||
expect(widgetRegistry.OrchestratorEventsWidget!.component).toBe(OrchestratorEventsWidget);
|
||||
});
|
||||
|
||||
it("should have correct metadata for TasksWidget", (): void => {
|
||||
const tasksWidget = widgetRegistry.TasksWidget!;
|
||||
expect(tasksWidget.name).toBe("TasksWidget");
|
||||
|
||||
Reference in New Issue
Block a user