feat(FN-2092): merge fusion/fn-2092
This commit is contained in:
@@ -81,6 +81,24 @@ describe("useBackgroundSessions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("logs a warning when fetching background sessions fails", async () => {
|
||||
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const networkError = new Error("Network error");
|
||||
mockFetchAiSessions.mockRejectedValueOnce(networkError);
|
||||
|
||||
const { result } = renderHook(() => useBackgroundSessions());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(warnSpy).toHaveBeenCalledWith(
|
||||
"[useBackgroundSessions] Failed to fetch AI sessions:",
|
||||
networkError,
|
||||
);
|
||||
});
|
||||
|
||||
expect(result.current.sessions).toEqual([]);
|
||||
warnSpy.mockRestore();
|
||||
});
|
||||
|
||||
it("applies SSE-driven session updates reactively", async () => {
|
||||
const { result } = renderHook(() => useBackgroundSessions());
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ export function useBackgroundSessions(projectId?: string): UseBackgroundSessions
|
||||
sessionTimestampsRef.current = nextTimestampMap;
|
||||
setSessions(fetched);
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch((err) => {
|
||||
console.warn("[useBackgroundSessions] Failed to fetch AI sessions:", err);
|
||||
});
|
||||
}, [projectId]);
|
||||
|
||||
// Initial load: request state from sibling tabs first, then fetch authoritative API state.
|
||||
|
||||
Reference in New Issue
Block a user