Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@paying_for_order
Feature: Having good number of items in changing payment method page
In order to verify that I am changing the payment method of correct order
As a Customer
I want to see correct details about my order on changing the payment method page

Background:
Given the store operates on a single channel in "United States"
And there is a user "[email protected]" identified by "password123"
And the store allows paying "Offline"
And the store allows paying "Cash on delivery"
And the store has a product "PHP T-Shirt" priced at "$19.99"
And the store ships everywhere for free
And I am logged in as "[email protected]"

@ui
Scenario: Seeing correct quantity on payment retry page
Given I have added 2 products "PHP T-Shirt" to the cart
And I have proceeded selecting "Cash on delivery" payment method
And I have confirmed order
When I go to order details
Then I should see 2 as number of items
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ public function iShouldNotBeAbleToPay()
{
Assert::false($this->orderDetails->hasPayAction());
}

/**
* @Then I should see :quantity as number of items
*/
public function iShouldSeeAsNumberOfItems(int $quantity): void
{
Assert::same($this->orderDetails->getNumberOfItems(), $quantity);
}
}
12 changes: 12 additions & 0 deletions src/Sylius/Behat/Page/Shop/Order/ShowPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,25 @@ public function getRouteName()
return 'sylius_shop_order_show';
}

/**
* @inheritdoc
*/
public function getNumberOfItems(): int
{
$itemsText = trim($this->getElement('items_text')->getText());
$itemsTextWords = explode(' ', $itemsText);

return (int) $itemsTextWords[0];
}

/**
* {@inheritdoc}
*/
protected function getDefinedElements()
{
return array_merge(parent::getDefinedElements(), [
'instructions' => '#sylius-payment-method-instructions',
'items_text' => 'div.sub.header div.item:nth-child(3)',
'pay_link' => '#sylius-pay-link',
'payment_method' => '.item:contains("%name%") input',
'thank_you' => '#sylius-thank-you',
Expand Down
2 changes: 2 additions & 0 deletions src/Sylius/Behat/Page/Shop/Order/ShowPageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public function choosePaymentMethod($paymentMethodName);
* @return string[]
*/
public function getNotifications();

public function getNumberOfItems(): int;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{ money.convertAndFormat(order.total) }}
</div>
<div class="item">
{{ order.items|length }} {{ 'sylius.ui.items'|trans|lower }}
{{ order.totalQuantity }} {{ 'sylius.ui.items'|trans|lower }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, maybe we should change the 'sylius.ui.items' translation as well? I agree that there we should have a total quantity of the order, but then it should be something like 4 units or 4 products or whatever, instead of 4 items as order item can be indeed 1 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think items is the good word here.
It is the same word used in Amazon cart page even if you order several time the same product.
amazon com shopping cart

@Zales0123 let me know if it is ok for you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

</div>
</div>
</div>
Expand Down