d3ro-voice/apps/desktop/tests/main/index-update-dialog-preview.test.ts
Yun Chan 7fe49c437e chore: land in-progress workspace changes before 1.16.2
The tree carried uncommitted work from several areas (web push, mobile
screens, admin charts, test-hygiene cleanup, CI and map docs). It is landed
as one commit so the release pipeline can start from a clean tree; the
desktop transcript-correction behaviour shipped in the previous commit and
is unchanged here.
2026-11-05 21:58:44 +09:00

58 lines
2.2 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
type Listener = (...args: unknown[]) => void
const state = vi.hoisted(() => ({
appListeners: new Map<string, Listener>(),
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)
})
})