Commit 32e1cd78 authored by Tomas Vik (OOO back on 2026-08-31)'s avatar Tomas Vik (OOO back on 2026-08-31) 🌴
Browse files

fix: indicate that extension is waiting for OAuth redirect

parent e3f95594
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ module.exports = {
    createStatusBarItem: jest.fn(),
    showInputBox: jest.fn(),
    showQuickPick: jest.fn(),
    withProgress: jest.fn(),
    withProgress: jest.fn().mockImplementation((opt, callback) => callback()),
    createQuickPick: jest.fn(),
  },
  commands: {
+7 −0
Original line number Diff line number Diff line
@@ -91,6 +91,13 @@ describe('GitLabAuthenticationProvider', () => {
      expect(session.accessToken).toEqual('test_token');
      expect(session.scopes).toEqual(['read_user', 'api']);
      expect(accountService.getAllAccounts()).toHaveLength(1);
      expect(vscode.window.withProgress).toHaveBeenCalledWith(
        {
          title: 'Waiting for OAuth redirect from GitLab.com.',
          location: vscode.ProgressLocation.Notification,
        },
        expect.any(Function),
      );
    });
  });

+9 −2
Original line number Diff line number Diff line
@@ -115,7 +115,13 @@ export class GitLabAuthenticationProvider implements vscode.AuthenticationProvid
      this.exchangeCodeForToken(state, scopes),
    );
    await openUrl(url);
    const account = await Promise.race([
    const account = await vscode.window.withProgress(
      {
        title: 'Waiting for OAuth redirect from GitLab.com.',
        location: vscode.ProgressLocation.Notification,
      },
      () =>
        Promise.race([
          receivedRedirectUrl,
          new Promise<OAuthAccount>((_, reject) => {
            setTimeout(
@@ -126,7 +132,8 @@ export class GitLabAuthenticationProvider implements vscode.AuthenticationProvid
        ]).finally(() => {
          delete this.#requestsInProgress[state];
          cancelWaitingForRedirectUrl.fire();
    });
        }),
    );

    return convertAccountToAuthenticationSession(account);
  }