diff --git a/.gitignore b/.gitignore
index 1b475a61..e8daf509 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@
/tests/TestApplication/.env.local
/tests/TestApplication/.env.*.local
+/var/
phpspec.yml
diff --git a/features/refunding_single_order_unit.feature b/features/refunding_single_order_unit.feature
index 299d0fe9..851cf208 100644
--- a/features/refunding_single_order_unit.feature
+++ b/features/refunding_single_order_unit.feature
@@ -47,7 +47,7 @@ Feature: Refunding a single order unit
@ui
Scenario: Not being able to refund unit from an order that is unpaid
When I am viewing the summary of the order "#00000022"
- Then I should see disabled refunds button
+ Then I should not see refunds button
@application
Scenario: Not being able to refund unit from an order that is unpaid
diff --git a/templates/admin/order/content/header/title_block/actions/refunds.html.twig b/templates/admin/order/content/header/title_block/actions/refunds.html.twig
index 10762014..381782ca 100644
--- a/templates/admin/order/content/header/title_block/actions/refunds.html.twig
+++ b/templates/admin/order/content/header/title_block/actions/refunds.html.twig
@@ -1,7 +1,10 @@
{% set order = hookable_metadata.context.resource %}
-{% set path = path('sylius_refund_order_refunds_list', {'orderNumber': order.number,}) %}
-
- {{ ux_icon('tabler:repeat', {'class': 'icon dropdown-item-icon'}) }}
- {{ 'sylius_refund.ui.refunds'|trans }}
-
+{% if can_refund_order(order.number) %}
+ {% set path = path('sylius_refund_order_refunds_list', {'orderNumber': order.number,}) %}
+
+
+ {{ ux_icon('tabler:repeat', {'class': 'icon dropdown-item-icon'}) }}
+ {{ 'sylius_refund.ui.refunds'|trans }}
+
+{% endif %}
diff --git a/tests/Behat/Context/Ui/ManagingOrdersContext.php b/tests/Behat/Context/Ui/ManagingOrdersContext.php
index a5033c88..e2e3ca38 100644
--- a/tests/Behat/Context/Ui/ManagingOrdersContext.php
+++ b/tests/Behat/Context/Ui/ManagingOrdersContext.php
@@ -33,9 +33,7 @@ public function shouldBeNotifiedThatTheOrderShouldBePaid(): void
);
}
- /**
- * @Then I should not see refunds button
- */
+ #[Then('I should not see refunds button')]
public function iShouldNotSeeRefundsButton(): void
{
Assert::false($this->showPage->hasRefundsButton());
diff --git a/tests/Behat/Page/Admin/Order/ShowPage.php b/tests/Behat/Page/Admin/Order/ShowPage.php
index 69e06d5d..71024b83 100644
--- a/tests/Behat/Page/Admin/Order/ShowPage.php
+++ b/tests/Behat/Page/Admin/Order/ShowPage.php
@@ -37,7 +37,7 @@ public function hasDownloadCreditMemoButton(int $index): bool
public function hasRefundsButton(): bool
{
- return $this->getDocument()->hasButton('Refunds');
+ return $this->getDocument()->has('css', '[data-test-refunds]');
}
public function hasDisabledRefundsButton(): bool