feat(FN-2092): merge fusion/fn-2092

This commit is contained in:
gsxdsm
2026-04-18 22:07:20 -07:00
parent b0028c077f
commit 4e3e2ca7fe
6 changed files with 115 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ vi.mock("../../api", async (importOriginal) => {
fetchGitRemotes: vi.fn(() => Promise.resolve([])),
fetchAgents: vi.fn(() => Promise.resolve([])),
fetchTaskDetail: vi.fn((id: string) => Promise.resolve({ id, title: `Task ${id}` })),
fetchUnreadCount: vi.fn(() => Promise.resolve({ unreadCount: 0 })),
fetchScripts: vi.fn(() => Promise.resolve({ build: "npm run build", test: "pnpm test" })),
runScript: vi.fn(() => Promise.resolve({ sessionId: "sess-script-1", command: "echo hello" })),
killPtyTerminalSession: vi.fn(() => Promise.resolve({ killed: true })),
@@ -220,7 +221,7 @@ vi.mock("../../hooks/useNodes", () => ({
}));
import { App } from "../../App";
import { fetchAuthStatus, fetchSettings, fetchGlobalSettings, fetchTaskDetail, updateSettings, runScript, fetchScripts, fetchModels } from "../../api";
import { fetchAuthStatus, fetchSettings, fetchGlobalSettings, fetchTaskDetail, fetchUnreadCount, updateSettings, runScript, fetchScripts, fetchModels } from "../../api";
import * as apiNodeModule from "../../hooks/useRemoteNodeData";
beforeEach(() => {
@@ -276,6 +277,30 @@ beforeEach(() => {
mockGetStepData.mockReturnValue(null);
});
describe("App mailbox unread count", () => {
it("logs a warning when unread count fetch fails and keeps the zero-count fallback", async () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
const unreadFetchError = new Error("Mailbox unavailable");
(fetchUnreadCount as ReturnType<typeof vi.fn>).mockRejectedValueOnce(unreadFetchError);
render(<App />);
await waitFor(() => {
expect(fetchUnreadCount).toHaveBeenCalledWith("proj_123");
});
await waitFor(() => {
expect(warnSpy).toHaveBeenCalledWith(
"[App] Failed to fetch mailbox unread count:",
unreadFetchError,
);
});
expect(screen.getByRole("status", { name: "Loading Fusion dashboard" })).toBeInTheDocument();
warnSpy.mockRestore();
});
});
describe("App deep link handling", () => {
const originalLocation = window.location;
const originalReplaceState = window.history.replaceState;