Skip to content

Instantly share code, notes, and snippets.

@filiphric
Created August 9, 2019 11:54
Show Gist options
  • Select an option

  • Save filiphric/fedd7ff55a2ff2bd52242494fa059a20 to your computer and use it in GitHub Desktop.

Select an option

Save filiphric/fedd7ff55a2ff2bd52242494fa059a20 to your computer and use it in GitHub Desktop.
describe('Logging to Google SSO protected event', () => {
it('Receive token and successfully open app', () => {
const socialLoginOptions = {
username: // google name here
password: // google password here
loginUrl: // your login page (in your app), where you would click on a „login with google“ button, this is url which puppeteer will open
resolveUrl: // the page where you land after you come back from google
headless: // set to tru
loginSelector: // this would be the selector of „login with google“ button where your puppeteer script would click
postLoginSelector: // selector on a page where you land after you come back from google login, basicaly to tell you that your page was loaded
};
// google login done via puppeteer, passing socialLoginOptions as arguments to GoogleSocialLogin task
cy
.task('GoogleSocialLogin', socialLoginOptions)
.then( authorization => {
let token = authorization.myCookie;
cy
.setCookie(token); // set the authorization to browser
});
// open browser
cy
.visit(); // visit the app you should now be authorized in
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment