mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-12 14:22:00 -07:00
Feat/browser privacy consent (#21119)
This commit is contained in:
@@ -44,6 +44,11 @@ vi.mock('../../utils/debugLogger.js', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock browser consent to always grant consent by default
|
||||
vi.mock('../../utils/browserConsent.js', () => ({
|
||||
getBrowserConsentIfNeeded: vi.fn().mockResolvedValue(true),
|
||||
}));
|
||||
|
||||
vi.mock('./automationOverlay.js', () => ({
|
||||
injectAutomationOverlay: vi.fn().mockResolvedValue(undefined),
|
||||
}));
|
||||
@@ -64,6 +69,7 @@ vi.mock('node:fs', async (importOriginal) => {
|
||||
import * as fs from 'node:fs';
|
||||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
||||
import { getBrowserConsentIfNeeded } from '../../utils/browserConsent.js';
|
||||
|
||||
describe('BrowserManager', () => {
|
||||
let mockConfig: Config;
|
||||
@@ -72,6 +78,9 @@ describe('BrowserManager', () => {
|
||||
vi.resetAllMocks();
|
||||
vi.mocked(injectAutomationOverlay).mockClear();
|
||||
|
||||
// Re-establish consent mock after resetAllMocks
|
||||
vi.mocked(getBrowserConsentIfNeeded).mockResolvedValue(true);
|
||||
|
||||
// Setup mock config
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
@@ -527,6 +536,41 @@ describe('BrowserManager', () => {
|
||||
/sessionMode: persistent/,
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass --no-usage-statistics and --no-performance-crux when privacy is disabled', async () => {
|
||||
const privacyDisabledConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
browser: {
|
||||
headless: false,
|
||||
},
|
||||
},
|
||||
usageStatisticsEnabled: false,
|
||||
});
|
||||
|
||||
const manager = new BrowserManager(privacyDisabledConfig);
|
||||
await manager.ensureConnection();
|
||||
|
||||
const args = vi.mocked(StdioClientTransport).mock.calls[0]?.[0]
|
||||
?.args as string[];
|
||||
expect(args).toContain('--no-usage-statistics');
|
||||
expect(args).toContain('--no-performance-crux');
|
||||
});
|
||||
|
||||
it('should NOT pass privacy flags when usage statistics are enabled', async () => {
|
||||
// Default config has usageStatisticsEnabled: true (or undefined)
|
||||
const manager = new BrowserManager(mockConfig);
|
||||
await manager.ensureConnection();
|
||||
|
||||
const args = vi.mocked(StdioClientTransport).mock.calls[0]?.[0]
|
||||
?.args as string[];
|
||||
expect(args).not.toContain('--no-usage-statistics');
|
||||
expect(args).not.toContain('--no-performance-crux');
|
||||
});
|
||||
});
|
||||
|
||||
describe('MCP isolation', () => {
|
||||
|
||||
Reference in New Issue
Block a user