From 55bc0f8b337aa665f0bfc972d3feba6d96411e68 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 11 Apr 2026 14:35:15 -0700 Subject: [PATCH] Revert "Revert "test: verify auto-update notification flow"" (#479) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Revert "test: verify auto-update notification flow" (#478)" This reverts commit 988fa024560a797d4008b3a64ab6e0f99e2f3eff. * test: fix missing ipc events mock in useIpcEvents.test.ts * Add usage status bar and Codex account switching (#483) * 1.1.14 * feat: add active agent count in top bar (#484) * feat: add active agent count in top bar * fix: pass missing runtime pane title setters to pty connection --------- Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> * Add "No login required" to README features (#486) * Add "No login required" to top of README features Highlight that Orca needs no account or login — users bring their own Claude Code or Codex subscription directly. * Simplify no-login line and add Codex account switching section - Trim "No login required" to just the essentials - Add [New] Hot Swap Codex Accounts section with gif demo * Fix README badge layout — remove blank lines inside HTML blocks (#488) Blank lines inside

tags cause GitHub to render each badge as a separate paragraph instead of inline on one row. * Add Codex account switcher gif (#489) The gif was referenced in README but never committed. * Refresh worktree quick jump UI (#487) * fix: Warp-parity keyboard shortcuts — image paste and line-kill bindings (#491) Co-authored-by: Claude Sonnet 4.6 Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> * Nicer agent list (#492) * test: mock more missing IPC handlers and store actions in useIpcEvents tests --------- Co-authored-by: Jinwoo Hong <73622457+Jinwoo-H@users.noreply.github.com> Co-authored-by: Jinwoo-H Co-authored-by: Yax Patel <74978532+ypatel2022@users.noreply.github.com> Co-authored-by: Colin Chambachan Co-authored-by: Ramzi <79337754+heyramzi@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com> --- src/main/updater.test.ts | 39 ++++++ src/renderer/src/hooks/useIpcEvents.test.ts | 136 +++++++++++++++++++- 2 files changed, 174 insertions(+), 1 deletion(-) diff --git a/src/main/updater.test.ts b/src/main/updater.test.ts index 67c054c3d..c9737da66 100644 --- a/src/main/updater.test.ts +++ b/src/main/updater.test.ts @@ -277,4 +277,43 @@ describe('updater', () => { vi.advanceTimersByTime(60 * 1000) expect(autoUpdaterMock.checkForUpdates).toHaveBeenCalledTimes(2) }) + + it('reschedules the next automatic check 36 hours after finding an available update', async () => { + vi.useFakeTimers() + vi.setSystemTime(new Date('2026-04-03T12:00:00Z')) + + autoUpdaterMock.checkForUpdates.mockImplementation(() => { + autoUpdaterMock.emit('checking-for-update') + queueMicrotask(() => { + autoUpdaterMock.emit('update-available', { version: '1.0.61' }) + }) + return Promise.resolve(undefined) + }) + + const sendMock = vi.fn() + const setLastUpdateCheckAt = vi.fn() + const mainWindow = { webContents: { send: sendMock } } + + const { setupAutoUpdater } = await import('./updater') + + setupAutoUpdater(mainWindow as never, { + getLastUpdateCheckAt: () => null, + setLastUpdateCheckAt + }) + + await vi.runAllTicks() + + expect(autoUpdaterMock.checkForUpdates).toHaveBeenCalledTimes(1) + expect(setLastUpdateCheckAt).toHaveBeenCalledTimes(1) + expect(sendMock).toHaveBeenCalledWith('updater:status', { + state: 'available', + version: '1.0.61' + }) + + vi.advanceTimersByTime(35 * 60 * 60 * 1000 + 59 * 60 * 1000) + expect(autoUpdaterMock.checkForUpdates).toHaveBeenCalledTimes(1) + + vi.advanceTimersByTime(60 * 1000) + expect(autoUpdaterMock.checkForUpdates).toHaveBeenCalledTimes(2) + }) }) diff --git a/src/renderer/src/hooks/useIpcEvents.test.ts b/src/renderer/src/hooks/useIpcEvents.test.ts index cf8dc94d5..0651ae189 100644 --- a/src/renderer/src/hooks/useIpcEvents.test.ts +++ b/src/renderer/src/hooks/useIpcEvents.test.ts @@ -1,4 +1,5 @@ -import { describe, expect, it } from 'vitest' +import type * as ReactModule from 'react' +import { beforeEach, describe, expect, it, vi } from 'vitest' import { resolveZoomTarget } from './useIpcEvents' function makeTarget(args: { hasXtermClass?: boolean; editorClosest?: boolean }): { @@ -55,3 +56,136 @@ describe('resolveZoomTarget', () => { ).toBe('ui') }) }) + +describe('useIpcEvents updater integration', () => { + beforeEach(() => { + vi.resetModules() + vi.unstubAllGlobals() + }) + + it('routes updater status events into store state and update toasts', async () => { + const setUpdateStatus = vi.fn() + const handleStatus = vi.fn() + const updaterStatusListenerRef: { current: ((status: unknown) => void) | null } = { + current: null + } + + vi.doMock('react', async () => { + const actual = await vi.importActual('react') + return { + ...actual, + useEffect: (effect: () => void | (() => void)) => { + effect() + } + } + }) + + vi.doMock('../store', () => ({ + useAppStore: { + getState: () => ({ + setUpdateStatus, + fetchRepos: vi.fn(), + fetchWorktrees: vi.fn(), + setActiveView: vi.fn(), + activeModal: null, + closeModal: vi.fn(), + openModal: vi.fn(), + activeWorktreeId: 'wt-1', + activeView: 'terminal', + setActiveRepo: vi.fn(), + setActiveWorktree: vi.fn(), + revealWorktreeInSidebar: vi.fn(), + setIsFullScreen: vi.fn(), + updateBrowserTabPageState: vi.fn(), + activeTabType: 'terminal', + editorFontZoomLevel: 0, + setEditorFontZoomLevel: vi.fn(), + setRateLimitsFromPush: vi.fn(), + settings: { terminalFontSize: 13 } + }) + } + })) + + vi.doMock('./update-toast-controller', () => ({ + createUpdateToastController: () => ({ + handleStatus + }) + })) + + vi.doMock('@/lib/ui-zoom', () => ({ + applyUIZoom: vi.fn() + })) + vi.doMock('@/lib/worktree-activation', () => ({ + activateAndRevealWorktree: vi.fn(), + ensureWorktreeHasInitialTerminal: vi.fn() + })) + vi.doMock('@/components/sidebar/visible-worktrees', () => ({ + getVisibleWorktreeIds: () => [] + })) + vi.doMock('@/lib/editor-font-zoom', () => ({ + nextEditorFontZoomLevel: vi.fn(() => 0), + computeEditorFontSize: vi.fn(() => 13) + })) + vi.doMock('@/components/settings/SettingsConstants', () => ({ + zoomLevelToPercent: vi.fn(() => 100), + ZOOM_MIN: -3, + ZOOM_MAX: 3 + })) + vi.doMock('@/lib/zoom-events', () => ({ + dispatchZoomLevelChanged: vi.fn() + })) + + vi.stubGlobal('window', { + api: { + repos: { onChanged: () => () => {} }, + worktrees: { onChanged: () => () => {} }, + ui: { + onOpenSettings: () => () => {}, + onToggleWorktreePalette: () => () => {}, + onOpenQuickOpen: () => () => {}, + onJumpToWorktreeIndex: () => () => {}, + onActivateWorktree: () => () => {}, + onNewBrowserTab: () => () => {}, + onNewTerminalTab: () => () => {}, + onCloseActiveTab: () => () => {}, + onSwitchTab: () => () => {}, + onToggleStatusBar: () => () => {}, + onFullscreenChanged: () => () => {}, + onTerminalZoom: () => () => {}, + getZoomLevel: () => 0, + set: vi.fn() + }, + updater: { + getStatus: () => Promise.resolve({ state: 'idle' }), + onStatus: (listener: (status: unknown) => void) => { + updaterStatusListenerRef.current = listener + return () => {} + } + }, + browser: { + onGuestLoadFailed: () => () => {} + }, + rateLimits: { + get: () => Promise.resolve({ limits: {}, lastUpdatedAt: Date.now() }), + onUpdate: () => () => {} + } + } + }) + + const { useIpcEvents } = await import('./useIpcEvents') + + useIpcEvents() + await Promise.resolve() + + expect(setUpdateStatus).toHaveBeenCalledWith({ state: 'idle' }) + + const availableStatus = { state: 'available', version: '1.2.3' } + if (typeof updaterStatusListenerRef.current !== 'function') { + throw new Error('Expected updater status listener to be registered') + } + updaterStatusListenerRef.current(availableStatus) + + expect(setUpdateStatus).toHaveBeenCalledWith(availableStatus) + expect(handleStatus).toHaveBeenCalledWith(availableStatus) + }) +})