lirantal / cypress-social-logins

Cypress authentication flows using social network providers
Apache License 2.0
248 stars 78 forks source link

Feat/accept third party cookies #107

Closed TimLehner closed 2 years ago

TimLehner commented 2 years ago

Description

Similar behaviour is available using preLoginSelector, however this only works for accepting cookies on the user's application. This change:

Types of changes

Related Issue

https://github.com/lirantal/cypress-social-logins/issues/27

Motivation and Context

Trying to test a more-complicated login flow, where clicking the login button with existing React state may send additional context on the backend, e.g. for linking existing accounts. As a result I don't think I'm able to navigate directly to /api/auth/signin/facebook, instead I want to go to /api/auth/signin and use a selector to find the 'Facebook' button.

How Has This Been Tested?

Tested as part of integrating in my own project.

For example, took accept only essential cookies on Facebook:

const socialLoginOptions = {
  username,
  password,
  ...,
  loginSelector: 'form[action="http://localhost:3000/api/auth/signin/facebook"] > button[type="submit"]',
  trackingConsentSelectors: [
    'button[data-testid="cookie-policy-dialog-manage-button"]',
    'button[data-testid="cookie-policy-manage-dialog-accept-button"]'
  ]
}
cy.task('FacebookSocialLogin', socialLoginOptions).then(({ cookies, lsd, ssd }) => {
  ...
}

Screenshots (if appropriate):

image

Checklist:

lirantal commented 2 years ago

That looks good @TimLehner Thank you 👏

TimLehner commented 2 years ago

That's great, thanks! Is there anything I need to do to get this into a minor release?

lirantal commented 2 years ago

:tada: This PR is included in version 1.12.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

lirantal commented 2 years ago

:-)

Thank you again @TimLehner