elgentos / magento2-cypress-testing-suite

A community-driven Cypress testing suite for Magento 2
MIT License
171 stars 38 forks source link

Order success page issue in Luma theme #108

Open akhilshenay opened 1 year ago

akhilshenay commented 1 year ago

Order success page not shown while executing the Checkout tests (can find and order in the customer order history after having placed an order). Instead its being redirected to the cart page. The order gets successfully placed.

The issue only happens for logged in scenario while automating with Cypress. During manual attempt and using selenium it works perfectly fine.

To Reproduce Steps to reproduce the behavior: Use any default luma instance. I tried in default Luma Magento 2.4.3 Run checkout tests >> can find and order in the customer order history after having placed an order

Expected behavior Order success page should be shown and the order number verification against the order history section should pass.

Screenshots image

peterjaap commented 1 year ago

@Vinai has more info about this!

Vinai commented 1 year ago

I have spent hours trying to figure out what is going on. All I know at this point in time is that switching to Cypress v10 fixes the issue.

The issue is not limited to Luma, but it seems to happen with any Checkout.
The session is reset somehow when navigating to the success page.
The technical reason is that in \Magento\Checkout\Model\Session\SuccessValidator::isValid() the session value $this->checkoutSession->getLastSuccessQuoteId() is not there any more so the success controller redirects to the cart page.
Also, the PHPSESSID and form_key cookies don't change, so I haven't been able to figure out why this is happening.

So for now my fix is:

rm -r node_modules package-lock.json

Then use the old package.json from here before the update to 12:

{
  "devDependencies": {
    "cypress": "^10.8.0",
    "cypress-localstorage-commands": "^2.2.1",
    "cypress-tags": "^1.0.2",
    "typescript": "^4.8.3"
  }
}

Then run

npm install

And it works again 🤨

akhilshenay commented 1 year ago

Thanks for the detailed reply. Your solution worked like a charm...! @Vinai @peterjaap

dimitri-rob commented 10 months ago

Hi, I'm facing the same issue with Cypress 12.7.x and 13.4.0. I follow @Vinai fix with downgrad to Cypress 10.8.0 and my checkout sucess works but is someone find a proper solution than downgrade ?