Last active
January 24, 2022 19:06
-
-
Save mjhenkes/53d4505dc74609da2f00794301c73751 to your computer and use it in GitHub Desktop.
Cypress and cy partition discussion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('window:before:load event', () => { | |
| Cypress.Screenshot.defaults({ | |
| stuff: true | |
| })// this only applies to the primary domain | |
| cy.visit('/fixtures/multi-domain.html') | |
| cy.intercept('foobar.com/api') | |
| cy.intercept('/api', () => { | |
| return "my fake response" | |
| }) // does this apply to all domains? YES | |
| cy.get('a[data-cy="multi-domain-secondary-link"]').click() | |
| cy.switchToDomain('foobar.com', () => { | |
| Cypress.Screenshot.defaults({ | |
| stuff: false | |
| })// this only applies to the sub domain | |
| cy.intercept('/api') // Does this work ever? (Yes but only after initial load) Does this apply to primary? (Yes) | |
| // Ideally does not override teh top definition | |
| // Should we outlaw this? | |
| cy.on('window:before:load', (win: {testSecondaryWindowBeforeLoad: boolean}) => { | |
| win.testSecondaryWindowBeforeLoad = true | |
| }) // only applies to the sub domain. | |
| // do stuff | |
| }) | |
| }) | |
| it('is a sales for app and is not temporary' , () => { // BAD B is 99% | |
| cy.intercept('myApp.com') | |
| cy.visit('identityprovider.com') // go to identity provider first to log in | |
| cy.get('a[data-cy="multi-domain-secondary-link"]').click() // click the app you want to go to | |
| cy.switchToDomain('myApp.com', () => { // then we do all the test stuff here. | |
| // do all the stuff here | |
| }) | |
| }) | |
| it('is a sales for app and is not temporary' , () => { //ALT A, visit app you want to test first and get redirected to login | |
| cy.visit('myApp.com') //go to app you want to test | |
| cy.switchToDomain('identity provider', () => { // login here | |
| login | |
| cy.get('a[data-cy="multi-domain-secondary-link"]').click() // click the app you want to go to | |
| // do all the stuff here | |
| }) | |
| // do test stuff here | |
| }) | |
| it('is a sales for app and is not temporary' , () => { //ALT B Create domain and visit IDP before doing the test | |
| cy.session("id", (args) =>{ | |
| cy.createDomainContext('identity provider', () => { // login here | |
| cy.visit('identityprovider.com') //go to app you want to test | |
| login | |
| cy.get('a[data-cy="multi-domain-secondary-link"]').click() // click the app you want to go to | |
| // do all the stuff here | |
| }) | |
| }) | |
| cy.visit('myApp.com') //go to app you want to test | |
| // do test stuff here | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment