summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/App.test.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/App.test.tsx')
-rw-r--r--packages/cli/src/ui/App.test.tsx51
1 files changed, 51 insertions, 0 deletions
diff --git a/packages/cli/src/ui/App.test.tsx b/packages/cli/src/ui/App.test.tsx
index 79b9ce86..fc6dbb5a 100644
--- a/packages/cli/src/ui/App.test.tsx
+++ b/packages/cli/src/ui/App.test.tsx
@@ -26,6 +26,7 @@ import { Tips } from './components/Tips.js';
import { checkForUpdates, UpdateObject } from './utils/updateCheck.js';
import { EventEmitter } from 'events';
import { updateEventEmitter } from '../utils/updateEventEmitter.js';
+import * as auth from '../config/auth.js';
// Define a more complete mock server config based on actual Config
interface MockServerConfig {
@@ -232,6 +233,10 @@ vi.mock('./utils/updateCheck.js', () => ({
checkForUpdates: vi.fn(),
}));
+vi.mock('./config/auth.js', () => ({
+ validateAuthMethod: vi.fn(),
+}));
+
const mockedCheckForUpdates = vi.mocked(checkForUpdates);
const { isGitRepository: mockedIsGitRepository } = vi.mocked(
await import('@google/gemini-cli-core'),
@@ -1005,4 +1010,50 @@ describe('App UI', () => {
expect(lastFrame()).toContain('5 errors');
});
});
+
+ describe('auth validation', () => {
+ it('should call validateAuthMethod when useExternalAuth is false', async () => {
+ const validateAuthMethodSpy = vi.spyOn(auth, 'validateAuthMethod');
+ mockSettings = createMockSettings({
+ workspace: {
+ selectedAuthType: 'USE_GEMINI' as AuthType,
+ useExternalAuth: false,
+ theme: 'Default',
+ },
+ });
+
+ const { unmount } = render(
+ <App
+ config={mockConfig as unknown as ServerConfig}
+ settings={mockSettings}
+ version={mockVersion}
+ />,
+ );
+ currentUnmount = unmount;
+
+ expect(validateAuthMethodSpy).toHaveBeenCalledWith('USE_GEMINI');
+ });
+
+ it('should NOT call validateAuthMethod when useExternalAuth is true', async () => {
+ const validateAuthMethodSpy = vi.spyOn(auth, 'validateAuthMethod');
+ mockSettings = createMockSettings({
+ workspace: {
+ selectedAuthType: 'USE_GEMINI' as AuthType,
+ useExternalAuth: true,
+ theme: 'Default',
+ },
+ });
+
+ const { unmount } = render(
+ <App
+ config={mockConfig as unknown as ServerConfig}
+ settings={mockSettings}
+ version={mockVersion}
+ />,
+ );
+ currentUnmount = unmount;
+
+ expect(validateAuthMethodSpy).not.toHaveBeenCalled();
+ });
+ });
});