Skip to content

Commit

Permalink
[Behat] Add scenario about seeing shipping promotion on order summary
Browse files Browse the repository at this point in the history
  • Loading branch information
tuka217 committed Jan 9, 2017
1 parent e78af09 commit e0adcf2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
@@ -0,0 +1,23 @@
@checkout
Feature: Seeing shipping discount on order summary
In order to be certain that the shipping discount was applied to my order
As a Customer
I want to be able to see shipping promotion on the order summary

Background:
Given the store operates on a single channel in "United States"
And the store has a product "PHP T-Shirt" priced at "$19.99"
And the store has "DHL" shipping method with "$50.00" fee
And there is a promotion "Holiday promotion"
And the promotion gives "10%" discount on shipping to every order
And the store allows paying offline
And I am a logged in customer

@ui
Scenario: Seeing order shipping discount on the order summary page
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I proceed with "DHL" shipping method and "Offline" payment
Then I should be on the checkout summary step
And "Holiday promotion" should be applied to my order shipping
8 changes: 8 additions & 0 deletions src/Sylius/Behat/Context/Ui/CheckoutContext.php
Expand Up @@ -908,6 +908,14 @@ public function shouldBeAppliedToMyOrder($promotionName)
);
}

/**
* @Then :promotionName should be applied to my order shipping
*/
public function shouldBeAppliedToMyOrderShipping($promotionName)
{
Assert::true($this->completePage->hasShippingPromotion($promotionName));
}

/**
* @Given my tax total should be :taxTotal
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Sylius/Behat/Page/Shop/Checkout/CompletePage.php
Expand Up @@ -183,6 +183,15 @@ public function hasPromotion($promotionName)
return false !== stripos($this->getElement('promotion_discounts')->getText(), $promotionName);
}

/**
* {@inheritdoc}
*/
public function hasShippingPromotion($promotionName)
{
return false !== stripos($this->getElement('promotion_shipping_discounts')->getText(), $promotionName);
}


/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -293,6 +302,7 @@ protected function getDefinedElements()
'payment_step_label' => '.steps a:contains("Payment")',
'product_row' => 'tbody tr:contains("%name%")',
'promotion_discounts' => '#promotion-discounts',
'promotion_shipping_discounts' => '#promotion-shipping-discounts',
'promotion_total' => '#promotion-total',
'shipping_address' => '#sylius-shipping-address',
'shipping_method' => '#sylius-shipping-method',
Expand Down
7 changes: 7 additions & 0 deletions src/Sylius/Behat/Page/Shop/Checkout/CompletePageInterface.php
Expand Up @@ -97,6 +97,13 @@ public function hasPromotionTotal($promotionTotal);
*/
public function hasPromotion($promotionName);

/**
* @param string $promotionName
*
* @return bool
*/
public function hasShippingPromotion($promotionName);

/**
* @param string $taxTotal
*
Expand Down

0 comments on commit e0adcf2

Please sign in to comment.