feat(admin): prompt user to restart the CLI if they change auth to oauth mid-session or don't have auth type selected at start of session (#16426)

This commit is contained in:
Shreya Keshive
2026-01-12 15:39:08 -05:00
committed by GitHub
parent 2306e60be4
commit d65eab01d2
10 changed files with 207 additions and 2 deletions
@@ -72,6 +72,7 @@ describe('AuthDialog', () => {
setAuthState: (state: AuthState) => void;
authError: string | null;
onAuthError: (error: string | null) => void;
setAuthContext: (context: { requiresRestart?: boolean }) => void;
};
const originalEnv = { ...process.env };
@@ -94,6 +95,7 @@ describe('AuthDialog', () => {
setAuthState: vi.fn(),
authError: null,
onAuthError: vi.fn(),
setAuthContext: vi.fn(),
};
});
@@ -217,6 +219,28 @@ describe('AuthDialog', () => {
expect(props.settings.setValue).not.toHaveBeenCalled();
});
it('sets auth context with requiresRestart: true for LOGIN_WITH_GOOGLE', async () => {
mockedValidateAuthMethod.mockReturnValue(null);
renderWithProviders(<AuthDialog {...props} />);
const { onSelect: handleAuthSelect } =
mockedRadioButtonSelect.mock.calls[0][0];
await handleAuthSelect(AuthType.LOGIN_WITH_GOOGLE);
expect(props.setAuthContext).toHaveBeenCalledWith({
requiresRestart: true,
});
});
it('sets auth context with empty object for other auth types', async () => {
mockedValidateAuthMethod.mockReturnValue(null);
renderWithProviders(<AuthDialog {...props} />);
const { onSelect: handleAuthSelect } =
mockedRadioButtonSelect.mock.calls[0][0];
await handleAuthSelect(AuthType.USE_GEMINI);
expect(props.setAuthContext).toHaveBeenCalledWith({});
});
it('skips API key dialog on initial setup if env var is present', async () => {
mockedValidateAuthMethod.mockReturnValue(null);
process.env['GEMINI_API_KEY'] = 'test-key-from-env';