Skip to content

Commit

Permalink
Merge branch 'improvement/add-retry-for-cypress' into release-week-04
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Jan 27, 2025
2 parents cbcf7db + 2e83f11 commit ce317e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Test/End-2-end/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ Cypress.on('uncaught:exception', (error, runnable) => {
) {
return false
}

if (error.message.indexOf('[object Object]') !== -1) {
return false
}
})
27 changes: 25 additions & 2 deletions Test/End-2-end/cypress/support/pages/backend/OrdersPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

import MagentoRestApi from "Services/MagentoRestApi";

const magentoRestApi = new MagentoRestApi();
Expand Down Expand Up @@ -38,8 +43,26 @@ export default class OrdersPage {
cy.wait(1000);
}

assertOrderStatusIs(status) {
cy.get('#order_status').contains(status);
/**
* 90 seconds is pretty high but test webhooks are considered non-essential so may be slow.
* @param status
* @param retries
*/
assertOrderStatusIs(status, retries = 90) {
// Webhooks are async. So sometimes we may visit the order page before the status is updated.
// If that's the case, we reload the page and try again, and do this 3 times.
cy.get('#order_status').then((element) => {
if (!element.text().includes(status) && retries > 0) {
cy.reload();
cy.wait(1000);

this.assertOrderStatusIs(status, retries - 1);
return;
}

// Trigger assertion to fail.
cy.get('#order_status').contains(status, { timeout: 100 });
});
}

assertMolliePaymentStatusIs(status) {
Expand Down

0 comments on commit ce317e4

Please sign in to comment.