Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress says load event isn't fired, but it is fired #30803

Closed
lMartin3 opened this issue Dec 26, 2024 · 2 comments
Closed

Cypress says load event isn't fired, but it is fired #30803

lMartin3 opened this issue Dec 26, 2024 · 2 comments
Labels
stage: needs information Not enough info to reproduce the issue

Comments

@lMartin3
Copy link

lMartin3 commented Dec 26, 2024

Current behavior

I have a setup with two extremely simple web applications. One of them is an oauth + openid identity provider (call it "auth portal").

After writing a very simple test, just going into the application (app.example.com) and clicking the log-in button which makes a couple redirects, cypress says the auth application never fires the "load" event.

This is what a typical log-in flow from the application looks like
image

The auth application loads in 500ms according to chrome dev tools, and I added a console log that fires when the site is loaded, but for some reason cypress doesn't pick it up.

Unfortunately I cannot share much information about the applications themselves, but what I can say is that there isn't any page that takes more than 1000ms to load, that's for sure.

Desired behavior

Cypress should recognize when the page loads

Test code to reproduce

  it('Is able to reach log-in website', () => {
    cy.visit('https://app.[removed]');
    cy.get("#oauth-login").click();
  });

Cypress Version

13.17.0

Node version

18.17.0

Operating System

Windows 11 pro 22631.4602 1000.22700.1055.0

Debug Logs

No response

Other

No response

@jennifer-shehane
Copy link
Member

@lMartin3 Is the application under test hitting the window:load event in Cypress? Or can you put a debugger to see the load event firing from the app under test? https://docs.cypress.io/api/cypress-api/catalog-of-events#App-Events We're looking for that exact event to fire.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Dec 30, 2024
@lMartin3
Copy link
Author

@jennifer-shehane Yep I had added a debugger and the event was firing correctly. However, I found the issue and it was a bit weird.

The test flow was:

  1. Navigate to app
  2. Find the login button and click it
  3. The login button redirects to auth/oauth/access?code=etcetcetc
  4. From there, it redirects to auth/login, which has a login form
  5. After filling in the details, it clicks log in
  6. If the login is successful, it redirects to app/oauth/code?=etcetc
  7. that redirects to the app's landing page

The problem was that the redirection between step 3 and 4 would first lead you to http://auth/login rather than https://auth/login. I was serving this through cloudflare and HTTPS rewrites were on, so technically it was first vising http://auth/login and then it redirected that to https://auth/login.

For some reason, that worked flawlessly for users, but in cypress chrome and other browsers wouldn't even allow making a GET request to http://auth/login since auth/oauth/access was served over HTTPS.

What's weird is that in the preview, cypres would get to step 4 without any issues where it would see the login form, and there it would throw the "load event not fired" issue.

Anyways, thank you for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs information Not enough info to reproduce the issue
Projects
None yet
Development

No branches or pull requests

2 participants