-
Notifications
You must be signed in to change notification settings - Fork 86
Add in-app updater for Linux #3465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
026f17b
Add in-app updater for Linux
ivan-ottinger 69c7479
Generalize distro mention and show actual .deb filename in updater di…
ivan-ottinger 8d733ac
Split updater dialog copy into translator-friendly sentences
ivan-ottinger 10c7bd0
Use ~/Downloads/ in updater command so it works from any terminal cwd
ivan-ottinger 9c2f618
Add unit tests for the Linux updater paths
ivan-ottinger edd942b
Fix typecheck error reading dialog.showMessageBox mock args
ivan-ottinger bdab436
Trim redundant comments from Linux updater response handling
ivan-ottinger 46adc3d
Use process.platform for Linux updates URL to mirror Mac/Win pattern
ivan-ottinger b5346c6
Address Copilot review on Linux updater: guard concurrent polls, vali…
ivan-ottinger 8d4b0c1
Drop defensive timeout-clear in rescheduleLinuxOrFinish
ivan-ottinger 83aecf7
Merge remote-tracking branch 'origin/trunk' into add-linux-in-app-upd…
ivan-ottinger 6d8d7d6
Validate .deb filename before interpolating into displayed shell command
ivan-ottinger f6901e0
Rename Linux skip log: "auto-updates" → "update checks"
ivan-ottinger d42ca03
Add translator comment for version placeholder in Linux updater dialog
ivan-ottinger 25cb673
Drop verbose vitest overload comment from updates test helper
ivan-ottinger be0d292
Merge branch 'trunk' into add-linux-in-app-updater
ivan-ottinger 370fe2a
Merge branch 'trunk' into add-linux-in-app-updater
ivan-ottinger 5f18545
Merge branch 'trunk' into add-linux-in-app-updater
gavande1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { app, dialog, shell, type MessageBoxOptions } from 'electron'; | ||
| import * as Sentry from '@sentry/electron/main'; | ||
| import { vi } from 'vitest'; | ||
| import { manualCheckForUpdates } from 'src/updates'; | ||
|
|
||
| function getLastDialogOptions(): MessageBoxOptions { | ||
| const lastCall = vi.mocked( dialog.showMessageBox ).mock.lastCall as unknown as [ | ||
| unknown, | ||
| MessageBoxOptions, | ||
| ]; | ||
| return lastCall[ 1 ]; | ||
| } | ||
|
|
||
| vi.mock( 'src/main-window', () => ( { | ||
| getMainWindow: vi.fn().mockResolvedValue( {} ), | ||
| } ) ); | ||
|
|
||
| const originalFetch = global.fetch; | ||
| const originalPlatform = process.platform; | ||
| const originalArch = process.arch; | ||
|
|
||
| beforeEach( () => { | ||
| Object.defineProperty( process, 'platform', { value: 'linux', configurable: true } ); | ||
| Object.defineProperty( process, 'arch', { value: 'arm64', configurable: true } ); | ||
| vi.mocked( app.getVersion ).mockReturnValue( '1.8.2' ); | ||
| // shell.openExternal isn't part of the global electron mock in vitest.setup.ts. | ||
| ( shell as unknown as { openExternal: ReturnType< typeof vi.fn > } ).openExternal = vi | ||
| .fn() | ||
| .mockResolvedValue( undefined ); | ||
| } ); | ||
|
|
||
| afterEach( () => { | ||
| global.fetch = originalFetch; | ||
| Object.defineProperty( process, 'platform', { value: originalPlatform, configurable: true } ); | ||
| Object.defineProperty( process, 'arch', { value: originalArch, configurable: true } ); | ||
| } ); | ||
|
|
||
| describe( 'Linux updater', () => { | ||
| it( 'shows the download dialog with the install command and opens the browser on Download', async () => { | ||
| global.fetch = vi.fn().mockResolvedValue( { | ||
| status: 200, | ||
| ok: true, | ||
| json: async () => ( { | ||
| version: '1.9.0', | ||
| downloadUrl: 'https://appscdn.example.com/path/studio_1.9.0_arm64.deb', | ||
| } ), | ||
| } as Response ); | ||
| vi.mocked( dialog.showMessageBox ).mockResolvedValue( { | ||
| response: 0, | ||
| checkboxChecked: false, | ||
| } ); | ||
|
|
||
| await manualCheckForUpdates(); | ||
|
|
||
| await vi.waitFor( () => { | ||
| expect( dialog.showMessageBox ).toHaveBeenCalled(); | ||
| } ); | ||
|
|
||
| const args = getLastDialogOptions(); | ||
| expect( args.message ).toContain( '1.9.0' ); | ||
| expect( args.detail ).toContain( 'sudo apt install ~/Downloads/studio_1.9.0_arm64.deb' ); | ||
|
|
||
| expect( shell.openExternal ).toHaveBeenCalledWith( | ||
| 'https://appscdn.example.com/path/studio_1.9.0_arm64.deb' | ||
| ); | ||
| } ); | ||
|
|
||
| it( 'shows "No updates available" on a manual check when the server returns 204', async () => { | ||
| global.fetch = vi.fn().mockResolvedValue( { | ||
| status: 204, | ||
| ok: true, | ||
| } as Response ); | ||
| vi.mocked( dialog.showMessageBox ).mockResolvedValue( { | ||
| response: 0, | ||
| checkboxChecked: false, | ||
| } ); | ||
|
|
||
| await manualCheckForUpdates(); | ||
|
|
||
| await vi.waitFor( () => { | ||
| expect( dialog.showMessageBox ).toHaveBeenCalled(); | ||
| } ); | ||
|
|
||
| const args = getLastDialogOptions(); | ||
| expect( args.message ).toBe( 'No updates available' ); | ||
| expect( shell.openExternal ).not.toHaveBeenCalled(); | ||
| } ); | ||
|
|
||
| it( 'reports to Sentry and shows no dialog when the server returns an error status', async () => { | ||
| global.fetch = vi.fn().mockResolvedValue( { | ||
| status: 500, | ||
| ok: false, | ||
| } as Response ); | ||
|
|
||
| await manualCheckForUpdates(); | ||
|
|
||
| await vi.waitFor( () => { | ||
| expect( Sentry.captureException ).toHaveBeenCalled(); | ||
| } ); | ||
|
|
||
| expect( dialog.showMessageBox ).not.toHaveBeenCalled(); | ||
| expect( shell.openExternal ).not.toHaveBeenCalled(); | ||
| } ); | ||
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.