Skip to content

fix(LoginHelper): increase GitHub login timeout and handle GitHub popup re-authorization#105

Merged
jrichter1 merged 14 commits into
redhat-developer:mainfrom
dom-aug:feat/increase-github-login-timeout
May 18, 2026
Merged

fix(LoginHelper): increase GitHub login timeout and handle GitHub popup re-authorization#105
jrichter1 merged 14 commits into
redhat-developer:mainfrom
dom-aug:feat/increase-github-login-timeout

Conversation

@dom-aug
Copy link
Copy Markdown
Contributor

@dom-aug dom-aug commented May 14, 2026

This pull request improves the reliability and robustness of the GitHub login automation in the Playwright test helper by increasing timeouts and refactoring the GitHub reauthorization flow. The main enhancements include handling both automatic logins and popup-based reauthorization, increasing timeouts to accommodate slower responses, and extracting popup handling logic for clarity and reuse.

Login flow robustness and reauthorization handling:

  • Refactored the GitHub login logic in LoginHelper.loginAsGithubUser to wait for either the sidebar (auto-login) or a popup (reauthorization required) after clicking "Sign In," and to handle the popup if it appears. This improves resilience against session staleness and unexpected authentication states.
  • Extracted popup reauthorization logic into a dedicated handleGithubPopupReauth method, improving code clarity and reusability.

Timeout adjustments for reliability:

  • Increased the test timeout for the 2FA step from 130 seconds to 260 seconds to accommodate slower authentication flows.
  • Increased the wait after entering the 2FA code from 3 seconds to 30 seconds to better handle slow network or UI responses.

Assisted-By: Claude Code

dom-aug and others added 9 commits May 13, 2026 12:43
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
…method

Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
… changes

Signed-off-by: Dominik Augustín <daugusti@redhat.com>
@subhashkhileri subhashkhileri requested a review from jrichter1 May 15, 2026 08:23
Comment thread src/playwright/helpers/common.ts Outdated
}

await this.page.waitForTimeout(3_000);
await this.page.waitForTimeout(30_000);
Copy link
Copy Markdown
Member

@jrichter1 jrichter1 May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly are we waiting for here? 30 seconds unconditional wait seems excessive

Copy link
Copy Markdown
Member

@jrichter1 jrichter1 May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is just to wait for the github login to finish, make it a conditional wait for some element on the github home page, like the heading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have increased this timeout to wait for the GitHub login to finish as the login timed-out on GitHub homepage. Though, I cannot find the Playwright Test Report from my PR that timed-out here; maybe it was during local tests against RHDH in a cluster.
The time it took the tests to return to RHDH from GitHub was quite random, which I assumed, this would cover. Is my understanding correct?
Should the suggested conditional wait be targeting GitHub homepage content or rather RHDH homepage/login screen?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the suggested conditional wait be targeting GitHub homepage content or rather RHDH homepage/login screen?

RHDH login is hanled outside this function, go for the github page

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it to wait for Home heading

dom-aug added 4 commits May 18, 2026 13:58
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
Comment thread src/playwright/helpers/common.ts Outdated
}

await this.page.waitForTimeout(3_000);
await this.page.waitForSelector('h2:has-text("Home")', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using waitForSelector is discouraged by playwright

I'd suggest using a user-facing locator like page.getByRole("heading", { name: "text" })
and waitFor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that one. I have fixed that.

In fact, the waitForSelector warning does not appear for me in this rhdh-e2e-test-utils repo, but in rhdh-plugin-export-overlays it does. What can cause the different behavior?

Signed-off-by: Dominik Augustín <daugusti@redhat.com>
@jrichter1 jrichter1 merged commit 4d3cb57 into redhat-developer:main May 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants