From a0d9426479ae032c83298b64e4432d1b3b70185b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 20 Nov 2023 10:48:16 +0100 Subject: [PATCH] Feature: End-2-End rest tests --- .github/workflows/end-2-end-test.yml | 5 +- .../graphql-place-order.cy.js} | 4 +- .../e2e/magento/api/rest-place-order.cy.js | 49 + .../cypress/fixtures/mollie-pwa-graphql.html | 834 ++++++++++++++++++ .../cypress/fixtures/mollie-pwa-rest.html | 537 +++++++++++ 5 files changed, 1425 insertions(+), 4 deletions(-) rename Test/End-2-end/cypress/e2e/magento/{graphql/place-order.cy.js => api/graphql-place-order.cy.js} (92%) create mode 100644 Test/End-2-end/cypress/e2e/magento/api/rest-place-order.cy.js create mode 100644 Test/End-2-end/cypress/fixtures/mollie-pwa-graphql.html create mode 100644 Test/End-2-end/cypress/fixtures/mollie-pwa-rest.html diff --git a/.github/workflows/end-2-end-test.yml b/.github/workflows/end-2-end-test.yml index 14ff4a960e1..c6b6e5773b0 100644 --- a/.github/workflows/end-2-end-test.yml +++ b/.github/workflows/end-2-end-test.yml @@ -76,12 +76,13 @@ jobs: MAGENTO_URL=$(docker exec magento-project-community-edition /bin/bash -c "curl -s ngrok:4040/api/tunnels |jq -r \".tunnels[0].public_url\"") echo "magento_url=$MAGENTO_URL" >> $GITHUB_ENV - # Note the `mollie-pwa.html` file, as it is copied to the pub folder. This is so that it can be accessed by Cypress. + # Note the `mollie-pwa-*.html` files, as it is copied to the pub folder. This is so that it can be accessed by Cypress. - name: Upload the code into the docker container run: | sed -i '/version/d' ./composer.json && \ docker cp $(pwd) magento-project-community-edition:/data/extensions/ && \ - docker cp $(pwd)/Test/End-2-end/cypress/fixtures/mollie-pwa.html magento-project-community-edition:/data/pub/opt/ && \ + docker cp $(pwd)/Test/End-2-end/cypress/fixtures/mollie-pwa-graphql.html magento-project-community-edition:/data/pub/opt/ && \ + docker cp $(pwd)/Test/End-2-end/cypress/fixtures/mollie-pwa-rest.html magento-project-community-edition:/data/pub/opt/ && \ docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev - name: Activate the extension diff --git a/Test/End-2-end/cypress/e2e/magento/graphql/place-order.cy.js b/Test/End-2-end/cypress/e2e/magento/api/graphql-place-order.cy.js similarity index 92% rename from Test/End-2-end/cypress/e2e/magento/graphql/place-order.cy.js rename to Test/End-2-end/cypress/e2e/magento/api/graphql-place-order.cy.js index b4251d1c255..b9f88195d70 100644 --- a/Test/End-2-end/cypress/e2e/magento/graphql/place-order.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/api/graphql-place-order.cy.js @@ -13,9 +13,9 @@ const mollieHostedPaymentPage = new MollieHostedPaymentPage(); const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); -describe('Check that the headless endpoints work as expected', () => { +describe('Check that the headless GraphQL endpoints work as expected', () => { it('C1835263: Validate that an order can be placed through GraphQL ', () => { - cy.visit('opt/mollie-pwa.html'); + cy.visit('opt/mollie-pwa-graphql.html'); cy.get('[data-key="start-checkout-process"]').click(); diff --git a/Test/End-2-end/cypress/e2e/magento/api/rest-place-order.cy.js b/Test/End-2-end/cypress/e2e/magento/api/rest-place-order.cy.js new file mode 100644 index 00000000000..71328dbebcf --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/api/rest-place-order.cy.js @@ -0,0 +1,49 @@ +/* + * Copyright Magmodules.eu. All rights reserved. + * See COPYING.txt for license details. + */ + +import Cookies from "Services/Cookies"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; + +const cookies = new Cookies(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); + +describe('Check that the headless REST endpoints work as expected', () => { + it('C1988313: Validate that an order can be placed through REST', () => { + cy.visit('opt/mollie-pwa-rest.html'); + + cy.get('[data-key="start-checkout-process"]').click(); + + cy.get('[data-key="mollie_methods_ideal"]').click(); + + cy.get('[data-key="place-order-action"]').click(); + + cy.get('[data-key="order-id"]').then((element) => { + cy.wrap(element.text()).as('order-id'); + }); + + cookies.disableSameSiteCookieRestrictions(); + + cy.get('[data-key="redirect-url"]').then((element) => { + cy.visit(element.attr('href')); + }); + + mollieHostedPaymentPage.selectFirstIssuer(); + mollieHostedPaymentPage.selectStatus('paid'); + + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + + cy.backendLogin(false); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + ordersPage.assertOrderStatusIs('Processing'); + }); +}) diff --git a/Test/End-2-end/cypress/fixtures/mollie-pwa-graphql.html b/Test/End-2-end/cypress/fixtures/mollie-pwa-graphql.html new file mode 100644 index 00000000000..fcea4e2c5e7 --- /dev/null +++ b/Test/End-2-end/cypress/fixtures/mollie-pwa-graphql.html @@ -0,0 +1,834 @@ + + + + +
+
+ + +
+
+
+
Profile ID (optional)
+
+
+ +
+
+ Mode + (Must match payment/mollie_general/type) +
+
+
+ +
+
+ +
+
CurrentStep
+
{{ currentStep }}
+
+ +
+
CartId
+
{{ cartId }}
+
+ +
+ +
+
+
+
    +
  • + + + Create cart + + (from storage) + +
  • +
  • + + + Add product to cart +
  • +
  • + + + Add shipping & billing address +
  • +
  • + + + Get shippings methods ({{ shippingMethod }}) +
  • +
  • + + + Set shipping method +
  • +
  • + + + Get payment methods +
  • +
  • + + + Set the payment method +
  • +
  • + + + Place order +
  • +
  • + + + Check transaction +
  • +
