From ab809a38d38f827f546c484341abd5edf5f6513f Mon Sep 17 00:00:00 2001 From: Grzegorz Sadowski Date: Mon, 29 Sep 2025 13:26:09 +0200 Subject: [PATCH 1/3] [Admin] Render button for order refund only if refund is possible --- .../header/title_block/actions/refunds.html.twig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 %} From 0c194602743db1f5883abfc949881754ec098f26 Mon Sep 17 00:00:00 2001 From: Grzegorz Sadowski Date: Mon, 29 Sep 2025 14:06:33 +0200 Subject: [PATCH 2/3] [Behat][Admin] Adjust scenario for rendering refund button --- features/refunding_single_order_unit.feature | 2 +- tests/Behat/Context/Ui/ManagingOrdersContext.php | 4 +--- tests/Behat/Page/Admin/Order/ShowPage.php | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) 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/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 From 4d98c44ea03a368114a584a770737a8bef4b55ab Mon Sep 17 00:00:00 2001 From: Grzegorz Sadowski Date: Mon, 29 Sep 2025 14:08:03 +0200 Subject: [PATCH 3/3] Add /var directory to .gitignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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