Skip to content

Instantly share code, notes, and snippets.

@mjhenkes
Last active January 24, 2022 19:06
Show Gist options
  • Select an option

  • Save mjhenkes/53d4505dc74609da2f00794301c73751 to your computer and use it in GitHub Desktop.

Select an option

Save mjhenkes/53d4505dc74609da2f00794301c73751 to your computer and use it in GitHub Desktop.
Cypress and cy partition discussion
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