Open Erenndriel opened 1 year ago
Hi @Erenndriel. Thank you for opening an issue. I have been able to reproduce this and it looks like this has been an issue for some time, as least since cypress 9.x.x
. What I think is the issue is that we only check for the super-domain to match when changing the iframe's source, even when the difference is in between tests.
What I would expect is each individual test that changes origin to reset top, like your example:
describe("test Cypress bug for subdomains", () => {
// should set top
it(`should visit "docs.cypress.io"`, () => cy.visit("https://docs.cypress.io/"));
// should change top
it(`should visit "learn.cypress.io"`, () => cy.visit("https://learn.cypress.io/"));
// should change top
it(`should visit "cypress.io"`, () => cy.visit("https://cypress.io"));
});
but if these navigations were all in one test, I would not expect them to change top:
describe("test Cypress bug for subdomains", () => {
it(`should visit "docs.cypress.io", "learn.cypress.io", and "cypress.io" in a single test`, () => {
// should set top
cy.visit("https://docs.cypress.io/");
// should NOT change top
cy.visit("https://learn.cypress.io/");
// should NOT change top
cy.visit("https://cypress.io");
});
});
This behavior seems like a bug to me. Going to go ahead and route it to the end-to-end team!
@AtofStryker Hi and thnx for the response! Any news in regards to how prioritized or an estimation whether this bug's fix will be released sooner or later? Me and my team need to know 'cause if it's going to take weeks or months, we cannot afford for such fix to come to fruition and have to resort to buying single domain addresses.
Thnx beforehand and appreciate the effort 🙏
Hi @Erenndriel. My guess is that this is not going to be prioritized anytime soon. My guess would be months unless someone wants to pick this up as an OSS contribution. The good news is it might not be super challenging to fix, but it might be hard to divorce the logic between tests of sub domain changes between tests vs. in general.
Does anyone have any suggestions as to a workaround for the above?
the only workaround that I have is using my angular app's functionality to change the route by invoking clicks on buttons that implement routerLink. this changes the URL for me. your mileage may vary.
Current behavior
Note: the URLs given below are just placeholders and should not be tested against. Please find any public domain that has subdomains. You can reproduce this with
https://docs.cypress.io/
aswell!cy.visit("https://a.b.com")
cookies
andlocalStorage
are set.cy.visit("https://c.b.com")
. Notice we're still calling on the same.b.com
domain but sub-domain changed!https://a.b.com
.cookies
orlocalStorage
are set on the page (you can just access the API from DevTools).Desired behavior
cy.visit("https://a.b.com")
cookies
andlocalStorage
are set.cy.visit("https://c.b.com")
.cookies
andlocalStorage
are also set.Test code to reproduce
Cypress Version
12.1.0
Node version
v19.3.0
Operating System
Windows 11
Debug Logs
No response
Other
Because of this bug/misbehavior me and my team are unable to proceed running our tests in the
test
env which has URLs with sub-domains.