Files
fusion/packages/desktop/src/renderer/__tests__/useDeepLink.test.ts
gsxdsm f3c463cb5e feat(FN-1072): add Electron desktop renderer integration
- Add Electron main-process IPC handlers and preload bridges for API proxying, window controls, update install, and platform lookup
- Introduce a desktop renderer entrypoint with DesktopWrapper and a custom frameless TitleBar component
- Add Electron-aware renderer utilities including API transport selection and hooks for runtime detection, auto-update events, and deep links
- Update dashboard header behavior for Electron mode and expand desktop tests across preload, transport, hooks, and title bar flows
- Document the desktop renderer architecture and update desktop package config/dependencies
2026-04-08 00:16:25 -07:00

60 lines
1.6 KiB
TypeScript

// @vitest-environment jsdom
import { act, cleanup, renderHook } from "@testing-library/react";
import { afterEach, describe, expect, it } from "vitest";
import { parseDeepLink, useDeepLink } from "../hooks/useDeepLink";
describe("parseDeepLink", () => {
it("parses task and project links", () => {
expect(parseDeepLink("fusion://task/FN-100")).toBe("fusion://task/FN-100");
expect(parseDeepLink("fusion://project/main")).toBe("fusion://project/main");
});
it("rejects unsupported links", () => {
expect(parseDeepLink("https://example.com")).toBeNull();
expect(parseDeepLink("fusion://invalid/test")).toBeNull();
expect(parseDeepLink("fusion://task")).toBeNull();
});
});
describe("useDeepLink", () => {
afterEach(() => {
cleanup();
window.electronAPI = undefined;
});
it("captures deep link events from Electron", () => {
let onDeepLink: ((url: string) => void) | undefined;
window.electronAPI = {
onDeepLink: (callback) => {
onDeepLink = callback;
return () => {
onDeepLink = undefined;
};
},
};
const { result } = renderHook(() => useDeepLink());
act(() => {
onDeepLink?.("fusion://task/FN-321");
});
expect(result.current.lastDeepLink).toBe("fusion://task/FN-321");
act(() => {
onDeepLink?.("https://example.com/not-supported");
});
expect(result.current.lastDeepLink).toBe("fusion://task/FN-321");
});
it("defaults to null outside Electron", () => {
window.electronAPI = undefined;
const { result } = renderHook(() => useDeepLink());
expect(result.current.lastDeepLink).toBeNull();
});
});