Skip to content

Commit

Permalink
Feature: Cypress test for the paymentlink
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed May 22, 2023
1 parent 0a8e772 commit b405c33
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:
name: E2E logs - ${{ matrix.PHP_VERSION }} - ${{ matrix.MAGENTO_VERSION }}
path: |
Test/End-2-end/cypress/videos
Test/End-2-end/cypress/screenshots
magento-logs
magento.log
nginx-proxy.log
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ view/adminhtml/web/css/styles.css
view/frontend/web/css/styles.css
Test/End-2-end/node_modules
Test/End-2-end/cypress/videos
Test/End-2-end/cypress/screenshots
53 changes: 49 additions & 4 deletions Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
describe('Check the functionality of the payment linkt method', () => {
it('Is possible to place an order using payment link', () => {
import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage";
import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage";
import OrdersPage from "Pages/backend/OrdersPage";
import OrdersCreatePage from "Pages/backend/OrdersCreatePage";
import Cookies from "Services/Cookies";

const checkoutSuccessPage = new CheckoutSuccessPage();
const mollieHostedPaymentPage = new MollieHostedPaymentPage();
const ordersPage = new OrdersPage();
const ordersCreatePage = new OrdersCreatePage();
const cookies = new Cookies();

describe('Placing orders from the backend', () => {
it('C895380: Validate that the ecommerce admin can submis an order in the backend and mark as "Paid" ', () => {
cy.backendLogin();

cy.visit('/admin/sales/order');
ordersCreatePage.createNewOrderFor('Veronica Costello');

ordersCreatePage.addProduct('Erika Running Short-32-Red');

ordersCreatePage.selectShippingMethod('Fixed');

// 2.3.7 needs a double click to select the payment method, not sure why.
cy.get('[for="p_method_mollie_methods_paymentlink"]').click().click();

cy.get('#mollie_methods_paymentlink_methods').select([
'banktransfer',
'creditcard',
'ideal',
]);

cookies.disableSameSiteCookieRestrictions();

ordersCreatePage.submitOrder();

cy.get('.mollie-copy-url')
.invoke('attr', 'data-url')
.then(href => {
cy.visit(href);
});

mollieHostedPaymentPage.selectPaymentMethod('iDEAL');
mollieHostedPaymentPage.selectFirstIssuer();
mollieHostedPaymentPage.selectStatus('paid');

checkoutSuccessPage.assertThatOrderSuccessPageIsShown();

cy.get('@order-id').then((orderId) => {
ordersPage.openOrderById(orderId);
});

cy.contains('Create New Order').click();
ordersPage.assertOrderStatusIs('Processing');
});
});
36 changes: 36 additions & 0 deletions Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export default class OrdersCreatePage {
createNewOrderFor(customerName) {
cy.visit('/admin/sales/order');

cy.contains('Create New Order').click();

cy.contains(customerName).click();
}

addProduct(productName) {
cy.get('.action-add').contains('Add Products').click();

cy.contains(productName).click();

cy.get('.action-add').contains('Add Selected Product(s) to Order').click();
cy.get('.order-tables').should('contain', productName);
}

selectShippingMethod(method) {
cy.get('#order-shipping-method-summary').contains('Get shipping methods and rates').click();

cy.get('#order-shipping-method-choose').contains(method).click();
}

submitOrder() {
cy.get('.actions .save').contains('Submit Order').click();

cy.url().should('include', 'admin/sales/order/view/order_id/');

cy.contains('You created the order.');

cy.get('[name="order_id"]').invoke('val').then(id => {
cy.wrap(id).as('order-id');
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class MollieHostedPaymentPage {
selectStatus(status) {
setCookie() {
cy.setCookie(
'SESSIONID',
"cypress-dummy-value",
Expand All @@ -12,6 +12,10 @@ export default class MollieHostedPaymentPage {
);

cy.reload();
}

selectStatus(status) {
this.setCookie();

cy.origin('https://www.mollie.com', {args: {status}}, ({status}) => {
cy.url().should('include', 'https://www.mollie.com/checkout/');
Expand All @@ -21,4 +25,20 @@ export default class MollieHostedPaymentPage {
cy.get('.button').click();
});
}

selectPaymentMethod(method) {
this.setCookie();

cy.origin('https://www.mollie.com', {args: {method}}, ({method}) => {
cy.get('.payment-method-list').contains(method).click();
});
}

selectFirstIssuer() {
this.setCookie();

cy.origin('https://www.mollie.com', () => {
cy.get('.payment-method-list').find('[name="issuer"]').first().click();
});
}
}

0 comments on commit b405c33

Please sign in to comment.