feat(FN-2501): merge fusion/fn-2501
This commit is contained in:
@@ -444,13 +444,6 @@ export function AgentsView({ addToast, projectId }: AgentsViewProps) {
|
||||
try {
|
||||
await updateAgentState(agentId, newState, projectId);
|
||||
addToast(`Agent state updated to ${newState}`, "success");
|
||||
if (newState === "active") {
|
||||
try {
|
||||
await startAgentRun(agentId, projectId);
|
||||
} catch (runErr) {
|
||||
addToast(`Agent activated, but failed to start run: ${getErrorMessage(runErr)}`, "error");
|
||||
}
|
||||
}
|
||||
void loadAgents();
|
||||
} catch (err) {
|
||||
addToast(`Failed to update state: ${getErrorMessage(err)}`, "error");
|
||||
|
||||
@@ -1078,9 +1078,9 @@ describe("AgentsView", () => {
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockUpdateAgentState).toHaveBeenCalledWith("agent-001", "active", undefined);
|
||||
expect(mockStartAgentRun).toHaveBeenCalledWith("agent-001", undefined);
|
||||
});
|
||||
|
||||
expect(mockStartAgentRun).not.toHaveBeenCalled();
|
||||
expect(mockAddToast).toHaveBeenCalledWith(
|
||||
expect.stringContaining("active"),
|
||||
"success"
|
||||
@@ -1114,7 +1114,7 @@ describe("AgentsView", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("can resume paused agent", async () => {
|
||||
it("can resume paused agent without manual run trigger", async () => {
|
||||
render(<AgentsView addToast={mockAddToast} />);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -1125,8 +1125,9 @@ describe("AgentsView", () => {
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockUpdateAgentState).toHaveBeenCalledWith("agent-003", "active", undefined);
|
||||
expect(mockStartAgentRun).toHaveBeenCalledWith("agent-003", undefined);
|
||||
});
|
||||
|
||||
expect(mockStartAgentRun).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("handles state change error gracefully", async () => {
|
||||
@@ -1148,27 +1149,6 @@ describe("AgentsView", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("shows error toast when startAgentRun fails but still updates state", async () => {
|
||||
mockStartAgentRun.mockRejectedValue(new Error("Run failed"));
|
||||
|
||||
render(<AgentsView addToast={mockAddToast} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTitle("Activate")).toBeTruthy();
|
||||
});
|
||||
|
||||
fireEvent.click(screen.getByTitle("Activate"));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockUpdateAgentState).toHaveBeenCalledWith("agent-001", "active", undefined);
|
||||
expect(mockStartAgentRun).toHaveBeenCalledWith("agent-001", undefined);
|
||||
expect(mockAddToast).toHaveBeenCalledWith(
|
||||
expect.stringContaining("failed to start run"),
|
||||
"error"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not start run when pausing agent", async () => {
|
||||
render(<AgentsView addToast={mockAddToast} />);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user