feat: apply remote admin settings (no-op) (#16106)

This commit is contained in:
Shreya Keshive
2026-01-09 17:04:57 -05:00
committed by GitHub
parent e04a5f0cb0
commit d74bf9ef2f
5 changed files with 281 additions and 125 deletions
+9 -85
View File
@@ -230,91 +230,6 @@ describe('gemini.tsx main function', () => {
vi.restoreAllMocks();
});
it('verifies that we dont load the config before relaunchAppInChildProcess', async () => {
const processExitSpy = vi
.spyOn(process, 'exit')
.mockImplementation((code) => {
throw new MockProcessExitError(code);
});
const { relaunchAppInChildProcess } = await import('./utils/relaunch.js');
const { loadCliConfig } = await import('./config/config.js');
const { loadSettings } = await import('./config/settings.js');
const { loadSandboxConfig } = await import('./config/sandboxConfig.js');
vi.mocked(loadSandboxConfig).mockResolvedValue(undefined);
const callOrder: string[] = [];
vi.mocked(relaunchAppInChildProcess).mockImplementation(async () => {
callOrder.push('relaunch');
});
vi.mocked(loadCliConfig).mockImplementation(async () => {
callOrder.push('loadCliConfig');
return {
isInteractive: () => false,
getQuestion: () => '',
getSandbox: () => false,
getDebugMode: () => false,
getListExtensions: () => false,
getListSessions: () => false,
getDeleteSession: () => undefined,
getMcpServers: () => ({}),
getMcpClientManager: vi.fn(),
initialize: vi.fn(),
getIdeMode: () => false,
getExperimentalZedIntegration: () => false,
getScreenReader: () => false,
getGeminiMdFileCount: () => 0,
getProjectRoot: () => '/',
getPolicyEngine: vi.fn(),
getMessageBus: () => ({
subscribe: vi.fn(),
}),
getEnableHooks: () => false,
getHookSystem: () => undefined,
getToolRegistry: vi.fn(),
getContentGeneratorConfig: vi.fn(),
getModel: () => 'gemini-pro',
getEmbeddingModel: () => 'embedding-001',
getApprovalMode: () => 'default',
getCoreTools: () => [],
getTelemetryEnabled: () => false,
getTelemetryLogPromptsEnabled: () => false,
getFileFilteringRespectGitIgnore: () => true,
getOutputFormat: () => 'text',
getExtensions: () => [],
getUsageStatisticsEnabled: () => false,
refreshAuth: vi.fn(),
setTerminalBackground: vi.fn(),
} as unknown as Config;
});
vi.mocked(loadSettings).mockReturnValue({
errors: [],
merged: {
advanced: { autoConfigureMemory: true },
security: { auth: {} },
ui: {},
},
workspace: { settings: {} },
setValue: vi.fn(),
forScope: () => ({ settings: {}, originalSettings: {}, path: '' }),
} as never);
try {
await main();
} catch (e) {
// Mocked process exit throws an error.
if (!(e instanceof MockProcessExitError)) throw e;
}
// It is critical that we call relaunch before loadCliConfig to avoid
// loading config in the outer process when we are going to relaunch.
// By ensuring we don't load the config we also ensure we don't trigger any
// operations that might require loading the config such as such as
// initializing mcp servers.
// For the sandbox case we still have to load a partial cli config.
// we can authorize outside the sandbox.
expect(callOrder).toEqual(['relaunch', 'loadCliConfig']);
processExitSpy.mockRestore();
});
it('should log unhandled promise rejections and open debug console on first error', async () => {
const processExitSpy = vi
.spyOn(process, 'exit')
@@ -519,6 +434,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getOutputFormat: () => 'text',
getExtensions: () => [],
getUsageStatisticsEnabled: () => false,
getRemoteAdminSettings: () => undefined,
setTerminalBackground: vi.fn(),
} as unknown as Config);
vi.mocked(loadSettings).mockReturnValue({
@@ -621,6 +537,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getScreenReader: () => false,
getGeminiMdFileCount: () => 0,
getProjectRoot: () => '/',
getRemoteAdminSettings: () => undefined,
setTerminalBackground: vi.fn(),
} as unknown as Config;
@@ -706,6 +623,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getGeminiMdFileCount: () => 0,
getProjectRoot: () => '/',
refreshAuth: vi.fn(),
getRemoteAdminSettings: () => undefined,
setTerminalBackground: vi.fn(),
} as unknown as Config;
@@ -790,6 +708,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getUsageStatisticsEnabled: () => false,
refreshAuth: vi.fn(),
setTerminalBackground: vi.fn(),
getRemoteAdminSettings: () => undefined,
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any
vi.spyOn(themeManager, 'setActiveTheme').mockReturnValue(false);
@@ -872,6 +791,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getFileFilteringRespectGitIgnore: () => true,
getOutputFormat: () => 'text',
getUsageStatisticsEnabled: () => false,
getRemoteAdminSettings: () => undefined,
setTerminalBackground: vi.fn(),
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -953,6 +873,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getFileFilteringRespectGitIgnore: () => true,
getOutputFormat: () => 'text',
getUsageStatisticsEnabled: () => false,
getRemoteAdminSettings: () => undefined,
setTerminalBackground: vi.fn(),
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -1030,6 +951,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getUsageStatisticsEnabled: () => false,
refreshAuth: vi.fn(),
setTerminalBackground: vi.fn(),
getRemoteAdminSettings: () => undefined,
} as any); // eslint-disable-line @typescript-eslint/no-explicit-any
vi.mock('./utils/readStdin.js', () => ({
@@ -1191,6 +1113,7 @@ describe('gemini.tsx main function exit codes', () => {
getOutputFormat: () => 'text',
getExtensions: () => [],
getUsageStatisticsEnabled: () => false,
getRemoteAdminSettings: () => undefined,
setTerminalBackground: vi.fn(),
} as unknown as Config);
vi.mocked(loadSettings).mockReturnValue({
@@ -1257,6 +1180,7 @@ describe('gemini.tsx main function exit codes', () => {
getExtensions: () => [],
getUsageStatisticsEnabled: () => false,
setTerminalBackground: vi.fn(),
getRemoteAdminSettings: () => undefined,
} as unknown as Config);
vi.mocked(loadSettings).mockReturnValue({
merged: { security: { auth: {} }, ui: {} },