mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
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:
commit
db561c9b1f
4 changed files with 20 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue