From dee31330d3625de39f9e1aae3fcb2767f16af584 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 11 May 2023 09:32:12 +0200 Subject: [PATCH 01/21] Bugfix: Restore the quote when using the back button --- Model/Mollie.php | 4 ++++ .../RestoreQuoteOfUnsuccessfulPayment.php | 8 ------- .../cypress/e2e/magento/checkout.cy.js | 23 ++++++++++++++++--- .../pages/mollie/MollieHostedPaymentPage.js | 6 +++++ Test/Integration/Model/MollieTest.php | 4 ++++ .../PHPUnit/IntegrationTestCaseTrait.php | 6 ++++- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Model/Mollie.php b/Model/Mollie.php index a90c174cc04..a4076cafda8 100644 --- a/Model/Mollie.php +++ b/Model/Mollie.php @@ -250,6 +250,10 @@ public function startTransaction(Order $order) { $this->eventManager->dispatch('mollie_start_transaction', ['order' => $order]); + // When clicking the back button from the hosted payment we need a way to verify if the order was paid or not. + // If this is not the case, we restore the quote. This flag is used to determine if it was paid or not. + $order->getPayment()->setAdditionalInformation('mollie_success', false); + $storeId = $order->getStoreId(); if (!$apiKey = $this->mollieHelper->getApiKey($storeId)) { return false; diff --git a/Observer/ControllerActionPredispatchCheckoutIndexIndex/RestoreQuoteOfUnsuccessfulPayment.php b/Observer/ControllerActionPredispatchCheckoutIndexIndex/RestoreQuoteOfUnsuccessfulPayment.php index c27431e3206..50464b6ffaf 100644 --- a/Observer/ControllerActionPredispatchCheckoutIndexIndex/RestoreQuoteOfUnsuccessfulPayment.php +++ b/Observer/ControllerActionPredispatchCheckoutIndexIndex/RestoreQuoteOfUnsuccessfulPayment.php @@ -9,7 +9,6 @@ use Magento\Checkout\Model\Session; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Sales\Api\Data\OrderInterface; use Mollie\Payment\Config; use Mollie\Payment\Model\Mollie; @@ -26,19 +25,12 @@ class RestoreQuoteOfUnsuccessfulPayment implements ObserverInterface */ private $config; - /** - * @var TimezoneInterface - */ - private $timezone; - public function __construct( Session $checkoutSession, - TimezoneInterface $timezone, Config $config ) { $this->checkoutSession = $checkoutSession; $this->config = $config; - $this->timezone = $timezone; } public function execute(Observer $observer) diff --git a/Test/End-2-end/cypress/e2e/magento/checkout.cy.js b/Test/End-2-end/cypress/e2e/magento/checkout.cy.js index c31fafbeb58..1b2ef39b1f8 100644 --- a/Test/End-2-end/cypress/e2e/magento/checkout.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/checkout.cy.js @@ -1,12 +1,14 @@ import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; const checkoutPaymentPage = new CheckoutPaymentPage(); const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); -describe('Check the checkout', () => { - it('Should have a payment method specific class', () => { +describe('Checkout usage', () => { + it('C849728: Validate that each payment methods have a specific CSS class', () => { visitCheckoutPayment.visit(); checkoutPaymentPage.selectPaymentMethod('iDeal'); @@ -25,7 +27,7 @@ describe('Check the checkout', () => { cy.get('.payment-method-mollie_methods_sofort').should('not.have.class', '_active'); }); - it('Should render Mollie Components when selecting Credit Card', () => { + it('C849729: Validate that it renders Mollie Components when selecting the Credit Card method ', () => { visitCheckoutPayment.visit(); checkoutPaymentPage.selectPaymentMethod('Credit Card'); @@ -34,4 +36,19 @@ describe('Check the checkout', () => { cy.get('#card-holder').should('be.visible'); cy.get('#card-holder .mollie-component').should('be.visible'); }); + + it.only('C849662: Restores the cart when using the back button from the HPP', () => { + visitCheckoutPayment.visit(); + + checkoutPaymentPage.selectPaymentMethod('iDeal'); + checkoutPaymentPage.selectFirstAvailableIssuer(); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.assertIsVisible(); + + // The original test included a call to cy.go('back');, but this fails for unknown reasons in CI. + cy.visit('/checkout#payment'); + + cy.url().should('include', '/checkout#payment'); + }); }) diff --git a/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js b/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js index f87b30e170c..8af30b26dc0 100644 --- a/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js +++ b/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js @@ -21,4 +21,10 @@ export default class MollieHostedPaymentPage { cy.get('.button').click(); }); } + + assertIsVisible() { + cy.origin('https://www.mollie.com', {args: {status}}, ({status}) => { + cy.url().should('include', 'https://www.mollie.com/checkout/'); + }); + } } diff --git a/Test/Integration/Model/MollieTest.php b/Test/Integration/Model/MollieTest.php index cb85f49a2fa..1e03627d7ec 100644 --- a/Test/Integration/Model/MollieTest.php +++ b/Test/Integration/Model/MollieTest.php @@ -7,6 +7,7 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Quote\Model\Quote; use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderPaymentInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Mollie\Api\Endpoints\MethodEndpoint; use Mollie\Api\Exceptions\ApiException; @@ -78,6 +79,7 @@ public function testStartTransactionWithMethodOrder() /** @var OrderInterface $order */ $order = $this->objectManager->create(OrderInterface::class); $order->setEntityId(1); + $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); $helperMock = $this->createMock(\Mollie\Payment\Helper\General::class); $helperMock->method('getApiKey')->willReturn('test_dummyapikeywhichmustbe30characterslong'); @@ -106,6 +108,7 @@ public function testStartTransactionWithMethodPayment() /** @var OrderInterface $order */ $order = $this->objectManager->create(OrderInterface::class); $order->setEntityId(1); + $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); $helperMock = $this->createMock(\Mollie\Payment\Helper\General::class); $helperMock->method('getApiKey')->willReturn('test_dummyapikeywhichmustbe30characterslong'); @@ -139,6 +142,7 @@ public function testRetriesOnACurlTimeout() /** @var OrderInterface $order */ $order = $this->objectManager->create(OrderInterface::class); $order->setEntityId(1); + $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); $helperMock = $this->createMock(\Mollie\Payment\Helper\General::class); $helperMock->method('getApiKey')->willReturn('test_dummyapikeywhichmustbe30characterslong'); diff --git a/Test/Integration/PHPUnit/IntegrationTestCaseTrait.php b/Test/Integration/PHPUnit/IntegrationTestCaseTrait.php index 54f508113c6..495be46010b 100644 --- a/Test/Integration/PHPUnit/IntegrationTestCaseTrait.php +++ b/Test/Integration/PHPUnit/IntegrationTestCaseTrait.php @@ -10,6 +10,7 @@ use Magento\Framework\Encryption\Encryptor; use Magento\Framework\Filesystem\DirectoryList; use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderPaymentInterface; use Magento\Sales\Api\OrderRepositoryInterface; use Magento\TestFramework\ObjectManager; use Mollie\Payment\Plugin\Quote\Api\PaymentMethodManagementPlugin; @@ -25,7 +26,10 @@ trait IntegrationTestCaseTrait protected function loadOrder(string $incrementId): OrderInterface { - return $this->loadOrderById($incrementId); + $order = $this->loadOrderById($incrementId); + $order->setPayment($this->objectManager->create(OrderPaymentInterface::class)); + + return $order; } public function loadOrderById(string $orderId): OrderInterface From 8bbe3190bb596ce2187cdb81a21ade03f53e16d0 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 11 May 2023 12:38:02 +0200 Subject: [PATCH 02/21] Improvement: Immediately show an error when the company is missing when using Billie --- Controller/Checkout/Redirect.php | 71 +++++------------ Service/Mollie/FormatExceptionMessages.php | 42 ++++++++++ .../cypress/e2e/magento/methods/billie.cy.js | 18 +++++ .../e2e/magento/methods/paymentlink.cy.js | 9 --- ...rman-shipping-address-without-company.json | 14 ++++ .../VisitCheckoutPaymentCompositeAction.js | 15 ++-- .../pages/frontend/CheckoutPaymentPage.js | 6 +- .../pages/frontend/CheckoutShippingPage.js | 6 ++ .../web/js/view/payment/method-renderer.js | 5 +- .../js/view/payment/method-renderer/billie.js | 76 +++++++++++++++++++ 10 files changed, 195 insertions(+), 67 deletions(-) create mode 100644 Service/Mollie/FormatExceptionMessages.php create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js delete mode 100644 Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js create mode 100644 Test/End-2-end/cypress/fixtures/german-shipping-address-without-company.json create mode 100644 view/frontend/web/js/view/payment/method-renderer/billie.js diff --git a/Controller/Checkout/Redirect.php b/Controller/Checkout/Redirect.php index ee768ec91de..84c8b3f47f7 100644 --- a/Controller/Checkout/Redirect.php +++ b/Controller/Checkout/Redirect.php @@ -24,6 +24,7 @@ use Mollie\Payment\Model\Methods\ApplePay; use Mollie\Payment\Model\Methods\CreditcardVault; use Mollie\Payment\Model\Mollie; +use Mollie\Payment\Service\Mollie\FormatExceptionMessages; use Mollie\Payment\Service\Mollie\Order\RedirectUrl; /** @@ -70,20 +71,25 @@ class Redirect extends Action * @var RedirectUrl */ private $redirectUrl; + /** + * @var FormatExceptionMessages + */ + private $formatExceptionMessages; /** * Redirect constructor. * - * @param Context $context - * @param Session $checkoutSession - * @param PageFactory $resultPageFactory - * @param PaymentHelper $paymentHelper - * @param MollieHelper $mollieHelper - * @param OrderManagementInterface $orderManagement - * @param Config $config - * @param PaymentTokenRepositoryInterface $paymentTokenRepository, - * @param OrderRepositoryInterface $orderRepository - * @param RedirectUrl $redirectUrl + * @param Context $context + * @param Session $checkoutSession + * @param PageFactory $resultPageFactory + * @param PaymentHelper $paymentHelper + * @param MollieHelper $mollieHelper + * @param OrderManagementInterface $orderManagement + * @param Config $config + * @param PaymentTokenRepositoryInterface $paymentTokenRepository , + * @param OrderRepositoryInterface $orderRepository + * @param RedirectUrl $redirectUrl + * @param FormatExceptionMessages $formatExceptionMessages */ public function __construct( Context $context, @@ -95,7 +101,8 @@ public function __construct( Config $config, PaymentTokenRepositoryInterface $paymentTokenRepository, OrderRepositoryInterface $orderRepository, - RedirectUrl $redirectUrl + RedirectUrl $redirectUrl, + FormatExceptionMessages $formatExceptionMessages ) { $this->checkoutSession = $checkoutSession; $this->resultPageFactory = $resultPageFactory; @@ -106,6 +113,7 @@ public function __construct( $this->paymentTokenRepository = $paymentTokenRepository; $this->orderRepository = $orderRepository; $this->redirectUrl = $redirectUrl; + $this->formatExceptionMessages = $formatExceptionMessages; parent::__construct($context); } @@ -151,8 +159,8 @@ public function execute() return $this->_redirect('checkout/cart'); } } catch (Exception $exception) { - // @phpstan-ignore-next-line - $this->formatExceptionMessage($exception, $methodInstance ?? null); + $errorMessage = $this->formatExceptionMessages->execute($exception, $methodInstance ?? null); + $this->messageManager->addErrorMessage($errorMessage); $this->mollieHelper->addTolog('error', $exception->getMessage()); $this->checkoutSession->restoreQuote(); $this->cancelUnprocessedOrder($order, $exception->getMessage()); @@ -183,43 +191,6 @@ private function cancelUnprocessedOrder(OrderInterface $order, $message) } } - /** - * @param Exception $exception - * @param MethodInterface|null $methodInstance - */ - private function formatExceptionMessage(Exception $exception, MethodInterface $methodInstance = null) - { - if (stripos( - $exception->getMessage(), - 'The webhook URL is invalid because it is unreachable from Mollie\'s point of view' - ) !== false - ) { - $this->messageManager->addErrorMessage( - __( - 'The webhook URL is invalid because it is unreachable from Mollie\'s point of view. ' . - 'View this article for more information: ' . - 'https://github.com/mollie/magento2/wiki/Webhook-Communication-between-your-Magento-webshop-and-Mollie' - ) - ); - - return; - } - - if ($methodInstance && stripos($exception->getMessage(), 'cURL error 28') !== false) { - $this->messageManager->addErrorMessage( - __( - 'A Timeout while connecting to %1 occurred, this could be the result of an outage. ' . - 'Please try again or select another payment method.', - $methodInstance->getTitle() - ) - ); - - return; - } - - $this->messageManager->addExceptionMessage($exception, __($exception->getMessage())); - } - /** * @return OrderInterface * @throws LocalizedException diff --git a/Service/Mollie/FormatExceptionMessages.php b/Service/Mollie/FormatExceptionMessages.php new file mode 100644 index 00000000000..3f850238f31 --- /dev/null +++ b/Service/Mollie/FormatExceptionMessages.php @@ -0,0 +1,42 @@ + 'The webhook URL is invalid because it is unreachable from Mollie\'s point of view. View this article for more information: https://github.com/mollie/magento2/wiki/Webhook-Communication-between-your-Magento-webshop-and-Mollie', + ]; + + public function execute(\Exception $exception, MethodInterface $methodInstance = null): string + { + foreach ($this->allowedErrorMessages as $message) { + if (stripos($exception->getMessage(), $message) !== false) { + return $message; + } + } + + foreach ($this->convertErrorMessages as $search => $replacement) { + if (stripos($exception->getMessage(), $search) !== false) { + return __($replacement)->render(); + } + } + + if ($methodInstance && stripos($exception->getMessage(), 'cURL error 28') !== false) { + return __( + 'A Timeout while connecting to %1 occurred, this could be the result of an outage. ' . + 'Please try again or select another payment method.', + $methodInstance->getTitle() + )->render(); + } + + return $exception->getMessage(); + } +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js new file mode 100644 index 00000000000..fe363196899 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js @@ -0,0 +1,18 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); + +describe('C849727: Validate that a company is required to place an order with Billie', () => { + it('Requires the company to be filled before placing the order', () => { + visitCheckoutPayment.visit('german-shipping-address-without-company.json'); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Billie'); + checkoutPaymentPage.pressPlaceOrderButton(); + + cy.get('.message.message-error.error').contains('Please enter a company name.').should('be.visible'); + }); +}) diff --git a/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js deleted file mode 100644 index f66c0d891d0..00000000000 --- a/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('Check the functionality of the payment linkt method', () => { - it('Is possible to place an order using payment link', () => { - cy.backendLogin(); - - cy.visit('/admin/sales/order'); - - cy.contains('Create New Order').click(); - }); -}); diff --git a/Test/End-2-end/cypress/fixtures/german-shipping-address-without-company.json b/Test/End-2-end/cypress/fixtures/german-shipping-address-without-company.json new file mode 100644 index 00000000000..35b493cdfc8 --- /dev/null +++ b/Test/End-2-end/cypress/fixtures/german-shipping-address-without-company.json @@ -0,0 +1,14 @@ +{ + "type": { + "username": "annaschmidt@mollie.com", + "firstname": "Anna", + "lastname": "Schmidt", + "street[0]": "Musterstraße 1", + "city": "Berlin", + "postcode": "10115", + "telephone": "+49 30 XXXXXXXX" + }, + "select": { + "country_id": "DE" + } +} diff --git a/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js b/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js index a8459ab6d0f..ac2a70642a0 100644 --- a/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js +++ b/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js @@ -7,24 +7,29 @@ const checkoutPage = new CheckoutPage(); const checkoutShippingPage = new CheckoutShippingPage(); export default class VisitCheckoutPaymentCompositeAction { - visit(country = 'NL') { + visit(fixture = 'NL') { productPage.openProduct(2); productPage.addSimpleProductToCart(); checkoutPage.visit(); - this.fillAddress(country); + this.fillAddress(fixture); checkoutShippingPage.selectFirstAvailableShippingMethod(); checkoutPage.continue(); } - fillAddress(country) { - if (country === 'DE') { + fillAddress(fixture) { + if (fixture === 'DE') { checkoutShippingPage.fillGermanShippingAddress(); return; } - checkoutShippingPage.fillDutchShippingAddress(); + if (fixture === 'NL') { + checkoutShippingPage.fillDutchShippingAddress(); + return; + } + + checkoutShippingPage.fillShippingAddressUsingFixture(fixture); } } diff --git a/Test/End-2-end/cypress/support/pages/frontend/CheckoutPaymentPage.js b/Test/End-2-end/cypress/support/pages/frontend/CheckoutPaymentPage.js index 47dd19dcac4..327fae43d84 100644 --- a/Test/End-2-end/cypress/support/pages/frontend/CheckoutPaymentPage.js +++ b/Test/End-2-end/cypress/support/pages/frontend/CheckoutPaymentPage.js @@ -15,12 +15,16 @@ export default class CheckoutPaymentPage { cy.get('.payment-method._active [name="issuer"]').first().should('be.visible').check(); } + pressPlaceOrderButton() { + cy.get('.payment-method._active .action.primary.checkout').click(); + } + placeOrder() { cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); cy.intercept('POST', 'rest/default/V1/guest-carts/*/payment-information').as('placeOrderAction'); - cy.get('.payment-method._active .action.primary.checkout').click(); + this.pressPlaceOrderButton(); cy.wait('@placeOrderAction').then((interception) => { cy.expect(interception.response.statusCode).to.eq(200); diff --git a/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js b/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js index 151d49d56ea..dab05aa57f5 100644 --- a/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js +++ b/Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js @@ -11,6 +11,12 @@ export default class CheckoutShippingPage { }); } + fillShippingAddressUsingFixture(fixture) { + cy.fixture(fixture).then((address) => { + this.fillShippingAddress(address); + }); + } + fillShippingAddress(address) { Object.keys(address.type).forEach((field) => { cy.log('Filling field: ' + field); diff --git a/view/frontend/web/js/view/payment/method-renderer.js b/view/frontend/web/js/view/payment/method-renderer.js index 17cddbee342..ea3e9e9aafc 100644 --- a/view/frontend/web/js/view/payment/method-renderer.js +++ b/view/frontend/web/js/view/payment/method-renderer.js @@ -11,9 +11,10 @@ define( ) { 'use strict'; var defaultComponent = 'Mollie_Payment/js/view/payment/method-renderer/default'; + var billieComponent = 'Mollie_Payment/js/view/payment/method-renderer/billie'; var idealComponent = 'Mollie_Payment/js/view/payment/method-renderer/ideal'; - var kbcComponent = 'Mollie_Payment/js/view/payment/method-renderer/kbc'; var giftcardComponent = 'Mollie_Payment/js/view/payment/method-renderer/giftcard'; + var kbcComponent = 'Mollie_Payment/js/view/payment/method-renderer/kbc'; var creditcardComponent = 'Mollie_Payment/js/view/payment/method-renderer/creditcard'; var checkoutConfig = window.checkoutConfig.payment.mollie; @@ -25,7 +26,7 @@ define( {type: 'mollie_methods_bancontact', component: defaultComponent}, {type: 'mollie_methods_banktransfer', component: defaultComponent}, {type: 'mollie_methods_belfius', component: defaultComponent}, - {type: 'mollie_methods_billie', component: defaultComponent}, + {type: 'mollie_methods_billie', component: billieComponent}, {type: 'mollie_methods_creditcard', component: creditcardComponent}, {type: 'mollie_methods_directdebit', component: defaultComponent}, {type: 'mollie_methods_eps', component: defaultComponent}, diff --git a/view/frontend/web/js/view/payment/method-renderer/billie.js b/view/frontend/web/js/view/payment/method-renderer/billie.js new file mode 100644 index 00000000000..34209891959 --- /dev/null +++ b/view/frontend/web/js/view/payment/method-renderer/billie.js @@ -0,0 +1,76 @@ +define( + [ + 'jquery', + 'underscore', + 'mage/translate', + 'ko', + 'mage/url', + 'mage/storage', + 'Mollie_Payment/js/view/payment/method-renderer/default', + 'Magento_Checkout/js/model/quote', + 'Magento_Checkout/js/checkout-data', + 'Magento_Customer/js/model/customer', + 'Magento_Checkout/js/model/url-builder', + 'Mollie_Payment/js/model/checkout-config', + 'jquery/jquery-storageapi' + ], + function ( + $, + _, + __, + ko, + url, + storage, + Component, + quote, + checkoutData, + customer, + urlBuilder, + checkoutConfigData + ) { + 'use strict'; + + var checkoutConfig = window.checkoutConfig.payment; + + return Component.extend( + { + validate() { + var billingAddress = quote.billingAddress(); + + if (!billingAddress || !billingAddress.company) { + this.messageContainer.addErrorMessage({ + message: __('Please enter a company name.') + }); + + return false; + } + + return true; + }, + + bbbbbeforePlaceOrder: function () { + var serviceUrl; + + /** + * We retrieve a payment token. This is used to start the transaction once the order is placed. + */ + if (customer.isLoggedIn()) { + serviceUrl = urlBuilder.createUrl('/carts/mine/mollie/payment-token', {}); + } else { + serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/mollie/payment-token', { + quoteId: quote.getQuoteId() + }); + } + + var promise = storage.get(serviceUrl); + + promise.done( function (result) { + this.paymentToken(result); + }.bind(this)); + + return promise; + } + } + ); + } +); From 13b03ab54e19de1ff2db53dc5ee5bee9b86e82b9 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 15 May 2023 10:04:45 +0200 Subject: [PATCH 03/21] Improvement: Allow to specify the query separate --- Controller/Checkout/Process.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Controller/Checkout/Process.php b/Controller/Checkout/Process.php index eef4f591e95..d3994ed055e 100644 --- a/Controller/Checkout/Process.php +++ b/Controller/Checkout/Process.php @@ -109,7 +109,8 @@ public function execute() $this->checkoutSession->start(); $redirect = new DataObject([ - 'path' => 'checkout/onepage/success?utm_nooverride=1', + 'path' => 'checkout/onepage/success', + 'query' => ['utm_nooverride' => 1], ]); $this->eventManager->dispatch('mollie_checkout_success_redirect', [ @@ -119,7 +120,10 @@ public function execute() 'response' => $this->getResponse(), ]); - return $this->_redirect($redirect->getData('path')); + return $this->_redirect($redirect->getData('path'), [ + '_query' => $redirect->getData('query'), + '_use_rewrite' => false, + ]); } catch (\Exception $e) { $this->mollieHelper->addTolog('error', $e->getMessage()); $this->messageManager->addErrorMessage(__('Transaction failed. Please verify your billing information and payment method, and try again.')); From edb8853d2746629ef46a364f27533b5f4b46e4df Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 15 May 2023 13:44:07 +0200 Subject: [PATCH 04/21] Improvement: Double check that the order is paid before sending the payment reminder --- Service/Order/PaymentReminder.php | 13 +++++++ .../Service/Order/PaymentReminderTest.php | 34 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Test/Integration/Service/Order/PaymentReminderTest.php diff --git a/Service/Order/PaymentReminder.php b/Service/Order/PaymentReminder.php index 4cd09ae0c02..b085ac7eed7 100644 --- a/Service/Order/PaymentReminder.php +++ b/Service/Order/PaymentReminder.php @@ -9,6 +9,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\Order; use Mollie\Payment\Api\Data\PendingPaymentReminderInterface; use Mollie\Payment\Api\Data\SentPaymentReminderInterface; use Mollie\Payment\Api\Data\SentPaymentReminderInterfaceFactory; @@ -74,6 +75,18 @@ public function __construct( public function send(PendingPaymentReminderInterface $pendingPaymentReminder): OrderInterface { $order = $this->orderRepository->get($pendingPaymentReminder->getOrderId()); + + if (in_array($order->getState(), [Order::STATE_PROCESSING, Order::STATE_COMPLETE])) { + $this->logger->addInfoLog( + 'info', + sprintf('Order #%s is already completed, not sending payment reminder', $order->getIncrementId()) + ); + + $this->pendingPaymentReminderRepository->delete($pendingPaymentReminder); + + return $order; + } + $this->logger->addInfoLog( 'info', sprintf('Preparing to send the payment reminder for order #%s', $order->getIncrementId()) diff --git a/Test/Integration/Service/Order/PaymentReminderTest.php b/Test/Integration/Service/Order/PaymentReminderTest.php new file mode 100644 index 00000000000..fe854f9fc13 --- /dev/null +++ b/Test/Integration/Service/Order/PaymentReminderTest.php @@ -0,0 +1,34 @@ +loadOrder('100000001'); + + /** @var PendingPaymentReminderInterface $pendingPaymentReminder */ + $pendingPaymentReminder = $this->objectManager->create(PendingPaymentReminderInterface::class); + $pendingPaymentReminder->setOrderId($order->getId()); + + $secondChanceMock = $this->createMock(SecondChanceEmail::class); + $secondChanceMock->expects($this->never())->method('send'); + + /** @var PaymentReminder $instance */ + $instance = $this->objectManager->create(PaymentReminder::class, [ + 'secondChanceEmail' => $secondChanceMock, + ]); + + $instance->send($pendingPaymentReminder); + } +} From 67bcf6a89ed8ff123145e176ceeea5562304c893 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 15 May 2023 15:53:00 +0200 Subject: [PATCH 05/21] Feature: Save the method used when using payment link #631 --- .../Processors/PaymentLinkPaymentMethod.php | 26 ++++++ .../PaymentLinkPaymentMethodTest.php | 82 +++++++++++++++++++ Test/Integration/MollieOrderBuilder.php | 5 ++ Test/Integration/MolliePaymentBuilder.php | 5 ++ etc/di.xml | 1 + 5 files changed, 119 insertions(+) create mode 100644 Model/Client/Orders/Processors/PaymentLinkPaymentMethod.php create mode 100644 Test/Integration/Model/Client/Orders/Processors/PaymentLinkPaymentMethodTest.php diff --git a/Model/Client/Orders/Processors/PaymentLinkPaymentMethod.php b/Model/Client/Orders/Processors/PaymentLinkPaymentMethod.php new file mode 100644 index 00000000000..83c8e27e7a3 --- /dev/null +++ b/Model/Client/Orders/Processors/PaymentLinkPaymentMethod.php @@ -0,0 +1,26 @@ +getPayment()->getMethod() !== 'mollie_methods_paymentlink') { + return $response; + } + + $magentoOrder->getPayment()->setAdditionalInformation('payment_link_method_used', $mollieOrder->method); + + return $response; + } +} diff --git a/Test/Integration/Model/Client/Orders/Processors/PaymentLinkPaymentMethodTest.php b/Test/Integration/Model/Client/Orders/Processors/PaymentLinkPaymentMethodTest.php new file mode 100644 index 00000000000..dde89317cb1 --- /dev/null +++ b/Test/Integration/Model/Client/Orders/Processors/PaymentLinkPaymentMethodTest.php @@ -0,0 +1,82 @@ +objectManager->create(OrderPaymentInterface::class); + $payment->setMethod('mollie_methods_paymentlink'); + + $order = $this->loadOrderById('100000001'); + $order->setPayment($payment); + + /** @var MollieOrderBuilder $orderBuilder */ + $orderBuilder = $this->objectManager->create(MollieOrderBuilder::class); + $orderBuilder->setMethod('ideal'); + + /** @var PaymentLinkPaymentMethod $instance */ + $instance = $this->objectManager->get(PaymentLinkPaymentMethod::class); + + $instance->process( + $order, + $orderBuilder->build(), + 'webhook', + $this->objectManager->create(ProcessTransactionResponse::class, [ + 'success' => true, + 'status' => 'paid', + 'order_id' => '-01', + 'type' => 'webhook', + ]) + ); + + $this->assertEquals('ideal', $order->getPayment()->getAdditionalInformation('payment_link_method_used')); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * @return void + */ + public function testDoesNotSaveWhenNotPaymentLinkUsed(): void + { + /** @var OrderPaymentInterface $payment */ + $payment = $this->objectManager->create(OrderPaymentInterface::class); + $payment->setMethod('mollie_methods_ideal'); // Anything but paymentlink + + $order = $this->loadOrderById('100000001'); + $order->setPayment($payment); + + /** @var MollieOrderBuilder $orderBuilder */ + $orderBuilder = $this->objectManager->create(MollieOrderBuilder::class); + $orderBuilder->setMethod('ideal'); + + /** @var PaymentLinkPaymentMethod $instance */ + $instance = $this->objectManager->get(PaymentLinkPaymentMethod::class); + + $instance->process( + $order, + $orderBuilder->build(), + 'webhook', + $this->objectManager->create(ProcessTransactionResponse::class, [ + 'success' => true, + 'status' => 'paid', + 'order_id' => '-01', + 'type' => 'webhook', + ]) + ); + + $this->assertNull($order->getPayment()->getAdditionalInformation('payment_link_method_used')); + } +} diff --git a/Test/Integration/MollieOrderBuilder.php b/Test/Integration/MollieOrderBuilder.php index 682baf72b8b..b76d122d8fd 100644 --- a/Test/Integration/MollieOrderBuilder.php +++ b/Test/Integration/MollieOrderBuilder.php @@ -63,6 +63,11 @@ public function setStatus(string $status): void $this->order->status = $status; } + public function setMethod(string $method): void + { + $this->order->method = $method; + } + public function build(): Order { return $this->order; diff --git a/Test/Integration/MolliePaymentBuilder.php b/Test/Integration/MolliePaymentBuilder.php index c43c5f79af5..086cf826adf 100644 --- a/Test/Integration/MolliePaymentBuilder.php +++ b/Test/Integration/MolliePaymentBuilder.php @@ -39,6 +39,11 @@ public function setStatus(string $status): void $this->payment->status = $status; } + public function setMethod(string $string): void + { + $this->payment->method = $string; + } + public function build(): Payment { return $this->payment; diff --git a/etc/di.xml b/etc/di.xml index 73bf94c6543..3fa66fcb8d5 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -273,6 +273,7 @@ Mollie\Payment\Model\Client\Orders\Processors\AddAdditionalInformation Mollie\Payment\Model\Client\Orders\Processors\SaveCardDetails + Mollie\Payment\Model\Client\Orders\Processors\PaymentLinkPaymentMethod Mollie\Payment\Model\Client\Orders\Processors\LastPaymentStatusIsFailure From b405c338ba4618d2071cb7a354749563bae74be1 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 18 May 2023 12:56:41 +0200 Subject: [PATCH 06/21] Feature: Cypress test for the paymentlink --- .github/workflows/end-2-end-test.yml | 1 + .gitignore | 1 + .../e2e/magento/methods/paymentlink.cy.js | 53 +++++++++++++++++-- .../support/pages/backend/OrdersCreatePage.js | 36 +++++++++++++ .../pages/mollie/MollieHostedPaymentPage.js | 22 +++++++- 5 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js diff --git a/.github/workflows/end-2-end-test.yml b/.github/workflows/end-2-end-test.yml index c13ea114773..adf7832aa9a 100644 --- a/.github/workflows/end-2-end-test.yml +++ b/.github/workflows/end-2-end-test.yml @@ -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 diff --git a/.gitignore b/.gitignore index e7b1f2a936b..a6f431ac4c2 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js index f66c0d891d0..6c233da36e4 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js @@ -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'); }); }); diff --git a/Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js b/Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js new file mode 100644 index 00000000000..109ac3a58bf --- /dev/null +++ b/Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js @@ -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'); + }); + } +} diff --git a/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js b/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js index f87b30e170c..018dc1987de 100644 --- a/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js +++ b/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js @@ -1,5 +1,5 @@ export default class MollieHostedPaymentPage { - selectStatus(status) { + setCookie() { cy.setCookie( 'SESSIONID', "cypress-dummy-value", @@ -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/'); @@ -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(); + }); + } } From 60801f8a6ec1644f501365ee3c4cb74e02e1ff8f Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 12:03:48 +0200 Subject: [PATCH 07/21] Feature: End-2-End tests for Billie --- .../cypress/e2e/magento/methods/billie.cy.js | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js index fe363196899..3a61567d2ca 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js @@ -1,11 +1,19 @@ import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import CartPage from "Pages/frontend/CartPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +const cartPage = new CartPage(); const checkoutPaymentPage = new CheckoutPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const ordersPage = new OrdersPage(); const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); -describe('C849727: Validate that a company is required to place an order with Billie', () => { - it('Requires the company to be filled before placing the order', () => { +describe('Check that extra validations for Billie are working as expected', () => { + it('C849727: Validate that a company is required to place an order with Billie', () => { visitCheckoutPayment.visit('german-shipping-address-without-company.json'); cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); @@ -16,3 +24,43 @@ describe('C849727: Validate that a company is required to place an order with Bi cy.get('.message.message-error.error').contains('Please enter a company name.').should('be.visible'); }); }) + +describe('Check if Billie behaves as expected', () => { + [ + {status: 'authorized', orderStatus: 'Processing', title: 'C363473: Validate the submission of an order with Billie as payment method and payment mark as "Authorized"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C363474: Validate the submission of an order with Billie as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C363476: Validate the submission of an order with Billie as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C363475: Validate the submission of an order with Billie as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit('DE'); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Billie'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); +}) From d7e7ecf154fa69c5acb150adc26b5d7ec268b226 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 13:27:14 +0200 Subject: [PATCH 08/21] Feature: End-2-End tests for Giropay --- .../cypress/e2e/magento/methods/giropay.cy.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js diff --git a/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js new file mode 100644 index 00000000000..346cd44816d --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js @@ -0,0 +1,53 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +describe('Check if the Giropay payment method is behaving as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3081: Validate the submission of an order with Giropay as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3082: Validate the submission of an order with Giropay as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3084: Validate the submission of an order with Giropay as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3083: Validate the submission of an order with Giropay as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Giropay'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); +}) From 3768197075bf11448fea61ac3c516149d83eec03 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Thu, 18 May 2023 12:56:41 +0200 Subject: [PATCH 09/21] Feature: Cypress test for the paymentlink --- .github/workflows/end-2-end-test.yml | 1 + .gitignore | 1 + .../e2e/magento/methods/paymentlink.cy.js | 53 +++++++++++++++++-- .../support/pages/backend/OrdersCreatePage.js | 36 +++++++++++++ .../pages/mollie/MollieHostedPaymentPage.js | 22 +++++++- 5 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js diff --git a/.github/workflows/end-2-end-test.yml b/.github/workflows/end-2-end-test.yml index c13ea114773..adf7832aa9a 100644 --- a/.github/workflows/end-2-end-test.yml +++ b/.github/workflows/end-2-end-test.yml @@ -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 diff --git a/.gitignore b/.gitignore index e7b1f2a936b..a6f431ac4c2 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js index f66c0d891d0..6c233da36e4 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/paymentlink.cy.js @@ -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'); }); }); diff --git a/Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js b/Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js new file mode 100644 index 00000000000..109ac3a58bf --- /dev/null +++ b/Test/End-2-end/cypress/support/pages/backend/OrdersCreatePage.js @@ -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'); + }); + } +} diff --git a/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js b/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js index f87b30e170c..018dc1987de 100644 --- a/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js +++ b/Test/End-2-end/cypress/support/pages/mollie/MollieHostedPaymentPage.js @@ -1,5 +1,5 @@ export default class MollieHostedPaymentPage { - selectStatus(status) { + setCookie() { cy.setCookie( 'SESSIONID', "cypress-dummy-value", @@ -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/'); @@ -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(); + }); + } } From c45989b0bb5664ff0edbb822501a2d5f301c021b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 11:40:16 +0200 Subject: [PATCH 10/21] Feature: End-2-End tests for Belfius --- .../cypress/e2e/magento/methods/belfius.cy.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js diff --git a/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js new file mode 100644 index 00000000000..251af2bba64 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js @@ -0,0 +1,53 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +describe('Check if the payment methods are available', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3089: Validate the submission of an order with Belfius as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3090: Validate the submission of an order with Belfius as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3092: Validate the submission of an order with Belfius as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3091: Validate the submission of an order with Belfius as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Belfius'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); +}) From 2360b311e98da0f5078fcd62d665533445f61a93 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 11:41:33 +0200 Subject: [PATCH 11/21] Feature: Allow to set the product ID using environment variables --- Test/End-2-end/cypress.config.js | 5 +++++ .../actions/composite/VisitCheckoutPaymentCompositeAction.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Test/End-2-end/cypress.config.js b/Test/End-2-end/cypress.config.js index e0632c15779..21faa02a45a 100644 --- a/Test/End-2-end/cypress.config.js +++ b/Test/End-2-end/cypress.config.js @@ -1,8 +1,13 @@ const { defineConfig } = require("cypress"); +const defaultProductId = process.env.DEFAULT_PRODUCT_ID || 2; + module.exports = defineConfig({ projectId: "44bnds", chromeWebSecurity: false, + env: { + defaultProductId: defaultProductId, + }, e2e: { experimentalWebKitSupport: true, setupNodeEvents(on, config) { diff --git a/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js b/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js index a8459ab6d0f..f36f1d961a4 100644 --- a/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js +++ b/Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js @@ -8,7 +8,7 @@ const checkoutShippingPage = new CheckoutShippingPage(); export default class VisitCheckoutPaymentCompositeAction { visit(country = 'NL') { - productPage.openProduct(2); + productPage.openProduct(Cypress.env('defaultProductId')); productPage.addSimpleProductToCart(); checkoutPage.visit(); From 4e5693d15ce034d9ba6c493a454cb9631f09aa50 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 12:14:55 +0200 Subject: [PATCH 12/21] Feature: End-2-End tests for Banktransfer --- .../e2e/magento/methods/banktransfer.cy.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js diff --git a/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js new file mode 100644 index 00000000000..27567382662 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js @@ -0,0 +1,54 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +describe('Check that banktransfer behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3094: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Paid"'}, + {status: 'open', orderStatus: 'Pending Payment', title: 'C3093: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Open"'}, + // {status: 'failed', orderStatus: 'Canceled', title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3095: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Expired"'}, + // {status: 'canceled', orderStatus: 'Canceled', title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Banktransfer'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); +}) From 69507d06bdb42e3d9fe544754d232f19d499611c Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 13:23:05 +0200 Subject: [PATCH 13/21] Feature: End-2-End tests for EPS --- .../cypress/e2e/magento/methods/eps.cy.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js diff --git a/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js new file mode 100644 index 00000000000..26fbddb3a08 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js @@ -0,0 +1,53 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +describe('Check if the EPS payment methods works as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3073: Validate the submission of an order with EPS as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3074: Validate the submission of an order with EPS as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3076: Validate the submission of an order with EPS as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3075: Validate the submission of an order with EPS as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('EPS'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); +}) From 444415865c8cb1ac9f4da311f2c68c844127322f Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 14:29:54 +0200 Subject: [PATCH 14/21] Feature: Only run tests for methods that are enabled --- Test/End-2-end/cypress.config.js | 65 ++++++++++++++- .../e2e/magento/methods/bancontact.cy.js | 82 ++++++++++++------- .../cypress/e2e/magento/methods/ideal.cy.js | 78 +++++++++++------- 3 files changed, 166 insertions(+), 59 deletions(-) diff --git a/Test/End-2-end/cypress.config.js b/Test/End-2-end/cypress.config.js index 21faa02a45a..b376d799931 100644 --- a/Test/End-2-end/cypress.config.js +++ b/Test/End-2-end/cypress.config.js @@ -11,7 +11,70 @@ module.exports = defineConfig({ e2e: { experimentalWebKitSupport: true, setupNodeEvents(on, config) { - return require('./cypress/plugins/index.js')(on, config) + require('./cypress/plugins/index.js')(on, config); + + const mollie_available_methods = new Promise((resolve, reject) => { + var https = require('follow-redirects').https; + var fs = require('fs'); + + const query = ` + query { + molliePaymentMethods(input:{amount:10, currency:"EUR"}) { + methods { + code + image + name + } + } + } + `; + + var options = { + 'method': 'GET', + 'hostname': 'mollie-opensource-237.controlaltdelete.dev', + 'path': '/graphql?query=' + encodeURIComponent(query), + 'headers': { + 'Content-Type': 'application/json', + 'Cookie': 'XDEBUG_SESSION=PHPSTORMx' + }, + 'maxRedirects': 20 + }; + + var req = https.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function (chunk) { + var body = Buffer.concat(chunks); + const methods = JSON.parse(body.toString()).data.molliePaymentMethods.methods.map(data => { + return data.code + }) + + config.env.mollie_available_methods = methods; + + console.log('Available Mollie payment methods: ', methods); + + resolve(config); + }); + + res.on("error", function (error) { + console.error('Error while fetching Mollie Payment methods', error); + reject(error); + }); + }); + + var postData = JSON.stringify({ + query: '', + variables: {} + }); + + req.end(); + }); + + return mollie_available_methods; }, }, }); diff --git a/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js index 63f2818c91d..dbc84a528b7 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js @@ -12,43 +12,65 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -describe('Check if the payment methods are available', () => { - [ - {status: 'paid', orderStatus: 'Processing', title: 'C3048: Validate the submission of an order with Bancontact as payment method and payment mark as "Paid"'}, - {status: 'open', orderStatus: 'Pending Payment', title: 'C3049: Validate the submission of an order with Bancontact as payment method and payment mark as "Open"'}, - {status: 'failed', orderStatus: 'Canceled', title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C3052: Validate the submission of an order with Bancontact as payment method and payment mark as "Expired"'}, - {status: 'canceled', orderStatus: 'Canceled', title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('bancontact')) { + describe('Check if the payment methods are available', () => { + [ + { + status: 'paid', + orderStatus: 'Processing', + title: 'C3048: Validate the submission of an order with Bancontact as payment method and payment mark as "Paid"' + }, + { + status: 'open', + orderStatus: 'Pending Payment', + title: 'C3049: Validate the submission of an order with Bancontact as payment method and payment mark as "Open"' + }, + { + status: 'failed', + orderStatus: 'Canceled', + title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"' + }, + { + status: 'expired', + orderStatus: 'Canceled', + title: 'C3052: Validate the submission of an order with Bancontact as payment method and payment mark as "Expired"' + }, + { + status: 'canceled', + orderStatus: 'Canceled', + title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"' + }, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('Bancontact'); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('Bancontact'); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - if (testCase.status === 'expired') { - ordersPage.callFetchStatus(); - } + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js index 548076d0959..873a3d7f7cc 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js @@ -12,40 +12,62 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -describe('Check if the payment methods are available', () => { - [ - {status: 'paid', orderStatus: 'Processing', title: 'C3043: Validate the submission of an order with iDEAL as payment method and payment mark as "Paid"'}, - {status: 'open', orderStatus: 'Pending Payment', title: 'C3044: Validate the submission of an order with iDEAL as payment method and payment mark as "Open"'}, - {status: 'failed', orderStatus: 'Canceled', title: 'C3045: Validate the submission of an order with iDEAL as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C3046: Validate the submission of an order with iDEAL as payment method and payment mark as "Expired"'}, - {status: 'canceled', orderStatus: 'Canceled', title: 'C3047: Validate the submission of an order with iDEAL as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('ideal')) { + describe('Check if the payment methods are available', () => { + [ + { + status: 'paid', + orderStatus: 'Processing', + title: 'C3043: Validate the submission of an order with iDEAL as payment method and payment mark as "Paid"' + }, + { + status: 'open', + orderStatus: 'Pending Payment', + title: 'C3044: Validate the submission of an order with iDEAL as payment method and payment mark as "Open"' + }, + { + status: 'failed', + orderStatus: 'Canceled', + title: 'C3045: Validate the submission of an order with iDEAL as payment method and payment mark as "Failed"' + }, + { + status: 'expired', + orderStatus: 'Canceled', + title: 'C3046: Validate the submission of an order with iDEAL as payment method and payment mark as "Expired"' + }, + { + status: 'canceled', + orderStatus: 'Canceled', + title: 'C3047: Validate the submission of an order with iDEAL as payment method and payment mark as "Cancelled"' + }, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('iDeal'); - checkoutPaymentPage.selectFirstAvailableIssuer(); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('iDeal'); + checkoutPaymentPage.selectFirstAvailableIssuer(); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} From e2c75d2872229e919d5385b66b6cb3dc2ce0c9fa Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 14:30:36 +0200 Subject: [PATCH 15/21] KBC/CBC --- .../cypress/e2e/magento/methods/kbc.cy.js | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js diff --git a/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js new file mode 100644 index 00000000000..1c923d89497 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js @@ -0,0 +1,71 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +if (Cypress.env('mollie_available_methods').includes('kbc')) { + describe('Check if the KBC/CBC payment method behaves as expected', () => { + [ + { + status: 'paid', + orderStatus: 'Processing', + title: 'C3080: Validate the submission of an order with KBC/CBC as payment method and payment mark as "Paid"' + }, + { + status: 'failed', + orderStatus: 'Canceled', + title: 'C3077: Validate the submission of an order with KBC/CBC as payment method and payment mark as "Failed"' + }, + { + status: 'expired', + orderStatus: 'Canceled', + title: 'C3079: Validate the submission of an order with KBC/CBC as payment method and payment mark as "Expired"' + }, + { + status: 'canceled', + orderStatus: 'Canceled', + title: 'C3078: Validate the submission of an order with KBC/CBC as payment method and payment mark as "Cancelled"' + }, + ].forEach((testCase) => { + it.only(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('KBC/CBC'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); + }) +} From c9a2f00011fd60c90490291a95337ca0a27f833b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 14:37:49 +0200 Subject: [PATCH 16/21] Feature: End-2-End tests for KBC --- Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js index 1c923d89497..85ef7120b2c 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js @@ -36,7 +36,7 @@ if (Cypress.env('mollie_available_methods').includes('kbc')) { title: 'C3078: Validate the submission of an order with KBC/CBC as payment method and payment mark as "Cancelled"' }, ].forEach((testCase) => { - it.only(testCase.title, () => { + it(testCase.title, () => { visitCheckoutPayment.visit(); cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); @@ -44,6 +44,10 @@ if (Cypress.env('mollie_available_methods').includes('kbc')) { checkoutPaymentPage.selectPaymentMethod('KBC/CBC'); checkoutPaymentPage.placeOrder(); + const values = ['CBC', 'KBC']; + const randomIndex = Math.floor(Math.random() * values.length); + + mollieHostedPaymentPage.selectPaymentMethod(values[randomIndex]); mollieHostedPaymentPage.selectStatus(testCase.status); if (testCase.status === 'paid') { From 8e0487c12f1802515cc85ec4dddd6ed31b539561 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 14:44:35 +0200 Subject: [PATCH 17/21] Only test methods that are available --- .../e2e/magento/methods/bancontact.cy.js | 32 ++-------- .../e2e/magento/methods/banktransfer.cy.js | 62 ++++++++++--------- .../cypress/e2e/magento/methods/belfius.cy.js | 60 +++++++++--------- .../methods/creditcard-with-components.cy.js | 42 +++++++------ .../cypress/e2e/magento/methods/eps.cy.js | 60 +++++++++--------- .../cypress/e2e/magento/methods/giropay.cy.js | 60 +++++++++--------- .../cypress/e2e/magento/methods/ideal.cy.js | 32 ++-------- .../cypress/e2e/magento/methods/kbc.cy.js | 2 +- 8 files changed, 160 insertions(+), 190 deletions(-) diff --git a/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js index dbc84a528b7..802f2d7a6e7 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/bancontact.cy.js @@ -13,33 +13,13 @@ const ordersPage = new OrdersPage(); const cartPage = new CartPage(); if (Cypress.env('mollie_available_methods').includes('bancontact')) { - describe('Check if the payment methods are available', () => { + describe('Check that bancontact behaves as expected', () => { [ - { - status: 'paid', - orderStatus: 'Processing', - title: 'C3048: Validate the submission of an order with Bancontact as payment method and payment mark as "Paid"' - }, - { - status: 'open', - orderStatus: 'Pending Payment', - title: 'C3049: Validate the submission of an order with Bancontact as payment method and payment mark as "Open"' - }, - { - status: 'failed', - orderStatus: 'Canceled', - title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"' - }, - { - status: 'expired', - orderStatus: 'Canceled', - title: 'C3052: Validate the submission of an order with Bancontact as payment method and payment mark as "Expired"' - }, - { - status: 'canceled', - orderStatus: 'Canceled', - title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"' - }, + {status: 'paid', orderStatus: 'Processing', title: 'C3048: Validate the submission of an order with Bancontact as payment method and payment mark as "Paid"'}, + {status: 'open', orderStatus: 'Pending Payment', title: 'C3049: Validate the submission of an order with Bancontact as payment method and payment mark as "Open"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3052: Validate the submission of an order with Bancontact as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"'}, ].forEach((testCase) => { it(testCase.title, () => { visitCheckoutPayment.visit(); diff --git a/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js index 27567382662..3ae0437e6d4 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/banktransfer.cy.js @@ -12,43 +12,45 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -describe('Check that banktransfer behaves as expected', () => { - [ - {status: 'paid', orderStatus: 'Processing', title: 'C3094: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Paid"'}, - {status: 'open', orderStatus: 'Pending Payment', title: 'C3093: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Open"'}, - // {status: 'failed', orderStatus: 'Canceled', title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C3095: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Expired"'}, - // {status: 'canceled', orderStatus: 'Canceled', title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('banktransfer')) { + describe('Check that banktransfer behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3094: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Paid"'}, + {status: 'open', orderStatus: 'Pending Payment', title: 'C3093: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Open"'}, + // {status: 'failed', orderStatus: 'Canceled', title: 'C3050: Validate the submission of an order with Bancontact as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3095: Validate the submission of an order with SEPA bank transfer as payment method and payment mark as "Expired"'}, + // {status: 'canceled', orderStatus: 'Canceled', title: 'C3051: Validate the submission of an order with Bancontact as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('Banktransfer'); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('Banktransfer'); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - if (testCase.status === 'expired') { - ordersPage.callFetchStatus(); - } + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js index 251af2bba64..a4814e0615e 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/belfius.cy.js @@ -12,42 +12,44 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -describe('Check if the payment methods are available', () => { - [ - {status: 'paid', orderStatus: 'Processing', title: 'C3089: Validate the submission of an order with Belfius as payment method and payment mark as "Paid"'}, - {status: 'failed', orderStatus: 'Canceled', title: 'C3090: Validate the submission of an order with Belfius as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C3092: Validate the submission of an order with Belfius as payment method and payment mark as "Expired"'}, - {status: 'canceled', orderStatus: 'Canceled', title: 'C3091: Validate the submission of an order with Belfius as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('belfius')) { + describe('Check that belfius behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3089: Validate the submission of an order with Belfius as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3090: Validate the submission of an order with Belfius as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3092: Validate the submission of an order with Belfius as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3091: Validate the submission of an order with Belfius as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('Belfius'); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('Belfius'); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - if (testCase.status === 'expired') { - ordersPage.callFetchStatus(); - } + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/creditcard-with-components.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/creditcard-with-components.cy.js index ec9a59ce9e8..755fdfa6b34 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/creditcard-with-components.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/creditcard-with-components.cy.js @@ -12,31 +12,33 @@ const mollieHostedPaymentPage = new MollieHostedPaymentPage(); const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); -describe('Test the Components in the checkout', () => { - it('C3037: Validate the submission of an order with Credit Card as payment method using Mollie Components and payment mark as "Paid"', () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('bancontact')) { + describe('Check that creditcards with components behaves as expected', () => { + it('C3037: Validate the submission of an order with Credit Card as payment method using Mollie Components and payment mark as "Paid"', () => { + visitCheckoutPayment.visit(); - checkoutPaymentPage.selectPaymentMethod('Credit Card'); + checkoutPaymentPage.selectPaymentMethod('Credit Card'); - components.fillComponentsForm( - 'Mollie Tester', - '3782 822463 10005', - '1230', - '1234' - ); + components.fillComponentsForm( + 'Mollie Tester', + '3782 822463 10005', + '1230', + '1234' + ); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus('paid'); + mollieHostedPaymentPage.selectStatus('paid'); - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - ordersPage.assertOrderStatusIs('Processing'); - }); -}) + ordersPage.assertOrderStatusIs('Processing'); + }); + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js index 26fbddb3a08..414b88c96da 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/eps.cy.js @@ -12,42 +12,44 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -describe('Check if the EPS payment methods works as expected', () => { - [ - {status: 'paid', orderStatus: 'Processing', title: 'C3073: Validate the submission of an order with EPS as payment method and payment mark as "Paid"'}, - {status: 'failed', orderStatus: 'Canceled', title: 'C3074: Validate the submission of an order with EPS as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C3076: Validate the submission of an order with EPS as payment method and payment mark as "Expired"'}, - {status: 'canceled', orderStatus: 'Canceled', title: 'C3075: Validate the submission of an order with EPS as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('eps')) { + describe('Check that eps behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3073: Validate the submission of an order with EPS as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3074: Validate the submission of an order with EPS as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3076: Validate the submission of an order with EPS as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3075: Validate the submission of an order with EPS as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('EPS'); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('EPS'); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - if (testCase.status === 'expired') { - ordersPage.callFetchStatus(); - } + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js index 346cd44816d..ee506979e42 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/giropay.cy.js @@ -12,42 +12,44 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -describe('Check if the Giropay payment method is behaving as expected', () => { - [ - {status: 'paid', orderStatus: 'Processing', title: 'C3081: Validate the submission of an order with Giropay as payment method and payment mark as "Paid"'}, - {status: 'failed', orderStatus: 'Canceled', title: 'C3082: Validate the submission of an order with Giropay as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C3084: Validate the submission of an order with Giropay as payment method and payment mark as "Expired"'}, - {status: 'canceled', orderStatus: 'Canceled', title: 'C3083: Validate the submission of an order with Giropay as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit(); +if (Cypress.env('mollie_available_methods').includes('giropay')) { + describe('Check that giropay behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3081: Validate the submission of an order with Giropay as payment method and payment mark as "Paid"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3082: Validate the submission of an order with Giropay as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3084: Validate the submission of an order with Giropay as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3083: Validate the submission of an order with Giropay as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('Giropay'); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('Giropay'); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - if (testCase.status === 'expired') { - ordersPage.callFetchStatus(); - } + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js index 873a3d7f7cc..1dc465e2898 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/ideal.cy.js @@ -13,33 +13,13 @@ const ordersPage = new OrdersPage(); const cartPage = new CartPage(); if (Cypress.env('mollie_available_methods').includes('ideal')) { - describe('Check if the payment methods are available', () => { + describe('CCheck that ideal behaves as expected', () => { [ - { - status: 'paid', - orderStatus: 'Processing', - title: 'C3043: Validate the submission of an order with iDEAL as payment method and payment mark as "Paid"' - }, - { - status: 'open', - orderStatus: 'Pending Payment', - title: 'C3044: Validate the submission of an order with iDEAL as payment method and payment mark as "Open"' - }, - { - status: 'failed', - orderStatus: 'Canceled', - title: 'C3045: Validate the submission of an order with iDEAL as payment method and payment mark as "Failed"' - }, - { - status: 'expired', - orderStatus: 'Canceled', - title: 'C3046: Validate the submission of an order with iDEAL as payment method and payment mark as "Expired"' - }, - { - status: 'canceled', - orderStatus: 'Canceled', - title: 'C3047: Validate the submission of an order with iDEAL as payment method and payment mark as "Cancelled"' - }, + {status: 'paid', orderStatus: 'Processing', title: 'C3043: Validate the submission of an order with iDEAL as payment method and payment mark as "Paid"'}, + {status: 'open', orderStatus: 'Pending Payment', title: 'C3044: Validate the submission of an order with iDEAL as payment method and payment mark as "Open"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3045: Validate the submission of an order with iDEAL as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3046: Validate the submission of an order with iDEAL as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3047: Validate the submission of an order with iDEAL as payment method and payment mark as "Cancelled"'}, ].forEach((testCase) => { it(testCase.title, () => { visitCheckoutPayment.visit(); diff --git a/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js index 85ef7120b2c..77fa0511164 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/kbc.cy.js @@ -13,7 +13,7 @@ const ordersPage = new OrdersPage(); const cartPage = new CartPage(); if (Cypress.env('mollie_available_methods').includes('kbc')) { - describe('Check if the KBC/CBC payment method behaves as expected', () => { + describe('Check that kbc behaves as expected', () => { [ { status: 'paid', From 8e23c0457ce5a6107650e1488d04ebb8caba18cf Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 15:23:44 +0200 Subject: [PATCH 18/21] Added more payment methods --- Test/End-2-end/cypress.config.js | 11 ++-- .../e2e/magento/methods/klarnapaylater.cy.js | 55 ++++++++++++++++++ .../e2e/magento/methods/klarnapaynow.cy.js | 55 ++++++++++++++++++ .../e2e/magento/methods/klarnasliceit.cy.js | 55 ++++++++++++++++++ .../cypress/e2e/magento/methods/paypal.cy.js | 56 +++++++++++++++++++ Test/End-2-end/cypress/support/e2e.js | 5 +- etc/adminhtml/methods/paypal.xml | 2 +- etc/config.xml | 2 +- 8 files changed, 232 insertions(+), 9 deletions(-) create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/klarnapaylater.cy.js create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/klarnapaynow.cy.js create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js create mode 100644 Test/End-2-end/cypress/e2e/magento/methods/paypal.cy.js diff --git a/Test/End-2-end/cypress.config.js b/Test/End-2-end/cypress.config.js index b376d799931..fc413d7df78 100644 --- a/Test/End-2-end/cypress.config.js +++ b/Test/End-2-end/cypress.config.js @@ -5,6 +5,9 @@ const defaultProductId = process.env.DEFAULT_PRODUCT_ID || 2; module.exports = defineConfig({ projectId: "44bnds", chromeWebSecurity: false, + retries: { + runMode: 2, + }, env: { defaultProductId: defaultProductId, }, @@ -13,13 +16,13 @@ module.exports = defineConfig({ setupNodeEvents(on, config) { require('./cypress/plugins/index.js')(on, config); - const mollie_available_methods = new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { var https = require('follow-redirects').https; var fs = require('fs'); const query = ` query { - molliePaymentMethods(input:{amount:10, currency:"EUR"}) { + molliePaymentMethods(input:{amount:100, currency:"EUR"}) { methods { code image @@ -35,7 +38,7 @@ module.exports = defineConfig({ 'path': '/graphql?query=' + encodeURIComponent(query), 'headers': { 'Content-Type': 'application/json', - 'Cookie': 'XDEBUG_SESSION=PHPSTORMx' + // 'Cookie': 'XDEBUG_SESSION=PHPSTORM' }, 'maxRedirects': 20 }; @@ -73,8 +76,6 @@ module.exports = defineConfig({ req.end(); }); - - return mollie_available_methods; }, }, }); diff --git a/Test/End-2-end/cypress/e2e/magento/methods/klarnapaylater.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/klarnapaylater.cy.js new file mode 100644 index 00000000000..a794d6aa684 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/klarnapaylater.cy.js @@ -0,0 +1,55 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +if (Cypress.env('mollie_available_methods').includes('klarnapaylater')) { + describe('Check that klarnapaylater behaves as expected', () => { + [ + {status: 'authorized', orderStatus: 'Processing', title: 'C3062: Validate the submission of an order with Klarna Pay Later as payment method and payment mark as "Authorized"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3063: Validate the submission of an order with Klarna Pay Later as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3065: Validate the submission of an order with Klarna Pay Later as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3064: Validate the submission of an order with Klarna Pay Later as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Klarna Pay Later'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/klarnapaynow.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/klarnapaynow.cy.js new file mode 100644 index 00000000000..6c405388932 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/klarnapaynow.cy.js @@ -0,0 +1,55 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +if (Cypress.env('mollie_available_methods').includes('klarnapaynow')) { + describe('Check that klarnapaynow behaves as expected', () => { + [ + {status: 'authorized', orderStatus: 'Processing', title: 'C3058: Validate the submission of an order with Klarna Pay Now as payment method and payment mark as "Authorized"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3059: Validate the submission of an order with Klarna Pay Now as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3061: Validate the submission of an order with Klarna Pay Now as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3060: Validate the submission of an order with Klarna Pay Now as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Klarna Pay Now'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js new file mode 100644 index 00000000000..957fd5bef5e --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js @@ -0,0 +1,55 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +// if (Cypress.env('mollie_available_methods').includes('klarnasliceit')) { + describe('Check that klarnasliceit behaves as expected', () => { + [ + {status: 'authorized', orderStatus: 'Processing', title: 'C3069: Validate the submission of an order with Klarna Slice It as payment method and payment mark as "Authorized"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3070: Validate the submission of an order with Klarna Slice It as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3072: Validate the submission of an order with Klarna Slice It as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3071: Validate the submission of an order with Klarna Slice It as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('Klarna Slice It'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); + }) +// } diff --git a/Test/End-2-end/cypress/e2e/magento/methods/paypal.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/paypal.cy.js new file mode 100644 index 00000000000..d60298a8b05 --- /dev/null +++ b/Test/End-2-end/cypress/e2e/magento/methods/paypal.cy.js @@ -0,0 +1,56 @@ +import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage"; +import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction"; +import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage"; +import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage"; +import OrdersPage from "Pages/backend/OrdersPage"; +import CartPage from "Pages/frontend/CartPage"; + +const checkoutPaymentPage = new CheckoutPaymentPage(); +const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); +const mollieHostedPaymentPage = new MollieHostedPaymentPage(); +const checkoutSuccessPage = new CheckoutSuccessPage(); +const ordersPage = new OrdersPage(); +const cartPage = new CartPage(); + +if (Cypress.env('mollie_available_methods').includes('paypal')) { + describe('Check that paypal behaves as expected', () => { + [ + {status: 'paid', orderStatus: 'Processing', title: 'C3053: Validate the submission of an order with Paypal as payment method and payment mark as "Paid"'}, + {status: 'pending', orderStatus: 'Pending Payment', title: 'C3054: Validate the submission of an order with Paypal as payment method and payment mark as "Pending"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C3055: Validate the submission of an order with Paypal as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C3057: Validate the submission of an order with Paypal as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C3056: Validate the submission of an order with Paypal as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit(); + + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + + checkoutPaymentPage.selectPaymentMethod('PayPal'); + checkoutPaymentPage.placeOrder(); + + mollieHostedPaymentPage.selectStatus(testCase.status); + + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } + + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } + + cy.backendLogin(); + + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); + + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } + + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); + }); + }) +} diff --git a/Test/End-2-end/cypress/support/e2e.js b/Test/End-2-end/cypress/support/e2e.js index af5bd7d5035..5bf0efd88f6 100644 --- a/Test/End-2-end/cypress/support/e2e.js +++ b/Test/End-2-end/cypress/support/e2e.js @@ -20,8 +20,9 @@ import './commands' // require('./commands') Cypress.on('uncaught:exception', (error, runnable) => { - // This is often thrown in Magento 2.4.6, but it doesn't seem to affect the test - if (error.message.indexOf('Cannot read properties of undefined (reading \'remove\')') !== -1) { + // Errors that sometimes occur but are safe to ignore + if (error.message.indexOf('Cannot read properties of undefined (reading \'remove\')') !== -1 || + error.message.indexOf('Cannot read properties of undefined (reading \'clone\')') !== -1) { return false } }) diff --git a/etc/adminhtml/methods/paypal.xml b/etc/adminhtml/methods/paypal.xml index 25278e7662c..66d6a711345 100644 --- a/etc/adminhtml/methods/paypal.xml +++ b/etc/adminhtml/methods/paypal.xml @@ -3,7 +3,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd"> - + diff --git a/etc/config.xml b/etc/config.xml index a6d9d42b751..d519fb6bb01 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -409,7 +409,7 @@ 1 Mollie\Payment\Model\Methods\Paypal - Paypal + PayPal {ordernumber} payment order From edb7d1a8ec1fc438f0ab4b4d06002852dc2f201b Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 20:35:54 +0200 Subject: [PATCH 19/21] Check that the methode is available for Billie and Klarna Slice It --- Test/End-2-end/cypress.config.js | 5 +- .../cypress/e2e/magento/methods/billie.cy.js | 78 ++++++++++--------- .../e2e/magento/methods/klarnasliceit.cy.js | 4 +- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/Test/End-2-end/cypress.config.js b/Test/End-2-end/cypress.config.js index fc413d7df78..d042c537d79 100644 --- a/Test/End-2-end/cypress.config.js +++ b/Test/End-2-end/cypress.config.js @@ -51,7 +51,10 @@ module.exports = defineConfig({ }); res.on("end", function (chunk) { - var body = Buffer.concat(chunks); + const body = Buffer.concat(chunks); + + console.info('Received body', body.toString()); + const methods = JSON.parse(body.toString()).data.molliePaymentMethods.methods.map(data => { return data.code }) diff --git a/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js index 3a61567d2ca..b8545ff97a0 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/billie.cy.js @@ -12,55 +12,57 @@ const mollieHostedPaymentPage = new MollieHostedPaymentPage(); const ordersPage = new OrdersPage(); const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction(); -describe('Check that extra validations for Billie are working as expected', () => { - it('C849727: Validate that a company is required to place an order with Billie', () => { - visitCheckoutPayment.visit('german-shipping-address-without-company.json'); +if (Cypress.env('mollie_available_methods').includes('billie')) { + describe('Check that extra validations for Billie are working as expected', () => { + it('C849727: Validate that a company is required to place an order with Billie', () => { + visitCheckoutPayment.visit('german-shipping-address-without-company.json'); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('Billie'); - checkoutPaymentPage.pressPlaceOrderButton(); + checkoutPaymentPage.selectPaymentMethod('Billie'); + checkoutPaymentPage.pressPlaceOrderButton(); - cy.get('.message.message-error.error').contains('Please enter a company name.').should('be.visible'); - }); -}) + cy.get('.message.message-error.error').contains('Please enter a company name.').should('be.visible'); + }); + }) -describe('Check if Billie behaves as expected', () => { - [ - {status: 'authorized', orderStatus: 'Processing', title: 'C363473: Validate the submission of an order with Billie as payment method and payment mark as "Authorized"'}, - {status: 'failed', orderStatus: 'Canceled', title: 'C363474: Validate the submission of an order with Billie as payment method and payment mark as "Failed"'}, - {status: 'expired', orderStatus: 'Canceled', title: 'C363476: Validate the submission of an order with Billie as payment method and payment mark as "Expired"'}, - {status: 'canceled', orderStatus: 'Canceled', title: 'C363475: Validate the submission of an order with Billie as payment method and payment mark as "Cancelled"'}, - ].forEach((testCase) => { - it(testCase.title, () => { - visitCheckoutPayment.visit('DE'); + describe('Check if Billie behaves as expected', () => { + [ + {status: 'authorized', orderStatus: 'Processing', title: 'C363473: Validate the submission of an order with Billie as payment method and payment mark as "Authorized"'}, + {status: 'failed', orderStatus: 'Canceled', title: 'C363474: Validate the submission of an order with Billie as payment method and payment mark as "Failed"'}, + {status: 'expired', orderStatus: 'Canceled', title: 'C363476: Validate the submission of an order with Billie as payment method and payment mark as "Expired"'}, + {status: 'canceled', orderStatus: 'Canceled', title: 'C363475: Validate the submission of an order with Billie as payment method and payment mark as "Cancelled"'}, + ].forEach((testCase) => { + it(testCase.title, () => { + visitCheckoutPayment.visit('DE'); - cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); + cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect'); - checkoutPaymentPage.selectPaymentMethod('Billie'); - checkoutPaymentPage.placeOrder(); + checkoutPaymentPage.selectPaymentMethod('Billie'); + checkoutPaymentPage.placeOrder(); - mollieHostedPaymentPage.selectStatus(testCase.status); + mollieHostedPaymentPage.selectStatus(testCase.status); - if (testCase.status === 'paid') { - checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); - } + if (testCase.status === 'paid') { + checkoutSuccessPage.assertThatOrderSuccessPageIsShown(); + } - if (testCase.status === 'canceled') { - cartPage.assertCartPageIsShown(); - } + if (testCase.status === 'canceled') { + cartPage.assertCartPageIsShown(); + } - cy.backendLogin(); + cy.backendLogin(); - cy.get('@order-id').then((orderId) => { - ordersPage.openOrderById(orderId); - }); + cy.get('@order-id').then((orderId) => { + ordersPage.openOrderById(orderId); + }); - if (testCase.status === 'expired') { - ordersPage.callFetchStatus(); - } + if (testCase.status === 'expired') { + ordersPage.callFetchStatus(); + } - ordersPage.assertOrderStatusIs(testCase.orderStatus); + ordersPage.assertOrderStatusIs(testCase.orderStatus); + }); }); - }); -}) + }) +} diff --git a/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js b/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js index 957fd5bef5e..ba1645d4ff9 100644 --- a/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js +++ b/Test/End-2-end/cypress/e2e/magento/methods/klarnasliceit.cy.js @@ -12,7 +12,7 @@ const checkoutSuccessPage = new CheckoutSuccessPage(); const ordersPage = new OrdersPage(); const cartPage = new CartPage(); -// if (Cypress.env('mollie_available_methods').includes('klarnasliceit')) { +if (Cypress.env('mollie_available_methods').includes('klarnasliceit')) { describe('Check that klarnasliceit behaves as expected', () => { [ {status: 'authorized', orderStatus: 'Processing', title: 'C3069: Validate the submission of an order with Klarna Slice It as payment method and payment mark as "Authorized"'}, @@ -52,4 +52,4 @@ const cartPage = new CartPage(); }); }); }) -// } +} From 35fdb2a91c28e9c605d7a4b60e6b31509b799800 Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 22 May 2023 21:16:26 +0200 Subject: [PATCH 20/21] Dynamic hostname --- Test/End-2-end/cypress.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Test/End-2-end/cypress.config.js b/Test/End-2-end/cypress.config.js index d042c537d79..b5ea3c23c06 100644 --- a/Test/End-2-end/cypress.config.js +++ b/Test/End-2-end/cypress.config.js @@ -20,6 +20,10 @@ module.exports = defineConfig({ var https = require('follow-redirects').https; var fs = require('fs'); + const baseUrl = config.baseUrl; + const urlObj = new URL(baseUrl); + const hostname = urlObj.hostname; + const query = ` query { molliePaymentMethods(input:{amount:100, currency:"EUR"}) { @@ -34,7 +38,7 @@ module.exports = defineConfig({ var options = { 'method': 'GET', - 'hostname': 'mollie-opensource-237.controlaltdelete.dev', + 'hostname': hostname, 'path': '/graphql?query=' + encodeURIComponent(query), 'headers': { 'Content-Type': 'application/json', From a77e3ca77061eecbaaed29a6b1886d82916c3374 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 25 May 2023 16:18:42 +0200 Subject: [PATCH 21/21] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9d5a879084d..17c6370ae76 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mollie/magento2", "description": "Mollie Payment Module for Magento 2", - "version": "2.25.0", + "version": "2.26.0", "keywords": [ "mollie", "payment", diff --git a/etc/config.xml b/etc/config.xml index d519fb6bb01..403b26c8d23 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -3,7 +3,7 @@ - v2.25.0 + v2.26.0 0 0 test