Merges five features: **Launch mode persistence** (FN-3405) — desktop now remembers and restores the user's preferred window mode across restarts via an IPC bridge; **Mailbox detail pane** (FN-3719/3720) — clicking messages in the Mail tab and Mailbox opens the detail pane and reply panel; **Remote Fusion-Task-Id: FN-3405
116 lines
3.1 KiB
TypeScript
116 lines
3.1 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => {
|
|
const app = {
|
|
whenReady: vi.fn(() => Promise.resolve()),
|
|
on: vi.fn(),
|
|
quit: vi.fn(),
|
|
};
|
|
|
|
const browserWindow = {
|
|
loadURL: vi.fn(),
|
|
loadFile: vi.fn(),
|
|
on: vi.fn(),
|
|
hide: vi.fn(),
|
|
show: vi.fn(),
|
|
maximize: vi.fn(),
|
|
};
|
|
|
|
return {
|
|
app,
|
|
BrowserWindow: vi.fn(() => browserWindow),
|
|
Tray: vi.fn(() => ({
|
|
destroy: vi.fn(),
|
|
setImage: vi.fn(),
|
|
setContextMenu: vi.fn(),
|
|
setToolTip: vi.fn(),
|
|
on: vi.fn(),
|
|
})),
|
|
nativeImage: {
|
|
createEmpty: vi.fn(() => ({ id: "empty-image" })),
|
|
},
|
|
browserWindow,
|
|
buildAppMenu: vi.fn(),
|
|
setupTray: vi.fn(),
|
|
registerIpcHandlers: vi.fn(),
|
|
registerDeepLinkProtocol: vi.fn(),
|
|
setupDeepLinkHandler: vi.fn(),
|
|
loadWindowState: vi.fn(async () => null),
|
|
loadDesktopLaunchMode: vi.fn(async () => "choose"),
|
|
saveDesktopLaunchMode: vi.fn(async () => undefined),
|
|
saveWindowState: vi.fn(),
|
|
setupAutoUpdater: vi.fn(),
|
|
};
|
|
});
|
|
|
|
vi.mock("electron", () => ({
|
|
app: mocks.app,
|
|
BrowserWindow: mocks.BrowserWindow,
|
|
Tray: mocks.Tray,
|
|
nativeImage: mocks.nativeImage,
|
|
}));
|
|
|
|
vi.mock("../menu.js", () => ({
|
|
buildAppMenu: mocks.buildAppMenu,
|
|
}));
|
|
|
|
vi.mock("../tray.js", () => ({
|
|
setupTray: mocks.setupTray,
|
|
}));
|
|
|
|
vi.mock("../ipc.js", () => ({
|
|
registerIpcHandlers: mocks.registerIpcHandlers,
|
|
}));
|
|
|
|
vi.mock("../deep-link.js", () => ({
|
|
registerDeepLinkProtocol: mocks.registerDeepLinkProtocol,
|
|
setupDeepLinkHandler: mocks.setupDeepLinkHandler,
|
|
}));
|
|
|
|
vi.mock("../native.js", () => ({
|
|
DEFAULT_WINDOW_STATE: {
|
|
width: 1280,
|
|
height: 900,
|
|
isMaximized: false,
|
|
},
|
|
loadWindowState: mocks.loadWindowState,
|
|
loadDesktopLaunchMode: mocks.loadDesktopLaunchMode,
|
|
saveDesktopLaunchMode: mocks.saveDesktopLaunchMode,
|
|
saveWindowState: mocks.saveWindowState,
|
|
setupAutoUpdater: mocks.setupAutoUpdater,
|
|
}));
|
|
|
|
// Mock renderer module
|
|
vi.mock("../renderer.js", () => ({
|
|
isDevelopmentMode: vi.fn(() => false),
|
|
getRendererUrl: vi.fn(() => "file:///path/to/dist/client/index.html"),
|
|
getRendererFilePath: vi.fn(() => "/path/to/dist/client/index.html"),
|
|
isUrlRenderer: vi.fn(() => false),
|
|
IS_DEVELOPMENT: false,
|
|
DASHBOARD_URL: vi.fn(() => "file:///path/to/dist/client/index.html"),
|
|
}));
|
|
|
|
describe("main module integration", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
vi.resetModules();
|
|
});
|
|
|
|
it("imports main module exports with a mocked electron runtime", async () => {
|
|
const mainModule = await import("../main.ts");
|
|
|
|
expect(mainModule.run).toBeTypeOf("function");
|
|
expect(mainModule.initializeApp).toBeTypeOf("function");
|
|
expect(mainModule.createMainWindow).toBeTypeOf("function");
|
|
});
|
|
|
|
it("initializes app lifecycle wiring without throwing", async () => {
|
|
const { initializeApp } = await import("../main.ts");
|
|
|
|
await expect(initializeApp()).resolves.toBeUndefined();
|
|
expect(mocks.BrowserWindow).toHaveBeenCalledTimes(1);
|
|
expect(mocks.registerIpcHandlers).toHaveBeenCalledTimes(1);
|
|
expect(mocks.setupTray).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|