From 32fcf432a2ac842ee6e3beedd3adca06ad324741 Mon Sep 17 00:00:00 2001 From: Wojdylak Date: Tue, 14 May 2024 09:39:04 +0200 Subject: [PATCH] [Admin][Product][Inventory] Enable behat tests --- ...inventory_units_during_checkout_process.feature | 4 ++-- ...ventory_tab_on_simple_product_edit_page.feature | 4 ++-- ...asing_invetory_below_on_hold_validation.feature | 6 +++--- ...ry_is_back_in_stock_on_order_cancelling.feature | 14 +++++++------- ..._with_specify_quantity_of_items_on_hand.feature | 4 ++-- .../Ui/Admin/BrowsingProductVariantsContext.php | 8 ++++---- .../Context/Ui/Admin/ManagingProductsContext.php | 4 ++-- src/Sylius/Behat/Page/Admin/Product/FormTrait.php | 5 +++++ .../Product/UpdateConfigurableProductPage.php | 5 ----- .../UpdateConfigurableProductPageInterface.php | 2 +- .../Page/Admin/Product/UpdateSimpleProductPage.php | 5 ----- .../Product/UpdateSimpleProductPageInterface.php | 2 +- .../Behat/Page/Admin/ProductVariant/IndexPage.php | 4 ++-- .../displaying_inventory_on_edit_product_page.yml | 2 +- .../product_variant/grid/field/inventory.html.twig | 4 ++-- 15 files changed, 34 insertions(+), 39 deletions(-) diff --git a/features/admin/inventory/checkout_inventory/holding_inventory_units_during_checkout_process.feature b/features/admin/inventory/checkout_inventory/holding_inventory_units_during_checkout_process.feature index 15a1e4f870..d1cfd0a1cb 100644 --- a/features/admin/inventory/checkout_inventory/holding_inventory_units_during_checkout_process.feature +++ b/features/admin/inventory/checkout_inventory/holding_inventory_units_during_checkout_process.feature @@ -14,7 +14,7 @@ Feature: Holding inventory units during checkout And there is a customer "sylius@example.com" that placed an order "#00000022" And I am logged in as an administrator - @todo @ui @api + @ui @api Scenario: Holding inventory units Given the customer bought 3 "Iron Maiden T-Shirt" products And the customer chose "Free" shipping method to "United States" with "Offline" payment @@ -22,7 +22,7 @@ Feature: Holding inventory units during checkout Then 3 units of this product should be on hold And 5 units of this product should be on hand - @todo @ui @api + @ui @api Scenario: Release hold units after order has been paid Given the customer bought 3 "Iron Maiden T-Shirt" products And the customer chose "Free" shipping method to "United States" with "Offline" payment diff --git a/features/admin/inventory/displaying_inventory_tab_on_simple_product_edit_page.feature b/features/admin/inventory/displaying_inventory_tab_on_simple_product_edit_page.feature index 2587e857f0..18f9d0faf7 100644 --- a/features/admin/inventory/displaying_inventory_tab_on_simple_product_edit_page.feature +++ b/features/admin/inventory/displaying_inventory_tab_on_simple_product_edit_page.feature @@ -10,12 +10,12 @@ Feature: Displaying inventory tab on simple product edit page And the store has a "PHP T-Shirt" configurable product And I am logged in as an administrator - @todo @ui @no-api + @ui @no-api Scenario: Seeing inventory on simple product edit page When I want to modify the "PHP Mug" product Then I should see inventory of this product - @todo @ui @no-api + @ui @no-api Scenario: Not seeing inventory on configurable product edit page When I want to modify the "PHP T-Shirt" product Then I should not see inventory of this product diff --git a/features/admin/inventory/managing_inventory/decreasing_invetory_below_on_hold_validation.feature b/features/admin/inventory/managing_inventory/decreasing_invetory_below_on_hold_validation.feature index c33b8aa6f4..bfd87d11b5 100644 --- a/features/admin/inventory/managing_inventory/decreasing_invetory_below_on_hold_validation.feature +++ b/features/admin/inventory/managing_inventory/decreasing_invetory_below_on_hold_validation.feature @@ -17,7 +17,7 @@ Feature: Validation of decreasing inventory below on hold validation And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment And I am logged in as an administrator - @todo @ui @api + @ui @api Scenario: Decreasing inventory when order was placed When I want to modify the "Wyborowa Vodka Exquisite" product variant And I change its quantity of inventory to 2 @@ -25,7 +25,7 @@ Feature: Validation of decreasing inventory below on hold validation Then I should be notified that on hand quantity must be greater than the number of on hold units And this variant should have a 5 item currently in stock - @todo @ui @api + @ui @api Scenario: Decreasing inventory when order was cancelled Given the order "#00000023" was cancelled When I want to modify the "Wyborowa Vodka Exquisite" product variant @@ -34,7 +34,7 @@ Feature: Validation of decreasing inventory below on hold validation Then I should be notified that it has been successfully edited And this variant should have a 2 item currently in stock - @todo @ui @api + @ui @api Scenario: Decreasing inventory when order was paid Given the order "#00000023" is already paid When I want to modify the "Wyborowa Vodka Exquisite" product variant diff --git a/features/admin/inventory/managing_inventory/verify_reserved_inventory_is_back_in_stock_on_order_cancelling.feature b/features/admin/inventory/managing_inventory/verify_reserved_inventory_is_back_in_stock_on_order_cancelling.feature index 53f8cb047e..c99f2d795f 100644 --- a/features/admin/inventory/managing_inventory/verify_reserved_inventory_is_back_in_stock_on_order_cancelling.feature +++ b/features/admin/inventory/managing_inventory/verify_reserved_inventory_is_back_in_stock_on_order_cancelling.feature @@ -18,7 +18,7 @@ Feature: Inventory releasing on order cancellation And the store allows paying with "Cash on Delivery" And I am logged in as an administrator - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory is back in stock after cancellation of a new order Given there is a customer "john.doe@gmail.com" that placed an order "#00000022" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -28,7 +28,7 @@ Feature: Inventory releasing on order cancellation Then the variant "Green" should have 5 items on hand And the "Green" variant should have 0 items on hold - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory and quantity of product's items is back in stock after cancellation of paid order Given there is a customer "john.doe@gmail.com" that placed an order "#00000022" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -39,7 +39,7 @@ Feature: Inventory releasing on order cancellation Then the variant "Green" should have 5 items on hand And the "Green" variant should have 0 items on hold - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory is back in stock after cancellation of a new order with two variants of product Given there is a customer "john.doe@gmail.com" that placed an order "#00000023" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -52,7 +52,7 @@ Feature: Inventory releasing on order cancellation And the variant "Red" should have 5 items on hand And the "Red" variant should have 0 items on hold - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory and quantity of product's items is back in stock after cancellation of paid order with two variants of product Given there is a customer "john.doe@gmail.com" that placed an order "#00000023" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -66,7 +66,7 @@ Feature: Inventory releasing on order cancellation And the variant "Red" should have 5 items on hand And the "Red" variant should have 0 items on hold - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory is back in stock after cancellation of a new order with two variants of different products Given there is a customer "john.doe@gmail.com" that placed an order "#00000024" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -78,7 +78,7 @@ Feature: Inventory releasing on order cancellation And the "Yellow" variant of "Skirt watermelon" product should have 5 items on hand And the "Yellow" variant of "Skirt watermelon" product should have 0 items on hold - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory and quantity of product's items is back in stock after cancellation of paid order with two variants of different products Given there is a customer "john.doe@gmail.com" that placed an order "#00000024" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -91,7 +91,7 @@ Feature: Inventory releasing on order cancellation And the "Yellow" variant of "Skirt watermelon" product should have 5 items on hand And the "Yellow" variant of "Skirt watermelon" product should have 0 items on hold - @todo @ui @api + @ui @api Scenario: Verify the reserved inventory and quantity of product's items is back in stock after cancellation of a refunded order Given there is a customer "john.doe@gmail.com" that placed an order "#00000022" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" diff --git a/features/admin/inventory/managing_inventory/viewing_product_variant_with_specify_quantity_of_items_on_hand.feature b/features/admin/inventory/managing_inventory/viewing_product_variant_with_specify_quantity_of_items_on_hand.feature index fd86ad008c..a9313f2682 100644 --- a/features/admin/inventory/managing_inventory/viewing_product_variant_with_specify_quantity_of_items_on_hand.feature +++ b/features/admin/inventory/managing_inventory/viewing_product_variant_with_specify_quantity_of_items_on_hand.feature @@ -15,7 +15,7 @@ Feature: Seeing product's variant with specify quantity of items on hand And the store allows paying with "Cash on Delivery" And I am logged in as an administrator - @todo @ui @api + @ui @api Scenario: Seeing decreased quantity of product's items in selected variant after order payment Given there is a customer "lucy@teamlucifer.com" that placed an order "#00000666" And the customer bought 3 units of "Green" variant of product "T-Shirt banana" @@ -25,7 +25,7 @@ Feature: Seeing product's variant with specify quantity of items on hand When I view all variants of the product "T-Shirt banana" Then the variant "Green" should have 2 items on hand - @todo @ui @api + @ui @api Scenario: Seeing decreased quantity of product's items from different variants after order payment Given there is a customer "lucy@teamlucifer.com" that placed an order "#00000666" And the customer bought 3 units of "Yellow" variant of product "T-Shirt banana" diff --git a/src/Sylius/Behat/Context/Ui/Admin/BrowsingProductVariantsContext.php b/src/Sylius/Behat/Context/Ui/Admin/BrowsingProductVariantsContext.php index a004116f25..64b2403467 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/BrowsingProductVariantsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/BrowsingProductVariantsContext.php @@ -133,24 +133,24 @@ final class BrowsingProductVariantsContext implements Context /** * @Then /^the variant "([^"]+)" should have (\d+) items on hand$/ */ - public function thisVariantShouldHaveItemsOnHand($productVariantName, $quantity) + public function thisVariantShouldHaveItemsOnHand($productVariantName, $quantity): void { Assert::true($this->indexPage->isSingleResourceWithSpecificElementOnPage( ['name' => $productVariantName], - sprintf('td > div.ui.label:contains("%s")', $quantity), + sprintf('[data-test-on-hand]:contains("%s")', $quantity), )); } /** * @Then /^the "([^"]+)" variant of ("[^"]+" product) should have (\d+) items on hand$/ */ - public function theVariantOfProductShouldHaveItemsOnHand($productVariantName, ProductInterface $product, $quantity) + public function theVariantOfProductShouldHaveItemsOnHand($productVariantName, ProductInterface $product, $quantity): void { $this->indexPage->open(['productId' => $product->getId()]); Assert::true($this->indexPage->isSingleResourceWithSpecificElementOnPage( ['name' => $productVariantName], - sprintf('td > div.ui.label:contains("%s")', $quantity), + sprintf('[data-test-on-hand]:contains("%s")', $quantity), )); } diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php index fe9a2e4464..8f7099fbb5 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php @@ -1288,7 +1288,7 @@ final class ManagingProductsContext implements Context */ public function iShouldSeeInventoryOfThisProduct(): void { - Assert::true($this->updateSimpleProductPage->hasInventoryTab()); + Assert::true($this->updateSimpleProductPage->hasTab('inventory')); } /** @@ -1296,7 +1296,7 @@ final class ManagingProductsContext implements Context */ public function iShouldNotSeeInventoryOfThisProduct(): void { - Assert::false($this->updateConfigurableProductPage->hasInventoryTab()); + Assert::false($this->updateConfigurableProductPage->hasTab('inventory')); } /** diff --git a/src/Sylius/Behat/Page/Admin/Product/FormTrait.php b/src/Sylius/Behat/Page/Admin/Product/FormTrait.php index 7696e6bc85..237dfa216a 100644 --- a/src/Sylius/Behat/Page/Admin/Product/FormTrait.php +++ b/src/Sylius/Behat/Page/Admin/Product/FormTrait.php @@ -118,6 +118,11 @@ trait FormTrait $this->autocompleteHelper->selectByName($this->getDriver(), $productOptionsAutocomplete->getXpath(), $optionName); } + public function hasTab(string $name): bool + { + return $this->hasElement('side_navigation_tab', ['%name%' => $name]); + } + /* * Tabs management */ diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php index c2869492aa..cb2f439adb 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPage.php @@ -136,11 +136,6 @@ class UpdateConfigurableProductPage extends BaseUpdatePage implements UpdateConf $this->getDocument()->clickLink('Generate'); } - public function hasInventoryTab(): bool - { - return null !== $this->getDocument()->find('css', '.tab > h3:contains("Inventory")'); - } - protected function getCodeElement(): NodeElement { return $this->getElement('code'); diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPageInterface.php b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPageInterface.php index 4819062855..9075890e36 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateConfigurableProductPageInterface.php @@ -63,5 +63,5 @@ interface UpdateConfigurableProductPageInterface extends UpdatePageInterface public function goToVariantGeneration(): void; - public function hasInventoryTab(): bool; + public function hasTab(string $name): bool; } diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php index 74ab095c7c..c74882e056 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPage.php @@ -283,11 +283,6 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd $this->getDocument()->clickLink('Generate'); } - public function hasInventoryTab(): bool - { - return null !== $this->getDocument()->find('css', '.tab > h3:contains("Inventory")'); - } - public function getShowProductInSingleChannelUrl(): string { return $this->getElement('show_product_single_button')->getAttribute('href'); diff --git a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php index 6df873b5df..6e61960919 100644 --- a/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Product/UpdateSimpleProductPageInterface.php @@ -115,7 +115,7 @@ interface UpdateSimpleProductPageInterface extends BaseUpdatePageInterface public function goToVariantGeneration(): void; - public function hasInventoryTab(): bool; + public function hasTab(string $name): bool; public function getShowProductInSingleChannelUrl(): string; diff --git a/src/Sylius/Behat/Page/Admin/ProductVariant/IndexPage.php b/src/Sylius/Behat/Page/Admin/ProductVariant/IndexPage.php index 5e589b143e..666ab50e5d 100644 --- a/src/Sylius/Behat/Page/Admin/ProductVariant/IndexPage.php +++ b/src/Sylius/Behat/Page/Admin/ProductVariant/IndexPage.php @@ -61,8 +61,8 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface protected function getDefinedElements(): array { return array_merge(parent::getDefinedElements(), [ - 'on_hand_quantity' => '.onHand[data-product-variant-id="%id%"]', - 'on_hold_quantity' => '.onHold[data-product-variant-id="%id%"]', + 'on_hand_quantity' => '[data-test-on-hand][data-product-variant-id="%id%"]', + 'on_hold_quantity' => '[data-test-on-hold][data-product-variant-id="%id%"]', 'save_configuration_button' => '[data-test-save-configuration-button]', ]); } diff --git a/src/Sylius/Behat/Resources/config/suites/ui/inventory/displaying_inventory_on_edit_product_page.yml b/src/Sylius/Behat/Resources/config/suites/ui/inventory/displaying_inventory_on_edit_product_page.yml index cd5d323ab3..8cdfaa3fb3 100644 --- a/src/Sylius/Behat/Resources/config/suites/ui/inventory/displaying_inventory_on_edit_product_page.yml +++ b/src/Sylius/Behat/Resources/config/suites/ui/inventory/displaying_inventory_on_edit_product_page.yml @@ -3,7 +3,7 @@ default: suites: - ui_managing_inventory: + ui_inventory_on_product_page: contexts: - sylius.behat.context.hook.doctrine_orm - sylius.behat.context.hook.session diff --git a/src/Sylius/Bundle/AdminBundle/templates/product_variant/grid/field/inventory.html.twig b/src/Sylius/Bundle/AdminBundle/templates/product_variant/grid/field/inventory.html.twig index 8b1c48ef4f..5192a4bd58 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/product_variant/grid/field/inventory.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/product_variant/grid/field/inventory.html.twig @@ -1,7 +1,7 @@ {% if data.isTracked %} - {{ data.onHand }} {{ 'sylius.ui.available_on_hand'|trans }} + {{ data.onHand }} {{ 'sylius.ui.available_on_hand'|trans }} {% if data.onHold > 0 %} - {{ data.onHold }} {{ 'sylius.ui.reserved'|trans }} + {{ data.onHold }} {{ 'sylius.ui.reserved'|trans }} {% endif %} {% else %} {{ 'sylius.ui.not_tracked'|trans }}