Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion packages/cli/src/ui/AppContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
};
});
import ansiEscapes from 'ansi-escapes';
import { type LoadedSettings } from '../config/settings.js';
import { type LoadedSettings, SettingScope } from '../config/settings.js';
import { createMockSettings } from '../test-utils/settings.js';
import type { InitializationResult } from '../core/initializer.js';
import { useQuotaAndFallback } from './hooks/useQuotaAndFallback.js';
Expand Down Expand Up @@ -3707,4 +3707,65 @@ describe('AppContainer State Management', () => {
unmount();
});
});

describe('IDE Integration Nudge Prompt', () => {
let mockHandleSlashCommand: Mock;

beforeEach(() => {
mockHandleSlashCommand = vi.fn();
mockedUseSlashCommandProcessor.mockReturnValue({
handleSlashCommand: mockHandleSlashCommand,
slashCommands: [],
pendingHistoryItems: [],
commandContext: {},
shellConfirmationRequest: null,
confirmationRequest: null,
});
});

it('should run "/ide enable" when isExtensionPreInstalled is true and selection is "yes"', async () => {
const setValueSpy = vi.spyOn(mockSettings, 'setValue').mockImplementation(() => {});
const { unmount } = await act(async () => renderAppContainer());

expect(capturedUIActions).toBeTruthy();

await act(async () => {
capturedUIActions.handleIdePromptComplete({
userSelection: 'yes',
isExtensionPreInstalled: true,
});
});

expect(mockHandleSlashCommand).toHaveBeenCalledWith('/ide enable');
expect(setValueSpy).toHaveBeenCalledWith(
SettingScope.User,
'ide.hasSeenNudge',
true,
);
unmount();
});

it('should run "/ide install" when isExtensionPreInstalled is false and selection is "yes"', async () => {
const setValueSpy = vi.spyOn(mockSettings, 'setValue').mockImplementation(() => {});
const { unmount } = await act(async () => renderAppContainer());

expect(capturedUIActions).toBeTruthy();

await act(async () => {
capturedUIActions.handleIdePromptComplete({
userSelection: 'yes',
isExtensionPreInstalled: false,
});
});

expect(mockHandleSlashCommand).toHaveBeenCalledWith('/ide install');
expect(setValueSpy).toHaveBeenCalledWith(
SettingScope.User,
'ide.hasSeenNudge',
true,
);
unmount();
});
});
});

4 changes: 3 additions & 1 deletion packages/cli/src/ui/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,9 @@ Logging in with Google... Restarting Gemini CLI to continue.
(result: IdeIntegrationNudgeResult) => {
if (result.userSelection === 'yes') {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
handleSlashCommand('/ide install');
handleSlashCommand(
result.isExtensionPreInstalled ? '/ide enable' : '/ide install',
);
settings.setValue(SettingScope.User, 'ide.hasSeenNudge', true);
} else if (result.userSelection === 'dismiss') {
settings.setValue(SettingScope.User, 'ide.hasSeenNudge', true);
Expand Down
Loading