Skip to content

Commit

Permalink
Feature: End-2-End rest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Nov 20, 2023
1 parent 296a5a2 commit a0d9426
Show file tree
Hide file tree
Showing 5 changed files with 1,425 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
49 changes: 49 additions & 0 deletions Test/End-2-end/cypress/e2e/magento/api/rest-place-order.cy.js
Original file line number Diff line number Diff line change
@@ -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');
});
})
Loading

0 comments on commit a0d9426

Please sign in to comment.