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

Allow user to prevent the first cy.visit call from setting top. #22889

Open
mjhenkes opened this issue Jul 21, 2022 · 0 comments
Open

Allow user to prevent the first cy.visit call from setting top. #22889

mjhenkes opened this issue Jul 21, 2022 · 0 comments
Labels
E2E Issue related to end-to-end testing topic: cy.origin Problems or enhancements related to cy.origin command Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: enhancement Requested enhancement of existing feature

Comments

@mjhenkes
Copy link
Member

mjhenkes commented Jul 21, 2022

What would you like?

Allow user to prevent the first cy.visit call from setting top.

Why is this needed?

Given Site A (www.siteA.com) that server side redirects (www.idp.com). The natural way to log in with cy.origin would look like this. This is expected to be a fairly common use case for cy.origin, along with clicking a button to log in.

it('site A login', () => {
    
    cy.visit('www.siteA.com')

    cy.origin('www.idp.com', () => {
        cy.signIn()
    })
    
    cy.get('selector')
})

However this will not work. The initial visit will set top to www.idp.com and any subsequent commands that attempted to run on www.siteA.com would fail and need to be place in a cy.origin block.

The current pattern to achieve this is non obvious, the cy.visit that redirects must be placed inside the cy.origin block.

it('site A login', () => {
   
    cy.origin('www.idp.com', () => {
        cy.visit('www.siteA.com')
        cy.signIn()
    })
    
    cy.get('selector')
})

With #21485 we are enabling cy.visit to visit cross origin pages. This will allow client side redirects to use our preferred syntax, however without being able to prevent cy.visit from reseting top the preferred syntax will not be available for server side redirects.

Other

This issue has affected several users as can be seen in the cy.origin discussion, #21186 (reply in thread), #21186 (comment)

We have a couple of options to consider if we want to prioritize this:

  1. Add config to visit to prevent reseting top. (Passive)
  2. Reset top to base url for each test, only allow overriding by overriding the baseurl config per test and prevent all visit commands from reseting top (most definitely non passive)
@mjhenkes mjhenkes added topic: cy.origin Problems or enhancements related to cy.origin command type: enhancement Requested enhancement of existing feature labels Jul 21, 2022
@mschile mschile added triage and removed triage labels Aug 18, 2022
@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing topic: cy.origin Problems or enhancements related to cy.origin command Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

3 participants