Merge "Login with Google Workspace" auth option into "Login with Google" (#1574)

Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
Tommaso Sciortino
2025-06-25 15:38:18 -07:00
committed by GitHub
parent 00b24c917e
commit 79c647d486
13 changed files with 31 additions and 95 deletions

View File

@@ -275,35 +275,6 @@ describe('retryWithBackoff', () => {
expect(mockFn).toHaveBeenCalledTimes(4); // 3 initial attempts + 1 after fallback
});
it('should trigger fallback for OAuth enterprise users after persistent 429 errors', async () => {
const fallbackCallback = vi.fn().mockResolvedValue('gemini-2.5-flash');
let fallbackOccurred = false;
const mockFn = vi.fn().mockImplementation(async () => {
if (!fallbackOccurred) {
const error: HttpError = new Error('Rate limit exceeded');
error.status = 429;
throw error;
}
return 'success';
});
const promise = retryWithBackoff(mockFn, {
maxAttempts: 3,
initialDelayMs: 100,
onPersistent429: async (authType?: string) => {
fallbackOccurred = true;
return await fallbackCallback(authType);
},
authType: 'oauth-enterprise',
});
await vi.runAllTimersAsync();
await expect(promise).resolves.toBe('success');
expect(fallbackCallback).toHaveBeenCalledWith('oauth-enterprise');
});
it('should NOT trigger fallback for API key users', async () => {
const fallbackCallback = vi.fn();

View File

@@ -99,8 +99,7 @@ export async function retryWithBackoff<T>(
if (
consecutive429Count >= 2 &&
onPersistent429 &&
(authType === AuthType.LOGIN_WITH_GOOGLE_PERSONAL ||
authType === AuthType.LOGIN_WITH_GOOGLE_ENTERPRISE)
authType === AuthType.LOGIN_WITH_GOOGLE_PERSONAL
) {
try {
const fallbackModel = await onPersistent429(authType);