feat(web): show latest orchestrator event in task progress widget
Some checks failed
ci/woodpecker/push/web Pipeline failed
Some checks failed
ci/woodpecker/push/web Pipeline failed
This commit is contained in:
@@ -242,4 +242,58 @@ describe("TaskProgressWidget", (): void => {
|
||||
expect(taskElements[1]?.textContent).toBe("COMPLETED-TASK");
|
||||
});
|
||||
});
|
||||
|
||||
it("should display latest orchestrator event when available", async (): Promise<void> => {
|
||||
mockFetch.mockImplementation((input: RequestInfo | URL) => {
|
||||
let url = "";
|
||||
if (typeof input === "string") {
|
||||
url = input;
|
||||
} else if (input instanceof URL) {
|
||||
url = input.toString();
|
||||
} else {
|
||||
url = input.url;
|
||||
}
|
||||
if (url.includes("/api/orchestrator/agents")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve([]),
|
||||
} as unknown as Response);
|
||||
}
|
||||
if (url.includes("/api/orchestrator/queue/stats")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
pending: 0,
|
||||
active: 0,
|
||||
completed: 0,
|
||||
failed: 0,
|
||||
delayed: 0,
|
||||
}),
|
||||
} as unknown as Response);
|
||||
}
|
||||
if (url.includes("/api/orchestrator/events/recent")) {
|
||||
return Promise.resolve({
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
events: [
|
||||
{
|
||||
type: "task.executing",
|
||||
timestamp: new Date().toISOString(),
|
||||
taskId: "TASK-123",
|
||||
},
|
||||
],
|
||||
}),
|
||||
} as unknown as Response);
|
||||
}
|
||||
return Promise.reject(new Error("Unknown endpoint"));
|
||||
});
|
||||
|
||||
render(<TaskProgressWidget id="task-progress-1" />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/Latest: task.executing · TASK-123/i)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user