Desktop: wire release toast Update to updater (#7549)

Desktop builds should not send users to git-update docs from the release
notification toast; route the toast “Update” action into the Desktop
updater flow.

On Electron, the release toast “Update” button executes
`Comfy-Desktop.CheckForUpdates`; failures surface via
`useErrorHandling`.

Fixes #7543

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7549-Desktop-wire-release-toast-Update-to-updater-2cb6d73d3650815aadbccc15c724815d)
by [Unito](https://www.unito.io)
This commit is contained in:
Benjamin Lu
2025-12-22 03:30:08 -08:00
committed by GitHub
parent d253f67919
commit 216c8694c7
2 changed files with 87 additions and 1 deletions

View File

@@ -5,6 +5,14 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { ReleaseNote } from '../common/releaseService'
import ReleaseNotificationToast from './ReleaseNotificationToast.vue'
const { commandExecuteMock } = vi.hoisted(() => ({
commandExecuteMock: vi.fn()
}))
const { toastErrorHandlerMock } = vi.hoisted(() => ({
toastErrorHandlerMock: vi.fn()
}))
// Mock dependencies
vi.mock('vue-i18n', () => ({
useI18n: vi.fn(() => ({
@@ -36,6 +44,18 @@ vi.mock('@/utils/markdownRendererUtil', () => ({
renderMarkdownToHtml: vi.fn((content: string) => `<div>${content}</div>`)
}))
vi.mock('@/composables/useErrorHandling', () => ({
useErrorHandling: vi.fn(() => ({
toastErrorHandler: toastErrorHandlerMock
}))
}))
vi.mock('@/stores/commandStore', () => ({
useCommandStore: vi.fn(() => ({
execute: commandExecuteMock
}))
}))
// Mock release store
const mockReleaseStore = {
recentRelease: null as ReleaseNote | null,
@@ -159,6 +179,58 @@ describe('ReleaseNotificationToast', () => {
)
})
it('executes desktop updater flow when running in Electron', async () => {
mockReleaseStore.recentRelease = {
version: '1.2.3',
content: '# Test Release'
} as ReleaseNote
commandExecuteMock.mockResolvedValueOnce(undefined)
const mockWindowOpen = vi.fn()
Object.defineProperty(window, 'open', {
value: mockWindowOpen,
writable: true
})
;(window as any).electronAPI = {}
wrapper = mountComponent()
await wrapper.vm.handleUpdate()
expect(commandExecuteMock).toHaveBeenCalledWith(
'Comfy-Desktop.CheckForUpdates'
)
expect(mockWindowOpen).not.toHaveBeenCalled()
expect(toastErrorHandlerMock).not.toHaveBeenCalled()
delete (window as any).electronAPI
})
it('shows an error toast if the desktop updater flow fails in Electron', async () => {
mockReleaseStore.recentRelease = {
version: '1.2.3',
content: '# Test Release'
} as ReleaseNote
const error = new Error('Command Comfy-Desktop.CheckForUpdates not found')
commandExecuteMock.mockRejectedValueOnce(error)
const mockWindowOpen = vi.fn()
Object.defineProperty(window, 'open', {
value: mockWindowOpen,
writable: true
})
;(window as any).electronAPI = {}
wrapper = mountComponent()
await wrapper.vm.handleUpdate()
expect(toastErrorHandlerMock).toHaveBeenCalledWith(error)
expect(mockWindowOpen).not.toHaveBeenCalled()
delete (window as any).electronAPI
})
it('calls handleShowChangelog when learn more link is clicked', async () => {
mockReleaseStore.recentRelease = {
version: '1.2.3',