fix(cli): wait for background auto-update before relaunching (#20904)

This commit is contained in:
Tommaso Sciortino
2026-03-03 09:18:29 -08:00
committed by GitHub
parent f15bcaf499
commit e5207eb67f
4 changed files with 151 additions and 2 deletions

View File

@@ -7,6 +7,11 @@
import { vi } from 'vitest';
import { RELAUNCH_EXIT_CODE, relaunchApp } from './processUtils.js';
import * as cleanup from './cleanup.js';
import * as handleAutoUpdate from './handleAutoUpdate.js';
vi.mock('./handleAutoUpdate.js', () => ({
waitForUpdateCompletion: vi.fn().mockResolvedValue(undefined),
}));
describe('processUtils', () => {
const processExit = vi
@@ -14,8 +19,11 @@ describe('processUtils', () => {
.mockReturnValue(undefined as never);
const runExitCleanup = vi.spyOn(cleanup, 'runExitCleanup');
it('should run cleanup and exit with the relaunch code', async () => {
afterEach(() => vi.clearAllMocks());
it('should wait for updates, run cleanup, and exit with the relaunch code', async () => {
await relaunchApp();
expect(handleAutoUpdate.waitForUpdateCompletion).toHaveBeenCalledTimes(1);
expect(runExitCleanup).toHaveBeenCalledTimes(1);
expect(processExit).toHaveBeenCalledWith(RELAUNCH_EXIT_CODE);
});