From 100c79e50136f9b8c7c42686ccd3a9df5f316dd0 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:29:16 +0200 Subject: [PATCH 01/14] [Behat] Enable all hybrid checkout scenarios except one --- .../checkout/leaving_notes_on_order_during_checkout.feature | 2 +- .../placing_an_order_on_a_single_channel_store.feature | 4 ++-- ...order_on_multiple_channels_with_different_currency.feature | 4 ++-- ...g_an_order_on_multiple_channels_with_same_currency.feature | 4 ++-- src/Sylius/Behat/Page/Admin/Order/ShowPage.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/features/hybrid/checkout/leaving_notes_on_order_during_checkout.feature b/features/hybrid/checkout/leaving_notes_on_order_during_checkout.feature index 6be63148ba..96b925113f 100644 --- a/features/hybrid/checkout/leaving_notes_on_order_during_checkout.feature +++ b/features/hybrid/checkout/leaving_notes_on_order_during_checkout.feature @@ -13,7 +13,7 @@ Feature: Leaving additional request notes on my order during checkout And there is a customer account "customer@example.com" identified by "sylius" And I am logged in as "customer@example.com" - @todo @ui @api + @api @ui Scenario: Adding note on the checkout summary step Given I have product "PHP T-Shirt" in the cart And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" diff --git a/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_a_single_channel_store.feature b/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_a_single_channel_store.feature index ac71f2e99f..972e988db2 100644 --- a/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_a_single_channel_store.feature +++ b/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_a_single_channel_store.feature @@ -16,7 +16,7 @@ Feature: Placing an order on a single channel store And there is a customer account "customer@example.com" identified by "sylius" And I am logged in as "customer@example.com" - @todo @ui + @api @ui Scenario: Placing an order in a channels base currency Given I have product "PHP T-Shirt" in the cart And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" @@ -24,7 +24,7 @@ Feature: Placing an order on a single channel store And I confirm my order Then the administrator should see that order placed by "customer@example.com" has "USD" currency - @todo @ui @no-api + @no-api @ui Scenario: Placing an order in a channels base currency displaying prices in other currency Given that channel also allows to shop using the "CAD" currency And I had product "PHP T-Shirt" in the cart diff --git a/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_different_currency.feature b/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_different_currency.feature index 4ff38f03b2..6db9c647f0 100644 --- a/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_different_currency.feature +++ b/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_different_currency.feature @@ -17,7 +17,7 @@ Feature: Placing an order on multiple channels with different currency And there is a customer account "customer@example.com" identified by "sylius" And I am logged in as "customer@example.com" - @todo @ui @api + @api @ui Scenario: Placing an order in a channels base currency Given I changed my current channel to "United States" And I have product "PHP T-Shirt" in the cart @@ -26,7 +26,7 @@ Feature: Placing an order on multiple channels with different currency And I confirm my order Then the administrator should see that order placed by "customer@example.com" has "USD" currency - @todo @ui @api + @api @ui Scenario: Placing an order on a different channel with same currency Given I changed my current channel to "Colombia" And I had product "PHP T-Shirt" in the cart diff --git a/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_same_currency.feature b/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_same_currency.feature index 91dc157d0a..c680abce50 100644 --- a/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_same_currency.feature +++ b/features/hybrid/checkout/placing_order_on_multi_channel/placing_an_order_on_multiple_channels_with_same_currency.feature @@ -17,7 +17,7 @@ Feature: Placing an order on multiple channels with same currency And there is a customer account "customer@example.com" identified by "sylius" And I am logged in as "customer@example.com" - @todo @ui + @api @ui Scenario: Placing an order in a channels base currency Given I changed my current channel to "Web" And I have product "PHP T-Shirt" in the cart @@ -26,7 +26,7 @@ Feature: Placing an order on multiple channels with same currency And I confirm my order Then the administrator should see that order placed by "customer@example.com" has "USD" currency - @todo @ui + @api @ui Scenario: Placing an order on a different channel with same currency Given I changed my current channel to "Mobile" And I had product "PHP T-Shirt" in the cart diff --git a/src/Sylius/Behat/Page/Admin/Order/ShowPage.php b/src/Sylius/Behat/Page/Admin/Order/ShowPage.php index f952d70c74..d318e7ebbb 100644 --- a/src/Sylius/Behat/Page/Admin/Order/ShowPage.php +++ b/src/Sylius/Behat/Page/Admin/Order/ShowPage.php @@ -393,7 +393,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface return array_merge(parent::getDefinedElements(), [ 'billing_address' => '[data-test-billing-address]', 'cancel_order' => '[data-test-cancel-order]', - 'currency' => '#sylius-order-currency', + 'currency' => '[data-test-currency]', 'customer_email' => '[data-test-customer] [data-test-email]', 'ip_address' => '#ipAddress', 'item' => '[data-test-item="%name%"]', From 9785016ad4446b3a1006631f719138b06b787206 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:29:47 +0200 Subject: [PATCH 02/14] [Admin] Render currency test attribute --- .../order/show/content/sections/general/currency.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/currency.html.twig b/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/currency.html.twig index 8faf3ece69..c726d83a22 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/currency.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/currency.html.twig @@ -4,5 +4,5 @@
{{ 'sylius.ui.currency'|trans }}:
-
{{ order.currencyCode }}
+
{{ order.currencyCode }}
From 8e19388909465f87d5a6355a893bf5cc2dd14a59 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:33:01 +0200 Subject: [PATCH 03/14] [Behat] Enable hybrid catalog promotion scenarios --- ...duct_created_in_catalog_promotions_scope.feature | 6 +++--- ...tions_on_variant_once_its_prices_changes.feature | 4 ++-- ..._on_variants_once_products_taxon_changes.feature | 4 ++-- .../Ui/Admin/ManagingProductTaxonsContext.php | 13 ++++++++++--- .../Context/Ui/Admin/ProductCreationContext.php | 2 +- .../Behat/Resources/config/services/contexts/ui.xml | 1 + 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/features/hybrid/promotion/applying_catalog_promotions/applying_catalog_promotions_for_product_created_in_catalog_promotions_scope.feature b/features/hybrid/promotion/applying_catalog_promotions/applying_catalog_promotions_for_product_created_in_catalog_promotions_scope.feature index 35653155d9..d0aeb93ccf 100644 --- a/features/hybrid/promotion/applying_catalog_promotions/applying_catalog_promotions_for_product_created_in_catalog_promotions_scope.feature +++ b/features/hybrid/promotion/applying_catalog_promotions/applying_catalog_promotions_for_product_created_in_catalog_promotions_scope.feature @@ -9,13 +9,13 @@ Feature: Applying catalog promotions for product created in catalog promotions s And the store classifies its products as "Clothes" and "Dishes" And I am logged in as an administrator - @todo @ui @mink:chromedriver @no-api + @no-api @ui @mink:chromedriver Scenario: Applying catalog promotion on newly created simple product Given there is a catalog promotion "Clothes sale" that reduces price by "30%" and applies on "Clothes" taxon When I create a new simple product "T-Shirt" priced at "$20.00" with "Clothes" taxon in the "United States" channel Then the visitor should see "$14.00" as the price of the "T-Shirt" product in the "United States" channel - @api @todo @ui + @api @ui Scenario: Applying catalog promotion on newly created product variant Given there is a catalog promotion "Clothes sale" that reduces price by "30%" and applies on "Clothes" taxon And the store has a "T-Shirt" configurable product @@ -23,7 +23,7 @@ Feature: Applying catalog promotions for product created in catalog promotions s When I create a new "PHP T-Shirt" variant priced at "$20.00" for "T-Shirt" product in the "United States" channel Then the visitor should see "$14.00" as the price of the "T-Shirt" product in the "United States" channel - @api @todo @ui + @api @ui Scenario: Not applying catalog promotion on newly created product variant if it's not eligible Given there is a catalog promotion "Clothes sale" that reduces price by "30%" and applies on "Clothes" taxon And the store has a "Plate" configurable product diff --git a/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variant_once_its_prices_changes.feature b/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variant_once_its_prices_changes.feature index 1cf3d378fc..b7dd344f27 100644 --- a/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variant_once_its_prices_changes.feature +++ b/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variant_once_its_prices_changes.feature @@ -14,12 +14,12 @@ Feature: Not reapplying catalog promotions on variant once its prices changes And there is disabled catalog promotion "Surprise sale" between "2021-07-01" and "2022-05-04" available in "Web-US" channel that reduces price by "90%" and applies on "PHP T-Shirt" variant And I am logged in as an administrator - @api @todo @ui + @api @ui Scenario: Changing the price of the variant When I change the price of the "PHP T-Shirt" product variant to "$50.00" in "Web-US" channel Then the visitor should see "$50.00" as the price of the "T-Shirt" product in the "Web-US" channel - @api @todo @ui + @api @ui Scenario: Changing the original price of the variant When I change the original price of the "PHP T-Shirt" product variant to "$105.00" in "Web-US" channel Then the visitor should see "$100.00" as the price of the "T-Shirt" product in the "Web-US" channel diff --git a/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variants_once_products_taxon_changes.feature b/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variants_once_products_taxon_changes.feature index 556782973c..9b5b4cb72e 100644 --- a/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variants_once_products_taxon_changes.feature +++ b/features/hybrid/promotion/applying_catalog_promotions/not_reapplying_catalog_promotions_on_variants_once_products_taxon_changes.feature @@ -16,14 +16,14 @@ Feature: Not reapplying catalog promotions on variants once the product’s taxo And there is disabled catalog promotion "Surprise sale" between "2021-07-01" and "2022-05-04" available in "Web-US" channel that reduces price by "90%" and applies on "Dishes" taxon And I am logged in as an administrator - @api @todo @ui + @api @ui @mink:chromedriver Scenario: Changing products taxon to taxon with scheduled catalog promotion When I change that the "T-Shirt" product does not belong to the "Clothes" taxon And I add "Shirts" taxon to the "T-Shirt" product Then the visitor should see that the "PHP T-Shirt" variant is not discounted And the visitor should still see "$100.00" as the price of the "T-Shirt" product in the "Web-US" channel - @api @todo @ui + @api @ui @mink:chromedriver Scenario: Changing products taxon to taxon with disabled catalog promotion When I change that the "T-Shirt" product does not belong to the "Clothes" taxon And I add "Dishes" taxon to the "T-Shirt" product diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductTaxonsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductTaxonsContext.php index 5bb19c13c7..7009db49ee 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductTaxonsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductTaxonsContext.php @@ -15,14 +15,17 @@ namespace Sylius\Behat\Context\Ui\Admin; use Behat\Behat\Context\Context; use Sylius\Behat\Element\Admin\Product\TaxonomyFormElementInterface; +use Sylius\Behat\Page\Admin\Product\UpdateSimpleProductPageInterface; use Sylius\Component\Core\Model\ProductInterface; use Sylius\Component\Core\Model\TaxonInterface; use Webmozart\Assert\Assert; -final class ManagingProductTaxonsContext implements Context +final readonly class ManagingProductTaxonsContext implements Context { - public function __construct(private TaxonomyFormElementInterface $taxonomyFormElement) - { + public function __construct( + private UpdateSimpleProductPageInterface $updateSimpleProductPage, + private TaxonomyFormElementInterface $taxonomyFormElement, + ) { } /** @@ -41,6 +44,10 @@ final class ManagingProductTaxonsContext implements Context ProductInterface $product, TaxonInterface $taxon, ): void { + if (!$this->updateSimpleProductPage->isOpen(['id' => $product->getId()])) { + $this->updateSimpleProductPage->open(['id' => $product->getId()]); + } + $this->taxonomyFormElement->uncheckProductTaxon($taxon); } diff --git a/src/Sylius/Behat/Context/Ui/Admin/ProductCreationContext.php b/src/Sylius/Behat/Context/Ui/Admin/ProductCreationContext.php index b7b8107362..053f7b33ed 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ProductCreationContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ProductCreationContext.php @@ -52,7 +52,7 @@ final readonly class ProductCreationContext implements Context $this->productChannelPricingsFormElement->specifyPrice($channel, $price); $this->createPage->checkChannel($channel->getCode()); - $this->productTaxonomyFormElement->selectMainTaxon($taxon); + $this->productTaxonomyFormElement->selectMainTaxon($taxon->getName()); $this->productTaxonomyFormElement->checkProductTaxon($taxon); $this->createPage->create(); diff --git a/src/Sylius/Behat/Resources/config/services/contexts/ui.xml b/src/Sylius/Behat/Resources/config/services/contexts/ui.xml index 91907b01cf..a79995b8d5 100644 --- a/src/Sylius/Behat/Resources/config/services/contexts/ui.xml +++ b/src/Sylius/Behat/Resources/config/services/contexts/ui.xml @@ -239,6 +239,7 @@ + From 6520335ed69e9ab6e7e2c29591885b08eb83dbb9 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:37:51 +0200 Subject: [PATCH 04/14] [Behat] Enable editing product option scenario --- .../managing_product_options/editing_product_option.feature | 2 +- .../Behat/Context/Ui/Admin/ManagingProductOptionsContext.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/admin/product/managing_product_options/editing_product_option.feature b/features/admin/product/managing_product_options/editing_product_option.feature index 1c88e787b6..ff51372e40 100644 --- a/features/admin/product/managing_product_options/editing_product_option.feature +++ b/features/admin/product/managing_product_options/editing_product_option.feature @@ -19,7 +19,7 @@ Feature: Editing product options Then I should be notified that it has been successfully edited And this product option name should be "T-Shirt color" - @todo @ui @api + @api @ui Scenario: Not being able to edit code of an existing product option When I want to modify the "T-Shirt size" product option Then I should not be able to edit its code diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php index 750d8f3c1a..3685a1bd03 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductOptionsContext.php @@ -230,7 +230,7 @@ final readonly class ManagingProductOptionsContext implements Context */ public function iShouldNotBeAbleToEditItsCode(): void { - Assert::true($this->updatePage->isCodeDisabled()); + Assert::true($this->formElement->isCodeDisabled()); } /** From dcc4c176a7624525f132984f5d503f6f790252ef Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:39:48 +0200 Subject: [PATCH 05/14] [Behat] Enable remaining managing users scenario --- .../user/managing_users/changing_shop_user_password.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/admin/user/managing_users/changing_shop_user_password.feature b/features/admin/user/managing_users/changing_shop_user_password.feature index b4241d5b08..b05422d149 100644 --- a/features/admin/user/managing_users/changing_shop_user_password.feature +++ b/features/admin/user/managing_users/changing_shop_user_password.feature @@ -9,7 +9,7 @@ Feature: Changing shop user's password And there is a user "kibsoon@example.com" identified by "goodGuy" And I am logged in as an administrator - @api @todo @ui + @api @ui Scenario: Changing a password of a shop user When I change the password of user "kibsoon@example.com" to "veryGoodGuy" Then I should be notified that it has been successfully edited From 5411651c7e95bae2b883442f8cfc36ea6ae8d8b0 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:45:17 +0200 Subject: [PATCH 06/14] [Behat] Enable deleting multiple product variants scenario --- .../deleting_multiple_product_variants.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/admin/product/managing_product_variants/deleting_multiple_product_variants.feature b/features/admin/product/managing_product_variants/deleting_multiple_product_variants.feature index fb2bb1696f..266949e40c 100644 --- a/features/admin/product/managing_product_variants/deleting_multiple_product_variants.feature +++ b/features/admin/product/managing_product_variants/deleting_multiple_product_variants.feature @@ -10,7 +10,7 @@ Feature: Deleting multiple product variants And this product has "Small PHP Mug", "Medium PHP Mug" and "Big PHP Mug" variants And I am logged in as an administrator - @todo @ui @mink:chromedriver @no-api + @no-api @ui @mink:chromedriver Scenario: Deleting multiple product variants at once When I browse variants of this product And I check the "Small PHP Mug" product variant From be3615dc2c3e0fa3d0e224a1fe1d377a9e7f69fc Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 12:50:08 +0200 Subject: [PATCH 07/14] [Behat] Enable viewing product in store from variant edit page scenarios --- ..._the_shop_while_editing_their_product_variants.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/admin/product/managing_product_variants/checking_products_in_the_shop_while_editing_their_product_variants.feature b/features/admin/product/managing_product_variants/checking_products_in_the_shop_while_editing_their_product_variants.feature index da722438be..5d0e9e392a 100644 --- a/features/admin/product/managing_product_variants/checking_products_in_the_shop_while_editing_their_product_variants.feature +++ b/features/admin/product/managing_product_variants/checking_products_in_the_shop_while_editing_their_product_variants.feature @@ -10,22 +10,22 @@ In order to check a product in shop in all channels it is available in And the store has a product "Bugatti" available in "United States" channel And I am logged in as an administrator - @todo @ui @no-api + @no-api @ui Scenario: Accessing product show page in shop from the product variant edit page where product is available in more than one channel Given this product is also available in the "Europe" channel And this product has "Red" variant priced at "$220,000.00" in "Europe" channel When I want to modify the "Bugatti" product variant - And I choose to show this product in the "Europe" channel + And I choose to show this product in the channel "Europe" Then I should see this product in the "Europe" channel in the shop - @todo @ui @no-api + @no-api @ui Scenario: Accessing product show page in shop from the product variant edit page where product is available in one channel Given this product has "Red" variant priced at "$220,000.00" in "United States" channel When I want to modify the "Bugatti" product variant And I choose to show this product in this channel Then I should see this product in the "United States" channel in the shop - @todo @ui @no-api + @no-api @ui Scenario: Being unable to access product show page in shop when the product is disabled Given this product has been disabled When I want to modify the "Bugatti" product variant From 6a1cdaaf0d20fc773cd1267b82ea706aea5fdbeb Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 14:04:22 +0200 Subject: [PATCH 08/14] [Behat] Improve view product in store action --- .../Ui/Admin/ManagingProductVariantsContext.php | 6 +++--- .../Context/Ui/Admin/ManagingProductsContext.php | 2 +- .../Page/Admin/Product/UpdateSimpleProductPage.php | 6 ++++-- .../Product/UpdateSimpleProductPageInterface.php | 3 ++- .../Behat/Page/Admin/ProductVariant/UpdatePage.php | 13 +++++++------ .../Admin/ProductVariant/UpdatePageInterface.php | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php index 5ced61cfe6..bb99e818a5 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductVariantsContext.php @@ -277,11 +277,11 @@ final class ManagingProductVariantsContext implements Context } /** - * @When I choose to show this product in the :channelName channel + * @When /^I choose to show this product in the (channel "([^"]+)")$/ */ - public function iChooseToShowThisProductInTheChannel(string $channelName): void + public function iChooseToShowThisProductInTheChannel(ChannelInterface $channel): void { - $this->updatePage->showProductInChannel($channelName); + $this->updatePage->showProductInChannel($channel); } /** diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php index 532cd60eae..91fac8aebd 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php @@ -208,7 +208,7 @@ final readonly class ManagingProductsContext implements Context /** * @When I choose to show this product in the :channel channel */ - public function iChooseToShowThisProductInTheChannel(string $channel): void + public function iChooseToShowThisProductInTheChannel(ChannelInterface $channel): void { $this->updateSimpleProductPage->showProductInChannel($channel); } diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php index 0e48106ee1..eaf5ecf76a 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php @@ -19,6 +19,7 @@ use Sylius\Behat\Behaviour\ChecksCodeImmutability; use Sylius\Behat\Context\Ui\Admin\Helper\NavigationTrait; use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage; use Sylius\Behat\Service\Helper\AutocompleteHelperInterface; +use Sylius\Component\Core\Model\ChannelInterface; use Symfony\Component\Routing\RouterInterface; class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProductPageInterface @@ -93,9 +94,9 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd return $this->getElement('view_in_store')->hasClass('disabled'); } - public function showProductInChannel(string $channel): void + public function showProductInChannel(ChannelInterface $channel): void { - $this->getElement('view_in_store')->clickLink($channel); + $this->getElement('view_in_store_in_channel', ['%channel_code%' => $channel->getCode()])->click(); } public function showProductInSingleChannel(): void @@ -168,6 +169,7 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd 'side_navigation_tab' => '[data-test-side-navigation-tab="%name%"]', 'tracked' => '[name="sylius_admin_product[variant][tracked]"]', 'view_in_store' => '[data-test-view-in-store]', + 'view_in_store_in_channel' => '[data-test-view-in-store] [data-test-channel-code="%channel_code%"]', ]); } } diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php index e253e16a17..7639118efe 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php @@ -16,6 +16,7 @@ namespace Sylius\Behat\Page\Admin\Product; use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface as BaseUpdatePageInterface; use Sylius\Behat\Page\Admin\EditToShowPageSwitcherInterface; use Sylius\Behat\Page\Admin\ShowPageButtonCheckerInterface; +use Sylius\Component\Core\Model\ChannelInterface; interface UpdateSimpleProductPageInterface extends BaseUpdatePageInterface, @@ -46,7 +47,7 @@ interface UpdateSimpleProductPageInterface extends public function isShowInShopButtonDisabled(): bool; - public function showProductInChannel(string $channel): void; + public function showProductInChannel(ChannelInterface $channel): void; public function showProductInSingleChannel(): void; diff --git a/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php b/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php index 51bb647110..3b7788ba90 100644 --- a/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePage.php @@ -104,17 +104,17 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface public function isShowInShopButtonDisabled(): bool { - return $this->getElement('show_product_single_button')->hasClass('disabled'); + return $this->getElement('view_in_store')->hasClass('disabled'); } - public function showProductInChannel(string $channel): void + public function showProductInChannel(ChannelInterface $channel): void { - $this->getElement('show_product_dropdown')->clickLink($channel); + $this->getElement('view_in_store_in_channel', ['%channel_code%' => $channel->getCode()])->click(); } public function showProductInSingleChannel(): void { - $this->getElement('show_product_single_button')->click(); + $this->getElement('view_in_store')->click(); } public function isSelectedOptionValueOnPage(string $optionName, string $valueName): bool @@ -131,6 +131,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface { return array_merge(parent::getDefinedElements(), [ 'code' => '#sylius_admin_product_variant_code', + 'enabled' => '#sylius_admin_product_variant_enabled', 'minimum_price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_minimumPrice', 'name' => '#sylius_admin_product_variant_translations_%language%_name', 'on_hand' => '#sylius_admin_product_variant_onHand', @@ -139,10 +140,10 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface 'price' => '#sylius_admin_product_variant_channelPricings_%channelCode%_price', 'pricing_configuration' => '#sylius_calculator_container', 'shipping_required' => '#sylius_admin_product_variant_shippingRequired', - 'show_product_dropdown' => '.scrolling.menu', 'show_product_single_button' => 'a:contains("Show product in shop page")', 'tracked' => '#sylius_admin_product_variant_tracked', - 'enabled' => '#sylius_admin_product_variant_enabled', + 'view_in_store' => '[data-test-view-in-store]', + 'view_in_store_in_channel' => '[data-test-view-in-store] [data-test-channel-code="%channel_code%"]', ]); } diff --git a/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePageInterface.php index 1dd8ed783d..b9029361b4 100644 --- a/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/ProductVariant/UpdatePageInterface.php @@ -45,7 +45,7 @@ interface UpdatePageInterface extends BaseUpdatePageInterface public function isShowInShopButtonDisabled(): bool; - public function showProductInChannel(string $channel): void; + public function showProductInChannel(ChannelInterface $channel): void; public function showProductInSingleChannel(): void; From a046ac804b0c98763e28d2ceded0e8fe227352ac Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 14:04:52 +0200 Subject: [PATCH 09/14] [Admin] Render view in store button in the variant edit page --- .../config/app/twig_hooks/product_variant/update.yaml | 3 +++ .../title_block/actions/view_in_store.html.twig | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml index 59ed376a50..88b9a96753 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml @@ -13,6 +13,9 @@ twig_hooks: 'sylius_admin.product_variant.update.content.header.title_block.actions': price_history: template: '@SyliusAdmin/product_variant/form/content/update/header/actions/price_history.html.twig' + view_in_store: + template: '@SyliusAdmin/product/common/header/title_block/actions/view_in_store.html.twig' + 'sylius_admin.product_variant.update.content.form': side_navigation: diff --git a/src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig b/src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig index 189d2486dd..f4f3b7c110 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig @@ -1,9 +1,9 @@ -{% from '@SyliusAdmin/shared/helper/icon.html.twig' import icon %} - -{% set product = (hookable_metadata.context.resource) %} -{% set enabled_channels = product.channels|filter(channel => channel.enabled == true) %} - {% if sylius_bundle_loaded_checker('SyliusShopBundle') %} + {% from '@SyliusAdmin/shared/helper/icon.html.twig' import icon %} + + {% set product = hookable_metadata.context.resource.product|default(hookable_metadata.context.resource) %} + {% set enabled_channels = product.channels|filter(channel => channel.enabled == true) %} + {% if not product.enabled or enabled_channels|length < 1 %} {{ icon({ icon: 'arrow_up_right', class: 'icon icon-tabler' }) }} @@ -26,6 +26,7 @@ class="dropdown-item{% if url is not defined %} disabled{% endif %}" href="{{ (url is not defined) ? '#' : url|raw }}" target="_blank" + {{ sylius_test_html_attribute('channel-code', channel.code) }} > {{ icon({ icon: 'arrow_up_right', class: 'icon dropdown-item-icon icon-tabler' }) }} {{ channel.name }} ({{ channel.code }}) From 1108ea968329fe12698f052afd2aa1c1a3df4185 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 15:06:47 +0200 Subject: [PATCH 10/14] [Behat] Enable scenarios and improve implementation for filtered pages redirections --- ...edirected_to_previous_filtered_page.feature | 8 ++++---- .../Behat/Page/Admin/Crud/CreatePage.php | 18 +++++++++++++----- src/Sylius/Behat/Page/Admin/Crud/IndexPage.php | 18 +++++++++++++++--- .../Page/Admin/PaymentMethod/CreatePage.php | 6 ------ .../Admin/Product/CreateSimpleProductPage.php | 5 ----- .../Behat/Page/Admin/Product/IndexPage.php | 13 ------------- 6 files changed, 32 insertions(+), 36 deletions(-) diff --git a/features/admin/being_redirected_to_previous_filtered_page.feature b/features/admin/being_redirected_to_previous_filtered_page.feature index acf4b6bfd7..137315ae77 100644 --- a/features/admin/being_redirected_to_previous_filtered_page.feature +++ b/features/admin/being_redirected_to_previous_filtered_page.feature @@ -12,7 +12,7 @@ Feature: Being redirected to previous filtered page And the store has a product "Znicz Pruszków T-Shirt" And I am logged in as an administrator - @todo @ui @no-api + @no-api @ui Scenario: Being redirected to previous filtered page after deleting a product When I browse products And I choose enabled filter @@ -20,7 +20,7 @@ Feature: Being redirected to previous filtered page And I delete the "FC Barcelona T-Shirt" product on filtered page Then I should be redirected to the previous page of only enabled products - @todo @ui @no-api + @no-api @ui Scenario: Being redirected to previous filtered page after cancelling editing a product When I browse products And I choose enabled filter @@ -29,7 +29,7 @@ Feature: Being redirected to previous filtered page And I cancel my changes Then I should be redirected to the previous page of only enabled products - @todo @ui @no-api + @no-api @ui Scenario: Being redirected to previous filtered page with pagination after cancelling editing a product When I browse products And I choose enabled filter @@ -39,7 +39,7 @@ Feature: Being redirected to previous filtered page And I cancel my changes Then I should be redirected to the 2nd page of only enabled products - @todo @ui @no-api + @no-api @ui Scenario: Being redirected to previous filtered page after cancelling creating a new product When I browse products And I choose enabled filter diff --git a/src/Sylius/Behat/Page/Admin/Crud/CreatePage.php b/src/Sylius/Behat/Page/Admin/Crud/CreatePage.php index ae9d8822c9..ff7e1cfdb4 100644 --- a/src/Sylius/Behat/Page/Admin/Crud/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Crud/CreatePage.php @@ -28,7 +28,7 @@ class CreatePage extends SymfonyPage implements CreatePageInterface Session $session, $minkParameters, RouterInterface $router, - private string $routeName, + private readonly string $routeName, ) { parent::__construct($session, $minkParameters, $router); } @@ -61,17 +61,25 @@ class CreatePage extends SymfonyPage implements CreatePageInterface return $this->routeName; } + public function cancelChanges(): void + { + $this->getElement('cancel_button')->click(); + } + public function getMessageInvalidForm(): string { return $this->getDocument()->find('css', '.ui.icon.negative.message')->getText(); } + /** + * @return array + */ protected function getDefinedElements(): array { - return array_merge( - parent::getDefinedElements(), - ['form' => 'form'], - ); + return array_merge(parent::getDefinedElements(), [ + 'form' => 'form', + 'cancel_button' => '[data-test-cancel-changes-button]', + ]); } protected function waitForFormUpdate(): void diff --git a/src/Sylius/Behat/Page/Admin/Crud/IndexPage.php b/src/Sylius/Behat/Page/Admin/Crud/IndexPage.php index 0d9e6c6006..eb75e02cc6 100644 --- a/src/Sylius/Behat/Page/Admin/Crud/IndexPage.php +++ b/src/Sylius/Behat/Page/Admin/Crud/IndexPage.php @@ -27,8 +27,8 @@ class IndexPage extends SymfonyPage implements IndexPageInterface Session $session, $minkParameters, RouterInterface $router, - private TableAccessorInterface $tableAccessor, - private string $routeName, + private readonly TableAccessorInterface $tableAccessor, + private readonly string $routeName, ) { parent::__construct($session, $minkParameters, $router); } @@ -165,6 +165,16 @@ class IndexPage extends SymfonyPage implements IndexPageInterface return $this->routeName; } + public function goToPage(int $page): void + { + $this->getElement('page_button', ['%page%' => $page])->click(); + } + + public function getPageNumber(): int + { + return (int) $this->getElement('current_page')->getText(); + } + protected function getTableAccessor(): TableAccessorInterface { return $this->tableAccessor; @@ -200,10 +210,12 @@ class IndexPage extends SymfonyPage implements IndexPageInterface return array_merge(parent::getDefinedElements(), [ 'bulk_actions' => '.sylius-grid-nav__bulk', 'bulk_delete_confirm_button' => '[data-test-modal="bulk-delete"] [data-test-confirm-button]', - 'enabled_filter' => '#criteria_enabled', + 'current_page' => '[data-test-current-page]', + 'enabled_filter' => '[data-test-criterion-enabled]', 'filter' => '[data-test-filter]', 'filters_form' => '[data-test-filters-form]', 'filters_toggle' => '.accordion-button', + 'page_button' => '[data-test-page="%page%"]', 'table' => '.table', ]); } diff --git a/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php b/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php index 09fc8e3fc2..c4e39afdf5 100644 --- a/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/PaymentMethod/CreatePage.php @@ -33,11 +33,6 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface ); } - public function cancelChanges(): void - { - $this->getElement('cancel_button')->click(); - } - public function checkChannel(string $channelName): void { $this->getDocument()->checkField($channelName); @@ -105,7 +100,6 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'cancel_button' => '[data-test-cancel-changes-button]', 'code' => '#sylius_admin_payment_method_code', 'enabled' => '#sylius_admin_payment_method_enabled', 'gateway_name' => '#sylius_admin_payment_method_gatewayConfig_gatewayName', diff --git a/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php b/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php index a3d3245c91..1177e046d9 100644 --- a/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/CreateSimpleProductPage.php @@ -65,11 +65,6 @@ class CreateSimpleProductPage extends BaseCreatePage implements CreateSimpleProd $this->getElement('channel', ['%channel_code%' => $channelCode])->check(); } - public function cancelChanges(): void - { - $this->getElement('cancel_button')->click(); - } - private function changeTab(string $tabName): void { if (DriverHelper::isNotJavascript($this->getDriver())) { diff --git a/src/Sylius/Behat/Page/Admin/Product/IndexPage.php b/src/Sylius/Behat/Page/Admin/Product/IndexPage.php index b6c58330b7..10ddd5b1ce 100644 --- a/src/Sylius/Behat/Page/Admin/Product/IndexPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/IndexPage.php @@ -84,11 +84,6 @@ class IndexPage extends CrudIndexPage implements IndexPageInterface $field->find('css', '[data-test-show-action="Details"]')->click(); } - public function goToPage(int $page): void - { - $this->getElement('pagination_button', ['%page%' => $page])->click(); - } - public function checkFirstProductHasDataAttribute(string $attributeName): bool { return $this->getElement('first_product')->find('css', sprintf('[%s]', $attributeName)) !== null; @@ -99,11 +94,6 @@ class IndexPage extends CrudIndexPage implements IndexPageInterface return $this->getElement('last_product')->find('css', sprintf('[%s]', $attributeName)) !== null; } - public function getPageNumber(): int - { - return (int) $this->getElement('page_number')->getText(); - } - /** @return array */ protected function getDefinedElements(): array { @@ -113,9 +103,6 @@ class IndexPage extends CrudIndexPage implements IndexPageInterface 'first_product' => '.table > tbody > tr:first-child', 'last_product' => '.table > tbody > tr:last-child', 'main_taxon_filter' => '#criteria_main_taxon', - 'page_number' => '.sylius-grid-nav__pagination .active', - 'pagination_button' => '.sylius-grid-nav__pagination a.item:contains("%page%")', - 'pagination_buttons' => '.sylius-grid-nav__pagination', 'taxon_filter' => '#criteria_taxon', ]); } From 4fa37cb0f0379dec4355aeed66624a1f8d119e44 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Tue, 23 Jul 2024 15:07:36 +0200 Subject: [PATCH 11/14] [Admin] Render pagination and enabled filter test attributes --- .../templates/shared/grid/filter/boolean.html.twig | 2 +- .../Bundle/AdminBundle/templates/shared/pagerfanta.html.twig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Sylius/Bundle/AdminBundle/templates/shared/grid/filter/boolean.html.twig b/src/Sylius/Bundle/AdminBundle/templates/shared/grid/filter/boolean.html.twig index 4596454549..4dafffafb5 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/shared/grid/filter/boolean.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/shared/grid/filter/boolean.html.twig @@ -1,3 +1,3 @@ {% form_theme form '@SyliusAdmin/shared/form_theme.html.twig' %} -{{ form_row(form, {'label': filter.label}) }} +{{ form_row(form, sylius_test_form_attribute('criterion-enabled')|sylius_merge_recursive({'label': filter.label})) }} diff --git a/src/Sylius/Bundle/AdminBundle/templates/shared/pagerfanta.html.twig b/src/Sylius/Bundle/AdminBundle/templates/shared/pagerfanta.html.twig index 4dd000c4c5..aabd1bb62e 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/shared/pagerfanta.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/shared/pagerfanta.html.twig @@ -7,11 +7,11 @@ {%- endblock pager_widget -%} {%- block page_link -%} -
  • {{- page -}}
  • +
  • {{- page -}}
  • {%- endblock page_link -%} {%- block current_page_link -%} -
  • {{- page -}}
  • +
  • {{- page -}}
  • {%- endblock current_page_link -%} {%- block previous_page_link -%} From 257d91acaf773c823c2971a4e6367b33aadf1b0a Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Wed, 31 Jul 2024 21:30:17 +0200 Subject: [PATCH 12/14] [Behat] Use test attribute to retrieve order notes --- .../Behat/Page/Admin/Order/ShowPage.php | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Sylius/Behat/Page/Admin/Order/ShowPage.php b/src/Sylius/Behat/Page/Admin/Order/ShowPage.php index d318e7ebbb..37b60c9a9f 100644 --- a/src/Sylius/Behat/Page/Admin/Order/ShowPage.php +++ b/src/Sylius/Behat/Page/Admin/Order/ShowPage.php @@ -27,7 +27,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface Session $session, $minkParameters, RouterInterface $router, - private TableAccessorInterface $tableAccessor, + private readonly TableAccessorInterface $tableAccessor, ) { parent::__construct($session, $minkParameters, $router); } @@ -314,9 +314,9 @@ class ShowPage extends SymfonyPage implements ShowPageInterface public function hasNote(string $note): bool { - $orderNotesElement = $this->getElement('order_notes'); + $notes = $this->getElement('notes'); - return $orderNotesElement->getText() === $note; + return $notes->getText() === $note; } public function hasShippingProvinceName(string $provinceName): bool @@ -388,6 +388,9 @@ class ShowPage extends SymfonyPage implements ShowPageInterface return $this->getElement('shipment_shipped_at_date')->getText(); } + /** + * @return array + */ protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ @@ -398,22 +401,22 @@ class ShowPage extends SymfonyPage implements ShowPageInterface 'ip_address' => '#ipAddress', 'item' => '[data-test-item="%name%"]', 'items_total' => '[data-test-items-total]', - 'order_notes' => '#sylius-order-notes', + 'notes' => '[data-test-notes]', 'order_payment_state' => '[data-test-order-payment-state]', 'order_shipping_state' => '[data-test-order-shipping-state]', 'order_state' => '[data-test-order-state]', 'order_total' => '[data-test-order-total]', - 'payments' => '[data-test-payments]', 'payment_complete' => '[data-test-complete-payment="%paymentId%"]', 'payment_refund' => '[data-test-refund-payment="%paymentId%"]', + 'payments' => '[data-test-payments]', 'promotion' => '[data-test-promotion="%name%"]', 'promotion_total' => '[data-test-promotion-total]', 'resend_order_confirmation_email' => '[data-test-resend-order-confirmation-email]', 'resend_shipment_confirmation_email' => '[data-test-resend-shipment-confirmation-email]', - 'shipment_shipped_at_date' => '[data-test-shipments] [data-test-shipped-at-date]', - 'shipments' => '[data-test-shipments]', - 'shipment_tracking' => '[data-test-shipment-tracking]', 'shipment_ship_button' => '[data-test-shipment-ship-button]', + 'shipment_shipped_at_date' => '[data-test-shipments] [data-test-shipped-at-date]', + 'shipment_tracking' => '[data-test-shipment-tracking]', + 'shipments' => '[data-test-shipments]', 'shipping' => '[data-test-shipping="%name%"]', 'shipping_address' => '[data-test-shipping-address]', 'shipping_adjustment_name' => '#shipping-adjustment-label', @@ -426,11 +429,6 @@ class ShowPage extends SymfonyPage implements ShowPageInterface ]); } - protected function getTableAccessor(): TableAccessorInterface - { - return $this->tableAccessor; - } - protected function hasAddress(string $elementText, string $customerName, string $street, string $postcode, string $city, string $countryName): bool { return From d8fd9e1db6f66c57afee15856f7641165cd2d27c Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Wed, 31 Jul 2024 21:31:22 +0200 Subject: [PATCH 13/14] [Admin] Add missing order notes information --- .../config/app/twig_hooks/order/show.yaml | 2 ++ .../show/content/sections/general/notes.html.twig | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/notes.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/order/show.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/order/show.yaml index 499012917e..142fe7532f 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/order/show.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/order/show.yaml @@ -174,6 +174,8 @@ twig_hooks: template: '@SyliusAdmin/order/show/content/sections/general/language.html.twig' channel: template: '@SyliusAdmin/order/show/content/sections/general/channel.html.twig' + notes: + template: '@SyliusAdmin/order/show/content/sections/general/notes.html.twig' 'sylius_admin.order.show.content.sections.customer': full_name: diff --git a/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/notes.html.twig b/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/notes.html.twig new file mode 100644 index 0000000000..5be962b24e --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/order/show/content/sections/general/notes.html.twig @@ -0,0 +1,14 @@ +{% set order = hookable_metadata.context.resource %} + +
    +
    + {{ 'sylius.ui.notes'|trans }}: +
    +
    + {% if order.notes is not null %} + {{ order.notes }} + {% else %} + - + {% endif %} +
    +
    From 7826af04c84153416d2bf0c336524aab4e273508 Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Thu, 1 Aug 2024 12:37:57 +0200 Subject: [PATCH 14/14] [Admin] Configure and use anonymous view in store component --- .../Resources/config/app/twig_hooks/product/show.yaml | 4 +++- .../Resources/config/app/twig_hooks/product/update.yaml | 4 +++- .../config/app/twig_hooks/product_variant/update.yaml | 5 +++-- .../actions => shared/components}/view_in_store.html.twig | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) rename src/Sylius/Bundle/AdminBundle/templates/{product/common/header/title_block/actions => shared/components}/view_in_store.html.twig (96%) diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/show.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/show.yaml index 3ce91e31ce..74e52a2426 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/show.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/show.yaml @@ -14,7 +14,9 @@ twig_hooks: edit: template: '@SyliusAdmin/shared/crud/show/content/header/title_block/actions/edit.html.twig' view_in_store: - template: '@SyliusAdmin/product/common/header/title_block/actions/view_in_store.html.twig' + component: 'sylius_admin:view_in_store' + props: + product: '@=_context.resource' 'sylius_admin.product.show.content.page_body': general: diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/update.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/update.yaml index 77eeae11e3..5862495e1d 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/update.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product/update.yaml @@ -15,7 +15,9 @@ twig_hooks: 'sylius_admin.product.update.content.header.title_block.actions': view_in_store: - template: '@SyliusAdmin/product/common/header/title_block/actions/view_in_store.html.twig' + component: 'sylius_admin:view_in_store' + props: + product: '@=_context.resource' manage_variants: template: '@SyliusAdmin/product/common/header/title_block/actions/manage_variants.html.twig' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml index 88b9a96753..d4405c2b0d 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/product_variant/update.yaml @@ -14,8 +14,9 @@ twig_hooks: price_history: template: '@SyliusAdmin/product_variant/form/content/update/header/actions/price_history.html.twig' view_in_store: - template: '@SyliusAdmin/product/common/header/title_block/actions/view_in_store.html.twig' - + component: 'sylius_admin:view_in_store' + props: + product: '@=_context.resource.getProduct()' 'sylius_admin.product_variant.update.content.form': side_navigation: diff --git a/src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig b/src/Sylius/Bundle/AdminBundle/templates/shared/components/view_in_store.html.twig similarity index 96% rename from src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig rename to src/Sylius/Bundle/AdminBundle/templates/shared/components/view_in_store.html.twig index f4f3b7c110..4f25340347 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/product/common/header/title_block/actions/view_in_store.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/shared/components/view_in_store.html.twig @@ -1,7 +1,6 @@ {% if sylius_bundle_loaded_checker('SyliusShopBundle') %} {% from '@SyliusAdmin/shared/helper/icon.html.twig' import icon %} - {% set product = hookable_metadata.context.resource.product|default(hookable_metadata.context.resource) %} {% set enabled_channels = product.channels|filter(channel => channel.enabled == true) %} {% if not product.enabled or enabled_channels|length < 1 %}