import { describe, expect, it, vi } from 'vitest' type Listener = (...args: unknown[]) => void const state = vi.hoisted(() => ({ appListeners: new Map(), bootstrap: vi.fn(async () => undefined), exit: vi.fn(), preview: vi.fn(async () => undefined), quit: vi.fn(), requestSingleInstanceLock: vi.fn(() => true), setAsDefaultProtocolClient: vi.fn(), setupLifecycle: vi.fn(), })) vi.mock('electron', () => ({ app: { on: vi.fn((event: string, listener: Listener) => state.appListeners.set(event, listener)), whenReady: vi.fn(() => Promise.resolve()), setAsDefaultProtocolClient: state.setAsDefaultProtocolClient, requestSingleInstanceLock: state.requestSingleInstanceLock, disableHardwareAcceleration: vi.fn(), commandLine: { appendSwitch: vi.fn() }, exit: state.exit, quit: state.quit, getPath: vi.fn(() => '.'), }, })) vi.mock('electron-log', () => ({ default: { error: vi.fn() }, })) vi.mock('../../src/main/app-identity', () => ({ applyAppIdentity: vi.fn() })) vi.mock('../../src/main/bootstrap', () => ({ bootstrap: state.bootstrap })) vi.mock('../../src/main/lifecycle', () => ({ setupLifecycle: state.setupLifecycle })) vi.mock('../../src/main/windows/WindowManager', () => ({ showMainWindow: vi.fn(() => null) })) vi.mock('../../src/main/services/LoggerService', () => ({ getLogger: () => ({ info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }), })) vi.mock('../../src/main/update-dialog-preview', () => ({ isUpdateDialogPreviewRequested: () => true, runUpdateDialogPreview: state.preview, })) describe('update dialog preview entrypoint', () => { it('protocol/lock/bootstrap을 건드리지 않고 preview 후 종료한다', async () => { await import('../../src/main/index') await vi.waitFor(() => expect(state.preview).toHaveBeenCalledTimes(1)) expect(state.setAsDefaultProtocolClient).not.toHaveBeenCalled() expect(state.requestSingleInstanceLock).not.toHaveBeenCalled() expect(state.bootstrap).not.toHaveBeenCalled() expect(state.setupLifecycle).not.toHaveBeenCalled() expect(state.exit).not.toHaveBeenCalled() expect(state.quit).toHaveBeenCalledTimes(1) }) })