diff --git a/features/promotion/applying_promotion_rules/reapplying_promotion_on_cart_change.feature b/features/promotion/applying_promotion_rules/reapplying_promotion_on_cart_change.feature index fed0da67a3..8424ba9d77 100644 --- a/features/promotion/applying_promotion_rules/reapplying_promotion_on_cart_change.feature +++ b/features/promotion/applying_promotion_rules/reapplying_promotion_on_cart_change.feature @@ -10,7 +10,7 @@ Feature: Reapplying promotion on cart change And there is a promotion "Holiday promotion" And I am a logged in customer - @ui + @ui @api Scenario: Not receiving discount on shipping after removing last item from cart Given the store has "DHL" shipping method with "$10.00" fee And the promotion gives "100%" discount on shipping to every order @@ -21,7 +21,7 @@ Feature: Reapplying promotion on cart change And there should be no shipping fee And there should be no discount - @ui + @ui @api Scenario: Receiving discount on shipping after shipping method change Given the store has "DHL" shipping method with "$10.00" fee And the store has "FedEx" shipping method with "$30.00" fee @@ -32,7 +32,7 @@ Feature: Reapplying promotion on cart change Then my cart total should be "$100.00" And my cart shipping should be for Free - @ui + @ui @api Scenario: Receiving discount after removing an item from the cart and then adding another one Given the store has a product "Symfony T-Shirt" priced at "$150.00" And the promotion gives "$10.00" discount to every order @@ -42,18 +42,18 @@ Feature: Reapplying promotion on cart change Then my cart total should be "$140.00" And my discount should be "-$10.00" - @ui + @ui @api Scenario: Not receiving discount when cart does not meet the required total value after removing an item Given the promotion gives "$10.00" discount to every order with items total at least "$120.00" And I have 2 products "PHP T-Shirt" in the cart - When I change "PHP T-Shirt" quantity to 1 + When I change product "PHP T-Shirt" quantity to 1 Then my cart total should be "$100.00" And there should be no discount - @ui + @ui @api Scenario: Not receiving discount when cart does not meet the required quantity after removing an item Given the promotion gives "$10.00" discount to every order with quantity at least 3 And I have 3 products "PHP T-Shirt" in the cart - When I change "PHP T-Shirt" quantity to 1 + When I change product "PHP T-Shirt" quantity to 1 Then my cart total should be "$100.00" And there should be no discount diff --git a/src/Sylius/Behat/Context/Api/Shop/CartContext.php b/src/Sylius/Behat/Context/Api/Shop/CartContext.php index 14c3361cd5..9780813744 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CartContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CartContext.php @@ -184,19 +184,24 @@ final class CartContext implements Context } /** + * @Given /^I change (product "[^"]+") quantity to (\d+)$/ * @When /^I change (product "[^"]+") quantity to (\d+) in my (cart)$/ - * @Given I change :productName quantity to :quantity * @When /^the (?:visitor|customer) change (product "[^"]+") quantity to (\d+) in his (cart)$/ * @When /^the visitor try to change (product "[^"]+") quantity to (\d+) in the customer (cart)$/ * @When /^I try to change (product "[^"]+") quantity to (\d+) in my (cart)$/ */ - public function iChangeQuantityToInMyCart(ProductInterface $product, int $quantity, string $tokenValue): void + public function iChangeQuantityToInMyCart(ProductInterface $product, int $quantity, ?string $tokenValue = null): void { + if (null === $tokenValue && $this->sharedStorage->has('cart_token')) { + $tokenValue = $this->sharedStorage->get('cart_token'); + } + $itemResponse = $this->getOrderItemResponseFromProductInCart($product, $tokenValue); $this->changeQuantityOfOrderItem((string) $itemResponse['id'], $quantity, $tokenValue); } /** + * @Given /^I removed (product "[^"]+") from the (cart)$/ * @When /^I remove (product "[^"]+") from the (cart)$/ */ public function iRemoveProductFromTheCart(ProductInterface $product, string $tokenValue): void @@ -362,6 +367,7 @@ final class CartContext implements Context /** * @Then /^my (cart) should be empty$/ + * @Then /^(cart) should be empty with no value$/ */ public function myCartShouldBeEmpty(string $tokenValue): void { @@ -686,6 +692,8 @@ final class CartContext implements Context * @Then /^my cart shipping total should be ("[^"]+")$/ * @Then I should not see shipping total for my cart * @Then /^my cart estimated shipping cost should be ("[^"]+")$/ + * @Then there should be no shipping fee + * @Then my cart shipping should be for Free */ public function myCartShippingFeeShouldBe(int $shippingTotal = 0): void { diff --git a/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php b/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php index 9dbfca5145..1947646fa1 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php @@ -377,6 +377,8 @@ final class CheckoutContext implements Context * @When /^the visitor try to proceed with ("[^"]+" shipping method) in the customer cart$/ * @When I try to change shipping method to :shippingMethod * @Given I proceed selecting :shippingMethod shipping method + * @Given I chose :shippingMethod shipping method + * @When I change shipping method to :shippingMethod */ public function iProceededWithShippingMethod(ShippingMethodInterface $shippingMethod): void { diff --git a/src/Sylius/Behat/Context/Ui/Shop/CartContext.php b/src/Sylius/Behat/Context/Ui/Shop/CartContext.php index efd647a85c..d2df424b46 100644 --- a/src/Sylius/Behat/Context/Ui/Shop/CartContext.php +++ b/src/Sylius/Behat/Context/Ui/Shop/CartContext.php @@ -103,6 +103,7 @@ final class CartContext implements Context /** * @Given I change :productName quantity to :quantity + * @Given I change product :productName quantity to :quantity * @Given I change product :productName quantity to :quantity in my cart */ public function iChangeQuantityTo($productName, $quantity)