Open blackgrouse opened 5 days ago
Hi Team,
I came across this issue related to Cypress hanging during Microsoft AAD login in the CI/CD environment (Azure DevOps on Ubuntu 22.04), and I’d like to contribute to the resolution.
I have some suggestions to troubleshoot and resolve the problem:
pageLoadTimeout
to ensure enough time for the redirect to complete.cy.intercept()
to manage network requests during login and handle them more reliably.Before I start working on this, could you guide me on how to contribute effectively to this project? Are there any specific coding guidelines or contribution practices I should be aware of?
I'm happy to share any further details or logs that might be useful.
Looking forward to your response!
Best regards,
Deepan Mondal
@DeepanMondal
Before I start working on this, could you guide me on how to contribute effectively to this project? Are there any specific coding guidelines or contribution practices I should be aware of?
You should read the CONTRIBUTING document.
@blackgrouse Does this code work in non-Chrome browsers? Like Electron or Firefox?
It reminds me of this issue, which we have a workaround for if that is the case.
@jennifer-shehane Thanks for getting back to me.
Yes, I'm able to reproduce in Electron.
Current behavior
Cypress can hang when a pageLoadTimeout event is received when redirecting back to our app after logging in using Microsoft AAD which is causing issues in our CI/CD environment (Azure DevOps (ADO) ubuntu-22.04).
Our app uses MS AAD to authenticate users and we are automating this using v13.8.1
cy.session()
andcy.origin()
commands with code based on this blog. I have had to tweak the code slightly as our login page is hosted by Microsoft.Here is my version of the login code via the custom command cy.loginWithMicrosoftAccountAndSelectOrg():
```js declare global { namespace Cypress { interface Chainable { loginWithMicrosoftAccountAndSelectOrg(options: { username: string; password: string; clickAadTile?: boolean; clickDontRemainSignedIn?: boolean; orgButtonText?: string; postLoginSelector?: string; sessionName?: string; visit?: { url: string; failOnStatusCode?: boolean }; }): ChainableThe UI flow is:
Most of the time this works fine, but sometimes, after step 3, Cypress hangs and doesn't redirect to our app. On debugging, we are not receiving a
load
event so that Cypress fires apageLoadTimeout
event, which should cause the test to fail. Unfortunately it does not, Cypress hangs at this point and continues running infinitely until stopped - by the user locally, or by ADO after a predefined amount of time. In the latter case, this fails the build, which obviously impacts our delivery efficiency as we have to rerun any builds which have failed in this way.The last line executed was:
and then there is no more activity in the test runner.
I have been able to reproduce this on my Mac 14.6.1 and the latest version of Cypress. Here is a screenshot of the test runner when failing locally:
Desired behavior
The desired behaviour is that Cypress should not hang but should allow the test to fail as expected.
Test code to reproduce
I have not had time to provide a failing test, but provide example code
Cypress Version
13.8.1
Node version
20.16.0
Operating System
macOS 14.6.1 and ubuntu 20.04
Debug Logs
Other
No response