+ +
+
+
+
+ + +
+
+

Order done!

+
+

Order ID: {{ orderId }}

+

1. Please open this url and select a payment status (or not):

+ {{ redirectUrl }}
+ +

2. When you have opened the url, click here to get the payment status:

+ + +
+ PaymentStatus: {{ paymentStatus }}
+ redirect_to_cart: {{ redirectToCart ? 'true' : 'false' }}
+ redirect_to_success_page: {{ redirectToSuccessPage ? 'true' : 'false' }}
+
+
+
+
+
+
+ +
+
+ + {{ method.title }} + + +
    +
  • + +
  • +
+
+ +
+
+
Card Number
+
+
+
+ +
+
Card Holder
+
+
+
+ +
+
Expiry Date
+
+
+
+ +
+
CVV
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ + Continue!? +
+
+
+ + + diff --git a/Test/End-2-end/cypress/fixtures/mollie-pwa-rest.html b/Test/End-2-end/cypress/fixtures/mollie-pwa-rest.html new file mode 100644 index 00000000000..b22c53d7abb --- /dev/null +++ b/Test/End-2-end/cypress/fixtures/mollie-pwa-rest.html @@ -0,0 +1,537 @@ + + + + +
+
+ + +
+
+
+
Profile ID (optional)
+
+
+ +
+
+ Mode + (Must match payment/mollie_general/type) +
+
+
+ +
+
+ +
+
CurrentStep
+
{{ currentStep }}
+
+ +
+
CartId
+
{{ cartId }}
+
+ +
+ +
+
+
+
    +
  • + + + Create cart + + (from storage) + +
  • +
  • + + + Add product to cart +
  • +
  • + + + Add shipping & billing address +
  • +
  • + + + Get shipping methods ({{ shippingMethod }}) +
  • +
  • + + + Set shipping method +
  • +
  • + + + Place order +
  • +
  • + + + Start transaction +
  • +
+ +
+
+
+
+ + +
+
+

Order done!

+
+

Order ID: {{ orderId }}

+

1. Please open this url and select a payment status (or not):

+ {{ redirectUrl }}
+ +

2. When you have opened the url, check the status in the backend of your webshop.

+
+
+
+
+
+ +
+
+ + + {{ method.title }} + +
+
+
Card Number
+
+
+
+ +
+
Card Holder
+
+
+
+ +
+
Expiry Date
+
+
+
+ +
+
CVV
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ + +