Skip to content

Commit

Permalink
[Admin][Product][Inventory] Enable behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojdylak authored and GSadee committed May 14, 2024
1 parent 8b6d2b1 commit 32fcf43
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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
When I view variants of the product "Iron Maiden T-Shirt"
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ 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
And I save my changes
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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,24 @@ public function productShouldExistInTheProductCatalog(ProductVariantInterface $p
/**
* @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),
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingProductsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1288,15 +1288,15 @@ public function iShouldBeOnTheVariantGenerationPageForThisProduct(ProductInterfa
*/
public function iShouldSeeInventoryOfThisProduct(): void
{
Assert::true($this->updateSimpleProductPage->hasInventoryTab());
Assert::true($this->updateSimpleProductPage->hasTab('inventory'));
}

/**
* @Then I should not see inventory of this product
*/
public function iShouldNotSeeInventoryOfThisProduct(): void
{
Assert::false($this->updateConfigurableProductPage->hasInventoryTab());
Assert::false($this->updateConfigurableProductPage->hasTab('inventory'));
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Sylius/Behat/Page/Admin/Product/FormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public function selectOption(string $optionName): void
$this->autocompleteHelper->selectByName($this->getDriver(), $productOptionsAutocomplete->getXpath(), $optionName);
}

public function hasTab(string $name): bool
{
return $this->hasElement('side_navigation_tab', ['%name%' => $name]);
}

/*
* Tabs management
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ public function goToVariantGeneration(): void
$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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ public function goToVariantCreation(): void;

public function goToVariantGeneration(): void;

public function hasInventoryTab(): bool;
public function hasTab(string $name): bool;
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,6 @@ public function goToVariantGeneration(): void
$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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function goToVariantCreation(): void;

public function goToVariantGeneration(): void;

public function hasInventoryTab(): bool;
public function hasTab(string $name): bool;

public function getShowProductInSingleChannelUrl(): string;

Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Page/Admin/ProductVariant/IndexPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function countItemsWithNoName(): int
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]',
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% if data.isTracked %}
<span class="onHand" data-product-variant-id="{{ data.id }}">{{ data.onHand }}</span> {{ 'sylius.ui.available_on_hand'|trans }}
<span class="onHand" data-product-variant-id="{{ data.id }}" {{ sylius_test_html_attribute('on-hand') }}>{{ data.onHand }}</span> {{ 'sylius.ui.available_on_hand'|trans }}
{% if data.onHold > 0 %}
<span class="onHold" data-product-variant-id="{{ data.id }}">{{ data.onHold }}</span> {{ 'sylius.ui.reserved'|trans }}
<span class="onHold" data-product-variant-id="{{ data.id }}" {{ sylius_test_html_attribute('on-hold') }}>{{ data.onHold }}</span> {{ 'sylius.ui.reserved'|trans }}
{% endif %}
{% else %}
{{ 'sylius.ui.not_tracked'|trans }}
Expand Down

0 comments on commit 32fcf43

Please sign in to comment.