cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.01k stars 3.18k forks source link

Investigate Salesforce API logins being broken #24290

Closed nagash77 closed 1 year ago

nagash77 commented 2 years ago

We want to look into several tickets involving Salesforce API authentication being broken by the latest Winter 22 release.

https://github.com/cypress-io/cypress/issues/23958, https://github.com/cypress-io/cypress/issues/24303

An older ticket that is still open - https://github.com/cypress-io/cypress/issues/2367

Also appears to impact Salesforce applications prior to login: https://github.com/cypress-io/cypress/issues/24418

AtofStryker commented 2 years ago

I created a reprod which is heavily based on some of the users provided reproductions here. I can provide the credentials if needed. I investigated for a bit and it looks like the markup://search_lightning:store is missing from the config options, but is present when functioning normally as top Screen Shot 2022-10-18 at 3 25 34 PM

alexanderg1982 commented 2 years ago

Hi Any news regarding these issues?

aliaksei-liauchuk-incountry commented 2 years ago

Are there any news this issue?

AtofStryker commented 2 years ago

@alexanderg1982 @aliaksei-liauchuk-incountry no updates on this currently, but we hope to look into this soon and will provide updates once we have something more to report.

tzioprodly commented 2 years ago

Hey guys, I am also experiencing this issue...

rzorzos commented 1 year ago

Is there a workaround on this at least? Or should we just wait for the resolve?

tit commented 1 year ago

Found Workaround. Use Firefox (not Chrome). In Firefox Salesforce login is worked.

TamirZano commented 1 year ago

We want to look into several tickets involving Salesforce API authentication being broken by the latest Winter 22 release.

23958, #24303

An older ticket that is still open - #2367

Also appears to impact Salesforce applications prior to login: #24418

TamirZano commented 1 year ago

Are there any news this issue?

jeanabanto commented 1 year ago

Any updates on this issue?

AtofStryker commented 1 year ago

no updates currently, but we will comment on the issue when we have news.

AtofStryker commented 1 year ago

Hey all. I will be beginning to look into this issue in the next few days and hopefully we can derive a solution. We appreciate your patience!

jpatil14 commented 1 year ago

Hi @AtofStryker , Thanks for looking into it. Would you be able to provide any ETA?

AtofStryker commented 1 year ago

Hi @jpatil14 . No ETA for a fix yet, but investing right now is my sole focus. I explored a few things the past few days and was able to rule out some things, but haven't been able to determine root cause. Trying a different approach today and hoping I have better luck!

jpatil14 commented 1 year ago

Hi @jpatil14 . No ETA for a fix yet, but investing right now is my sole focus. I explored a few things the past few days and was able to rule out some things, but haven't been able to determine root cause. Trying a different approach today and hoping I have better luck!

Thank you. Lets hope it gets resolved. Well its not only blocking actual SF application but our other application too which is based on SF. That other application used to work before 23 release but since 23 release its not working at all. At least we can run actual SF application in firefox browser but our other application is neither working in chrome nor in firefox.

AtofStryker commented 1 year ago

I did want to provide an update from some of the findings from the current investigation. The reason the site will not load in chrome with Cypress is that, for some reason, Proxy objects are missing in the salesforce sandbox. A lot of these commands are executed in an isolated sandbox, which might be different from iframe vs. running as top vs. firefox. Continuing to look into this to figure out why Proxy objects as a whole are missing.

Just a heads up it does take some time to get feedback, as we are debugging 6-10MB of minified JavaScript 😅 . A lot of these functions are also dynamically executed in eval statements making this even more challenging.

Salesforce Winter in Firefox or Chromium as top

Salesforce Winter in Chromium in iframe

AtofStryker commented 1 year ago

UPDATE: We were able to figure out the root cause. When Cypress injects it's test runner, document.domain is set to allow the application to perform sub domain navigations to allow continued interactivity with the application iframe. This causes issues for some reason with salesforce's near membrane. Not setting document.domain fixes the issue. Screenshot 2022-12-21 at 2 44 14 PM

Currently, we don't have a workaround for this ,as cy.intercept is unable to remove injection code. But the team is working on a solution that should unblock these issues. My guess ETA for a fix for this is 1-2 weeks.

jpatil14 commented 1 year ago

UPDATE: We were able to figure out the root cause. When Cypress injects it's test runner, document.domain is set to allow the application to perform sub domain navigations to allow continued interactivity with the application iframe. This causes issues for some reason with salesforce's near membrane. Not setting document.domain fixes the issue. Screenshot 2022-12-21 at 2 44 14 PM

Currently, we don't have a workaround for this ,as cy.intercept is unable to remove injection code. But the team is working on a solution that should unblock these issues. My guess ETA for a fix for this is 1-2 weeks.

Thanks for this update.

AtofStryker commented 1 year ago

Just wanted to give an update. We have added a new option, called experimentalSkipDomainInjection that will be available in Cypress 12.4.0 which will be released a week from Tuesday. You will be able to configure this option for salesforce like such:

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    baseUrl: "https://YOUR_SALES_FORCE_PREFIX.develop.lightning.force.com",
    experimentalModifyObstructiveThirdPartyCode: true,
    experimentalSkipDomainInjection: ['*.salesforce.com', '*.force.com']
  },
});

This works with SOAP/API based login as seen below

https://user-images.githubusercontent.com/3980464/211396263-735c4c7b-a3fd-4051-af5f-39741c2bfc20.mp4

This can also work with cy.origin()

https://user-images.githubusercontent.com/3980464/211396547-7464aee4-cb55-46c7-ab26-ce7e03e1dd02.mp4

AtofStryker commented 1 year ago

Hey all. Wanted to give an update that the 12.4.0 has been delayed slightly. Our estimated time for release is going to be Tuesday, January 24th, 2023. We appreciate your patience in advance and look forward to shipping this out!

cypress-bot[bot] commented 1 year ago

Released in 12.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v12.4.0, please open a new issue.

AtofStryker commented 1 year ago

So the experimentalSkipDomainInjection flag has now been released for about a week. If anyone has any feedback , positive or negative, please let us know!

The goal for this experimental flag has two outcomes. Likely moving forward, this will be a config option with the experimental prefix removed once we have seen ample feedback and addressed issues moving forward. So the flag would be called skipDomainInjection.

The other option would be to remove this flag if adoption isn't used, though this outcome is not likely.