minor #14947 Cover reapplying promotion on cart changes scenarios in API (jakubtobiasz)

This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | n/a
| License         | MIT




Commits
-------

2f56278d9d Cover reapplying promotion on cart changes scenarios in API
This commit is contained in:
Kamil Grygierzec 2023-04-19 12:34:43 +02:00 committed by GitHub
commit db561c9b1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 9 deletions

View file

@ -10,7 +10,7 @@ Feature: Reapplying promotion on cart change
And there is a promotion "Holiday promotion" And there is a promotion "Holiday promotion"
And I am a logged in customer And I am a logged in customer
@ui @ui @api
Scenario: Not receiving discount on shipping after removing last item from cart Scenario: Not receiving discount on shipping after removing last item from cart
Given the store has "DHL" shipping method with "$10.00" fee Given the store has "DHL" shipping method with "$10.00" fee
And the promotion gives "100%" discount on shipping to every order 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 shipping fee
And there should be no discount And there should be no discount
@ui @ui @api
Scenario: Receiving discount on shipping after shipping method change Scenario: Receiving discount on shipping after shipping method change
Given the store has "DHL" shipping method with "$10.00" fee Given the store has "DHL" shipping method with "$10.00" fee
And the store has "FedEx" shipping method with "$30.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" Then my cart total should be "$100.00"
And my cart shipping should be for Free 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 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" Given the store has a product "Symfony T-Shirt" priced at "$150.00"
And the promotion gives "$10.00" discount to every order 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" Then my cart total should be "$140.00"
And my discount should be "-$10.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 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" 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 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" Then my cart total should be "$100.00"
And there should be no discount 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 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 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 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" Then my cart total should be "$100.00"
And there should be no discount And there should be no discount

View file

@ -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)$/ * @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|customer) change (product "[^"]+") quantity to (\d+) in his (cart)$/
* @When /^the visitor try to change (product "[^"]+") quantity to (\d+) in the customer (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)$/ * @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); $itemResponse = $this->getOrderItemResponseFromProductInCart($product, $tokenValue);
$this->changeQuantityOfOrderItem((string) $itemResponse['id'], $quantity, $tokenValue); $this->changeQuantityOfOrderItem((string) $itemResponse['id'], $quantity, $tokenValue);
} }
/** /**
* @Given /^I removed (product "[^"]+") from the (cart)$/
* @When /^I remove (product "[^"]+") from the (cart)$/ * @When /^I remove (product "[^"]+") from the (cart)$/
*/ */
public function iRemoveProductFromTheCart(ProductInterface $product, string $tokenValue): void public function iRemoveProductFromTheCart(ProductInterface $product, string $tokenValue): void
@ -362,6 +367,7 @@ final class CartContext implements Context
/** /**
* @Then /^my (cart) should be empty$/ * @Then /^my (cart) should be empty$/
* @Then /^(cart) should be empty with no value$/
*/ */
public function myCartShouldBeEmpty(string $tokenValue): void public function myCartShouldBeEmpty(string $tokenValue): void
{ {
@ -686,6 +692,8 @@ final class CartContext implements Context
* @Then /^my cart shipping total should be ("[^"]+")$/ * @Then /^my cart shipping total should be ("[^"]+")$/
* @Then I should not see shipping total for my cart * @Then I should not see shipping total for my cart
* @Then /^my cart estimated shipping cost should be ("[^"]+")$/ * @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 public function myCartShippingFeeShouldBe(int $shippingTotal = 0): void
{ {

View file

@ -377,6 +377,8 @@ final class CheckoutContext implements Context
* @When /^the visitor try to proceed with ("[^"]+" shipping method) in the customer cart$/ * @When /^the visitor try to proceed with ("[^"]+" shipping method) in the customer cart$/
* @When I try to change shipping method to :shippingMethod * @When I try to change shipping method to :shippingMethod
* @Given I proceed selecting :shippingMethod shipping method * @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 public function iProceededWithShippingMethod(ShippingMethodInterface $shippingMethod): void
{ {

View file

@ -103,6 +103,7 @@ final class CartContext implements Context
/** /**
* @Given I change :productName quantity to :quantity * @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 * @Given I change product :productName quantity to :quantity in my cart
*/ */
public function iChangeQuantityTo($productName, $quantity) public function iChangeQuantityTo($productName, $quantity)