Skip to content

Commit b48c601

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-95890' into 2.2-develop-pr51
2 parents 9196604 + f2e5baa commit b48c601

12 files changed

+140
-0
lines changed

dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductOnConfigureCartPage.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Bundle\Test\Fixture\BundleProduct;
1010
use Magento\Catalog\Test\Page\Product\CatalogProductView;
11+
use Magento\Checkout\Test\Constraint\Utils\CartPageLoadTrait;
1112
use Magento\Checkout\Test\Fixture\Cart;
1213
use Magento\Checkout\Test\Page\CheckoutCart;
1314
use Magento\Mtf\Constraint\AbstractAssertForm;
@@ -17,6 +18,8 @@
1718
*/
1819
class AssertBundleProductOnConfigureCartPage extends AbstractAssertForm
1920
{
21+
use CartPageLoadTrait;
22+
2023
/**
2124
* Check bundle product options correctly displayed on cart configuration page.
2225
*
@@ -28,6 +31,8 @@ class AssertBundleProductOnConfigureCartPage extends AbstractAssertForm
2831
public function processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductView $catalogProductView)
2932
{
3033
$checkoutCart->open();
34+
$this->waitForCartPageLoaded($checkoutCart);
35+
3136
$sourceProducts = $cart->getDataFieldConfig('items')['source'];
3237
$products = $sourceProducts->getProducts();
3338
foreach ($cart->getItems() as $key => $item) {

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ class Cart extends Block
113113
*/
114114
private $popupWindowContent = '#main';
115115

116+
/**
117+
* Locator for page with ajax loading state.
118+
*
119+
* @var string
120+
*/
121+
private $ajaxLoading = 'body.ajax-loading';
122+
116123
/**
117124
* Wait for PayPal page is loaded.
118125
*
@@ -295,4 +302,14 @@ public function waitForCheckoutButton()
295302
{
296303
$this->waitForElementVisible($this->inContextPaypalCheckoutButton);
297304
}
305+
306+
/**
307+
* Wait loading.
308+
*
309+
* @return void
310+
*/
311+
public function waitForLoader()
312+
{
313+
$this->waitForElementNotVisible($this->ajaxLoading);
314+
}
298315
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class Shipping extends Form
7272
*/
7373
protected $commonShippingPriceSelector = '.totals.shipping .price';
7474

75+
/**
76+
* Estimate shipping and tax form locator.
77+
*
78+
* @var string
79+
*/
80+
private $estimateShippingForm = '#shipping-zip-form';
81+
7582
/**
7683
* Open estimate shipping and tax form.
7784
*
@@ -250,4 +257,51 @@ public function waitForCommonShippingPriceBlock()
250257
{
251258
$this->waitForElementVisible($this->commonShippingPriceSelector, Locator::SELECTOR_CSS);
252259
}
260+
261+
/**
262+
* Wait until estimation form to appear.
263+
*
264+
* @return void
265+
*/
266+
public function waitForEstimateShippingAndTaxForm()
267+
{
268+
$browser = $this->browser;
269+
$selector = $this->estimateShippingForm;
270+
271+
$browser->waitUntil(
272+
function () use ($browser, $selector) {
273+
$element = $browser->find($selector);
274+
return $element->isPresent() ? true : null;
275+
}
276+
);
277+
}
278+
279+
/**
280+
* Wait for shipping method form.
281+
*
282+
* @return void
283+
*/
284+
public function waitForShippingMethodForm()
285+
{
286+
$browser = $this->browser;
287+
$selector = $this->shippingMethodForm;
288+
289+
$browser->waitUntil(
290+
function () use ($browser, $selector) {
291+
$element = $browser->find($selector);
292+
return $element->isPresent() ? true : null;
293+
}
294+
);
295+
}
296+
297+
/**
298+
* Wait for summary block to be loaded.
299+
*
300+
* @return void
301+
*/
302+
public function waitForSummaryBlock()
303+
{
304+
$this->waitForEstimateShippingAndTaxForm();
305+
$this->waitForShippingMethodForm();
306+
}
253307
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,15 @@ public function waitForShippingPriceBlock()
264264
{
265265
$this->waitForElementVisible($this->shippingPriceBlockSelector, Locator::SELECTOR_CSS);
266266
}
267+
268+
/**
269+
* Wait for "Grand Total" row to appear.
270+
*
271+
* @return void
272+
*/
273+
public function waitForGrandTotal()
274+
{
275+
$this->waitForUpdatedTotals();
276+
$this->waitForElementVisible($this->grandTotal);
277+
}
267278
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartItemsOptions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Checkout\Test\Constraint;
88

99
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
10+
use Magento\Checkout\Test\Constraint\Utils\CartPageLoadTrait;
1011
use Magento\Checkout\Test\Fixture\Cart;
1112
use Magento\Checkout\Test\Fixture\Cart\Items;
1213
use Magento\Checkout\Test\Page\CheckoutCart;
@@ -21,6 +22,8 @@
2122
*/
2223
class AssertCartItemsOptions extends AbstractAssertForm
2324
{
25+
use CartPageLoadTrait;
26+
2427
/**
2528
* Error message for verify options
2629
*
@@ -44,6 +47,8 @@ class AssertCartItemsOptions extends AbstractAssertForm
4447
public function processAssert(CheckoutCart $checkoutCart, Cart $cart)
4548
{
4649
$checkoutCart->open();
50+
$this->waitForCartPageLoaded($checkoutCart);
51+
4752
/** @var Items $sourceProducts */
4853
$sourceProducts = $cart->getDataFieldConfig('items')['source'];
4954
$products = $sourceProducts->getProducts();

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertGrandTotalInShoppingCart.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Checkout\Test\Constraint;
88

9+
use Magento\Checkout\Test\Constraint\Utils\CartPageLoadTrait;
910
use Magento\Checkout\Test\Fixture\Cart;
1011
use Magento\Checkout\Test\Page\CheckoutCart;
1112
use Magento\Mtf\Constraint\AbstractConstraint;
@@ -16,6 +17,8 @@
1617
*/
1718
class AssertGrandTotalInShoppingCart extends AbstractConstraint
1819
{
20+
use CartPageLoadTrait;
21+
1922
/**
2023
* Assert that grand total is equal to expected
2124
*
@@ -28,6 +31,7 @@ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireRe
2831
{
2932
if ($requireReload) {
3033
$checkoutCart->open();
34+
$this->waitForCartPageLoaded($checkoutCart);
3135
$checkoutCart->getTotalsBlock()->waitForUpdatedTotals();
3236
}
3337

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertPriceInShoppingCart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Checkout\Test\Constraint;
88

99
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
10+
use Magento\Checkout\Test\Constraint\Utils\CartPageLoadTrait;
1011
use Magento\Checkout\Test\Fixture\Cart;
1112
use Magento\Checkout\Test\Fixture\Cart\Items;
1213
use Magento\Checkout\Test\Page\CheckoutCart;
@@ -19,6 +20,8 @@
1920
*/
2021
class AssertPriceInShoppingCart extends AbstractAssertForm
2122
{
23+
use CartPageLoadTrait;
24+
2225
/**
2326
* Assert that price in the shopping cart equals to expected price from data set
2427
*
@@ -29,6 +32,8 @@ class AssertPriceInShoppingCart extends AbstractAssertForm
2932
public function processAssert(CheckoutCart $checkoutCart, Cart $cart)
3033
{
3134
$checkoutCart->open();
35+
$this->waitForCartPageLoaded($checkoutCart);
36+
3237
/** @var Items $sourceProducts */
3338
$sourceProducts = $cart->getDataFieldConfig('items')['source'];
3439
$products = $sourceProducts->getProducts();

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertProductQtyInShoppingCart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Checkout\Test\Constraint;
88

99
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
10+
use Magento\Checkout\Test\Constraint\Utils\CartPageLoadTrait;
1011
use Magento\Checkout\Test\Fixture\Cart;
1112
use Magento\Checkout\Test\Fixture\Cart\Items;
1213
use Magento\Checkout\Test\Page\CheckoutCart;
@@ -19,6 +20,8 @@
1920
*/
2021
class AssertProductQtyInShoppingCart extends AbstractAssertForm
2122
{
23+
use CartPageLoadTrait;
24+
2225
/**
2326
* Assert that quantity in the shopping cart is equals to expected quantity from data set
2427
*
@@ -29,6 +32,8 @@ class AssertProductQtyInShoppingCart extends AbstractAssertForm
2932
public function processAssert(CheckoutCart $checkoutCart, Cart $cart)
3033
{
3134
$checkoutCart->open();
35+
$this->waitForCartPageLoaded($checkoutCart);
36+
3237
/** @var Items $sourceProducts */
3338
$sourceProducts = $cart->getDataFieldConfig('items')['source'];
3439
$products = $sourceProducts->getProducts();

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertSubtotalInShoppingCart.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Checkout\Test\Constraint;
88

99
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
10+
use Magento\Checkout\Test\Constraint\Utils\CartPageLoadTrait;
1011
use Magento\Checkout\Test\Fixture\Cart;
1112
use Magento\Checkout\Test\Fixture\Cart\Items;
1213
use Magento\Checkout\Test\Page\CheckoutCart;
@@ -19,6 +20,8 @@
1920
*/
2021
class AssertSubtotalInShoppingCart extends AbstractAssertForm
2122
{
23+
use CartPageLoadTrait;
24+
2225
/**
2326
* Assert that subtotal total in the shopping cart is equals to expected total from data set
2427
*
@@ -31,6 +34,7 @@ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireRe
3134
{
3235
if ($requireReload) {
3336
$checkoutCart->open();
37+
$this->waitForCartPageLoaded($checkoutCart);
3438
}
3539

3640
/** @var Items $sourceProducts */
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\Constraint\Utils;
8+
9+
use Magento\Checkout\Test\Page\CheckoutCart;
10+
11+
/**
12+
* Check if cart page is fully loaded.
13+
*/
14+
trait CartPageLoadTrait
15+
{
16+
/**
17+
* @param CheckoutCart $checkoutCart
18+
* @return void
19+
*/
20+
public function waitForCartPageLoaded(CheckoutCart $checkoutCart)
21+
{
22+
$checkoutCart->getCartBlock()->waitForLoader();
23+
if (!$checkoutCart->getCartBlock()->cartIsEmpty()) {
24+
$checkoutCart->getShippingBlock()->waitForSummaryBlock();
25+
$checkoutCart->getTotalsBlock()->waitForGrandTotal();
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)