From 8441e7498e5e9edd5ce5cff4c7a8ec50f33d3a2e Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Tue, 6 Feb 2024 14:26:39 +0100 Subject: [PATCH] Pay previously canceled payment scenario --- .../paying_with_pagolight_during_checkout.feature | 14 ++++++++++++++ tests/Behat/Context/Ui/PagolightContext.php | 14 +++++++++++++- .../Page/Shop/Payum/Capture/PayumCaptureDoPage.php | 2 +- tests/Behat/Resources/services/ui.php | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/features/paying_with_pagolight_during_checkout.feature b/features/paying_with_pagolight_during_checkout.feature index 1014660..f46903e 100644 --- a/features/paying_with_pagolight_during_checkout.feature +++ b/features/paying_with_pagolight_during_checkout.feature @@ -41,3 +41,17 @@ Feature: Paying with Pagolight during checkout And I cancel the payment on Pagolight Then I should be notified that my payment has been cancelled And I should be able to pay again + + @ui @javascript + Scenario: Retrying the payment with success + Given I added product "PHP T-Shirt" to the cart + And I am at the checkout addressing step + And I specify the billing address as "Via Franceschini 3", "Casalgrande", "42013", "Italy" for "Mario Rossi" + And I complete the addressing step + And I proceeded with "Free" shipping method and "Pagolight" payment + And I have confirmed order + But I have cancelled Pagolight payment + When I try to pay again with Pagolight + And Pagolight notify the store about the successful payment + Then I should be redirected to the thank you page + And I should be notified that my payment has been completed diff --git a/tests/Behat/Context/Ui/PagolightContext.php b/tests/Behat/Context/Ui/PagolightContext.php index c71c570..7b07269 100644 --- a/tests/Behat/Context/Ui/PagolightContext.php +++ b/tests/Behat/Context/Ui/PagolightContext.php @@ -6,6 +6,7 @@ use Behat\Behat\Context\Context; use Behat\Mink\Session; +use Sylius\Behat\Page\Shop\Order\ShowPageInterface; use Sylius\Behat\Page\Shop\Order\ThankYouPageInterface; use Sylius\Bundle\PayumBundle\Model\PaymentSecurityTokenInterface; use Sylius\Component\Core\Repository\PaymentRepositoryInterface; @@ -30,6 +31,7 @@ public function __construct( private readonly Session $session, private readonly PayumCaptureDoPageInterface $payumCaptureDoPage, private readonly ThankYouPageInterface $thankYouPage, + private readonly ShowPageInterface $orderShowPage, ) { // TODO: Why config parameters are not loaded? $this->urlGenerator->setContext(new RequestContext('', 'GET', '127.0.0.1:8080', 'https')); @@ -48,7 +50,8 @@ public function iCompleteThePaymentOnPagolight(): void } /** - * @Given I cancel the payment on Pagolight + * @Given I have cancelled Pagolight payment + * @When I cancel the payment on Pagolight */ public function iCancelThePaymentOnPagolight(): void { @@ -81,6 +84,15 @@ public function iShouldBeRedirectedToTheThankYouPage(): void Assert::true($this->thankYouPage->hasThankYouMessage()); } + /** + * @When I try to pay again with Pagolight + */ + public function iTryToPayAgainWithPagolight(): void + { + $this->orderShowPage->pay(); + $this->iCompleteThePaymentOnPagolight(); + } + protected function getPaymentRepository(): PaymentRepositoryInterface { return $this->paymentRepository; diff --git a/tests/Behat/Page/Shop/Payum/Capture/PayumCaptureDoPage.php b/tests/Behat/Page/Shop/Payum/Capture/PayumCaptureDoPage.php index c4708a1..944ee29 100644 --- a/tests/Behat/Page/Shop/Payum/Capture/PayumCaptureDoPage.php +++ b/tests/Behat/Page/Shop/Payum/Capture/PayumCaptureDoPage.php @@ -16,7 +16,7 @@ public function getRouteName(): string public function waitForRedirect(): void { - $this->getDocument()->waitFor(5, function (DocumentElement $document) { + $this->getDocument()->waitFor(6, function (DocumentElement $document) { return !str_contains($document->getContent(), 'Stiamo processando il tuo pagamento'); }); } diff --git a/tests/Behat/Resources/services/ui.php b/tests/Behat/Resources/services/ui.php index c707a29..e299e50 100644 --- a/tests/Behat/Resources/services/ui.php +++ b/tests/Behat/Resources/services/ui.php @@ -18,6 +18,7 @@ service('behat.mink.default_session'), service('webgriffe_sylius_pagolight.behat.page.shop.payum.capture.do'), service('sylius.behat.page.shop.order.thank_you'), + service('sylius.behat.page.shop.order.show'), ]) ; };