diff --git a/features/refunding_all_order_units.feature b/features/refunding_all_order_units.feature index fa184bab..29a42841 100644 --- a/features/refunding_all_order_units.feature +++ b/features/refunding_all_order_units.feature @@ -20,6 +20,7 @@ Feature: Refunding all order units When I want to refund some units of order "#00000022" And I decide to refund all units of this order with "Space money" payment Then I should be notified that selected order units have been successfully refunded + And I should not be able to refund anything And this order refunded total should be "$40.00" But I should not be able to refund 1st unit with product "Mr. Meeseeks T-Shirt" And I should not be able to refund 2nd unit with product "Mr. Meeseeks T-Shirt" diff --git a/src/Resources/views/orderRefunds.html.twig b/src/Resources/views/orderRefunds.html.twig index 7a079053..a71e2556 100644 --- a/src/Resources/views/orderRefunds.html.twig +++ b/src/Resources/views/orderRefunds.html.twig @@ -5,6 +5,7 @@ {% block title %}{{ 'sylius.ui.order'|trans ~' #'~ order.number }} {{ 'sylius_refund.ui.refunds'|trans }} {{ parent() }}{% endblock %} {% set customer = order.customer %} +{% set disableButton = order.paymentState == constant('Sylius\\Component\\Core\\OrderPaymentStates::STATE_REFUNDED') ? 'disabled' : '' %} {% block content %} {% include '@SyliusRefundPlugin/_header.html.twig' %} @@ -15,8 +16,8 @@
- - + +
@@ -42,7 +43,7 @@
- diff --git a/tests/Behat/Context/Ui/RefundingContext.php b/tests/Behat/Context/Ui/RefundingContext.php index cd646ec6..583aeae7 100644 --- a/tests/Behat/Context/Ui/RefundingContext.php +++ b/tests/Behat/Context/Ui/RefundingContext.php @@ -283,6 +283,14 @@ public function shouldStillBeAbleToRefundOrderShipment(): void Assert::true($this->orderRefundsPage->isOrderShipmentAvailableToRefund()); } + /** + * @Then I should not be able to refund anything + */ + public function iShouldNotBeAbleToRefundAnything(): void + { + Assert::true($this->orderRefundsPage->eachRefundButtonIsDisabled()); + } + /** * @Then I should not be able to refund order shipment */ diff --git a/tests/Behat/Page/Admin/OrderRefundsPage.php b/tests/Behat/Page/Admin/OrderRefundsPage.php index 902f0d33..2b1b72c4 100644 --- a/tests/Behat/Page/Admin/OrderRefundsPage.php +++ b/tests/Behat/Page/Admin/OrderRefundsPage.php @@ -103,6 +103,15 @@ public function isUnitWithProductAvailableToRefund(string $productName, int $uni return $this->isRefundable($this->getUnitsWithProduct($productName)[$unitNumber]); } + public function eachRefundButtonIsDisabled(): bool + { + return + $this->getDocument()->find('css', 'button[data-refund-clear]')->getAttribute('disabled') !== null && + $this->getDocument()->find('css', '#page-button')->getAttribute('disabled') !== null && + $this->getDocument()->find('css', 'button[data-refund-all]')->getAttribute('disabled') !== null + ; + } + public function isOrderShipmentAvailableToRefund(): bool { return $this->isRefundable($this->getOrderShipment()); diff --git a/tests/Behat/Page/Admin/OrderRefundsPageInterface.php b/tests/Behat/Page/Admin/OrderRefundsPageInterface.php index 07d253ee..3837e41a 100644 --- a/tests/Behat/Page/Admin/OrderRefundsPageInterface.php +++ b/tests/Behat/Page/Admin/OrderRefundsPageInterface.php @@ -32,6 +32,8 @@ public function refund(): void; public function isUnitWithProductAvailableToRefund(string $productName, int $unitNumber): bool; + public function eachRefundButtonIsDisabled(): bool; + public function isOrderShipmentAvailableToRefund(): bool; public function hasBackButton(): bool;