From cb66f06883326e0f593521dac6b4dfb048c62cd7 Mon Sep 17 00:00:00 2001 From: mkorwel Date: Thu, 16 Apr 2026 00:24:45 +0000 Subject: [PATCH] test(cli): fix flaky LoginWithGoogleRestartDialog assertions and prune dead types --- .../ui/auth/LoginWithGoogleRestartDialog.test.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/ui/auth/LoginWithGoogleRestartDialog.test.tsx b/packages/cli/src/ui/auth/LoginWithGoogleRestartDialog.test.tsx index 4dd13a3334..5c34ae9668 100644 --- a/packages/cli/src/ui/auth/LoginWithGoogleRestartDialog.test.tsx +++ b/packages/cli/src/ui/auth/LoginWithGoogleRestartDialog.test.tsx @@ -8,9 +8,7 @@ import { render } from '../../test-utils/render.js'; import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest'; import { LoginWithGoogleRestartDialog } from './LoginWithGoogleRestartDialog.js'; import { useKeypress } from '../hooks/useKeypress.js'; -import { runExitCleanup } from '../../utils/cleanup.js'; import { - RELAUNCH_EXIT_CODE, _resetRelaunchStateForTesting, } from '../../utils/processUtils.js'; import { type Config } from '@google/gemini-cli-core'; @@ -20,12 +18,15 @@ vi.mock('../hooks/useKeypress.js', () => ({ useKeypress: vi.fn(), })); -vi.mock('../../utils/cleanup.js', () => ({ - runExitCleanup: vi.fn(), +vi.mock('../../utils/processUtils.js', () => ({ + relaunchApp: vi.fn().mockResolvedValue(undefined), + RELAUNCH_EXIT_CODE: 199, + _resetRelaunchStateForTesting: vi.fn(), })); const mockedUseKeypress = useKeypress as Mock; -const mockedRunExitCleanup = runExitCleanup as Mock; +import { relaunchApp } from '../../utils/processUtils.js'; +const mockedRelaunchApp = relaunchApp as Mock; describe('LoginWithGoogleRestartDialog', () => { const onDismiss = vi.fn(); @@ -100,8 +101,7 @@ describe('LoginWithGoogleRestartDialog', () => { // Advance timers to trigger the setTimeout callback await vi.runAllTimersAsync(); - expect(mockedRunExitCleanup).toHaveBeenCalledTimes(1); - expect(exitSpy).toHaveBeenCalledWith(RELAUNCH_EXIT_CODE); + expect(mockedRelaunchApp).toHaveBeenCalledTimes(1); vi.useRealTimers(); unmount();