Skip to content

Commit f3fb410

Browse files
committed
Merge remote-tracking branch 'origin/2.2.5-develop' into MAGETWO-92264
2 parents 0375835 + 1a4ca4c commit f3fb410

File tree

12 files changed

+141
-15
lines changed

12 files changed

+141
-15
lines changed

dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Form/Secure3d.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,27 @@ class Secure3d extends Form
3030
*/
3131
protected $submitButton = 'input[name="UsernamePasswordEntry"]';
3232

33+
/**
34+
* 3D Secure Authorization iFrame locator.
35+
*
36+
* @var string
37+
*/
38+
private $braintree3dSecureAuthForm = '#authWindow';
39+
3340
/**
3441
* Switch to 3D Secure iFrame.
3542
*
36-
* @param array $locator
43+
* @param string $locator
44+
* @return void
3745
*/
38-
public function switchToFrame($locator)
46+
public function switchToFrame(string $locator)
3947
{
40-
$this->browser->switchToFrame(new Locator($locator, Locator::SELECTOR_XPATH));
41-
$this->browser->switchToFrame(new Locator($locator, Locator::SELECTOR_XPATH));
48+
$this->waitForElementVisible($locator, Locator::SELECTOR_XPATH);
49+
$this->browser->switchToFrame(new Locator($locator, Locator::SELECTOR_XPATH));
50+
$this->waitForElementVisible($locator, Locator::SELECTOR_XPATH);
51+
$this->browser->switchToFrame(new Locator($locator, Locator::SELECTOR_XPATH));
52+
$this->waitForElementVisible($this->braintree3dSecureAuthForm);
53+
$this->browser->switchToFrame(new Locator($this->braintree3dSecureAuthForm));
4254
}
4355

4456
/**
@@ -63,6 +75,10 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
6375
$mapping = $this->dataMapping($fixture->getData());
6476
$this->switchToFrame($this->braintree3dSecure);
6577
$element = $this->browser->find('body');
78+
$this->waitForElementVisible(
79+
$mapping['secure3d_password']['selector'],
80+
$mapping['secure3d_password']['strategy']
81+
);
6682
$this->_fill([$mapping['secure3d_password']], $element);
6783
$this->submit();
6884
$this->browser->switchToFrame();

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,10 @@ public function inContextPaypalCheckout()
405405
public function braintreePaypalCheckout()
406406
{
407407
$currentWindow = $this->browser->getCurrentWindow();
408+
$this->getMiniCartBlock()->waitInit();
408409
$this->getMiniCartBlock()->openMiniCart();
409410
$this->getMiniCartBlock()->clickBraintreePaypalButton();
411+
410412
return $currentWindow;
411413
}
412414

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ class Cart extends Block
106106
*/
107107
protected $cartItemClass = \Magento\Checkout\Test\Block\Cart\CartItem::class;
108108

109+
/**
110+
* Paypal page elements locator.
111+
*
112+
* @var string
113+
*/
114+
private $popupWindowContent = '#main';
115+
109116
/**
110117
* Wait for PayPal page is loaded.
111118
*
@@ -114,6 +121,7 @@ class Cart extends Block
114121
public function waitForFormLoaded()
115122
{
116123
$this->waitForElementNotVisible($this->preloaderSpinner);
124+
$this->waitForElementVisible($this->popupWindowContent);
117125
}
118126

119127
/**
@@ -185,7 +193,12 @@ public function paypalCheckout()
185193
public function inContextPaypalCheckout()
186194
{
187195
$this->waitForCheckoutButton();
196+
$windowsCount = count($this->browser->getWindowHandles());
188197
$this->_rootElement->find($this->inContextPaypalCheckoutButton)->click();
198+
$browser = $this->browser;
199+
$this->browser->waitUntil(function () use ($browser, $windowsCount) {
200+
return count($browser->getWindowHandles()) === ($windowsCount + 1) ? true: null;
201+
});
189202
$this->browser->selectWindow();
190203
$this->waitForFormLoaded();
191204
$this->browser->closeWindow();

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Sidebar extends Block
3434
*
3535
* @var string
3636
*/
37-
protected $braintreePaypalCheckoutButton = './/button[contains(@id, "braintree-paypal-mini-cart")]';
37+
protected $braintreePaypalCheckoutButton = 'button[id^="braintree-paypal-mini-cart"]';
3838

3939
/**
4040
* Locator value for "Proceed to Checkout" button.
@@ -124,8 +124,16 @@ public function openMiniCart()
124124
*/
125125
public function clickBraintreePaypalButton()
126126
{
127-
$this->_rootElement->find($this->braintreePaypalCheckoutButton, Locator::SELECTOR_XPATH)
127+
// Button can be enabled/disabled few times.
128+
sleep(2);
129+
130+
$windowsCount = count($this->browser->getWindowHandles());
131+
$this->_rootElement->find($this->braintreePaypalCheckoutButton)
128132
->click();
133+
$browser = $this->browser;
134+
$this->browser->waitUntil(function () use ($browser, $windowsCount) {
135+
return count($browser->getWindowHandles()) === ($windowsCount + 1) ? true: null;
136+
});
129137
}
130138

131139
/**

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Checkout\Test\Fixture\Checkout;
99
use Magento\Customer\Test\Fixture\Customer;
1010
use Magento\Mtf\Block\Form;
11+
use Magento\Mtf\Client\Element\SimpleElement;
1112
use Magento\Mtf\Fixture\FixtureInterface;
1213

1314
/**
@@ -86,6 +87,7 @@ public function guestCheckout()
8687
*/
8788
public function loginCustomer(FixtureInterface $customer)
8889
{
90+
$this->waitForElementNotVisible($this->loadingMask);
8991
$this->fill($customer);
9092
$this->_rootElement->find($this->login)->click();
9193
$this->waitForElementNotVisible($this->loadingMask);
@@ -122,4 +124,32 @@ function () use ($browser, $selector) {
122124
}
123125
);
124126
}
127+
128+
/**
129+
* @inheritdoc
130+
*/
131+
protected function _fill(array $fields, SimpleElement $element = null)
132+
{
133+
$context = ($element === null) ? $this->_rootElement : $element;
134+
foreach ($fields as $name => $field) {
135+
if (!isset($field['value'])) {
136+
$this->_fill($field, $context);
137+
} else {
138+
$selector = $field['selector'];
139+
$strategy = $field['strategy'];
140+
$this->browser->waitUntil(function () use ($context, $selector, $strategy) {
141+
$element = $context->find($selector, $strategy);
142+
143+
return $element->isVisible() && !$element->isDisabled() ? true : null;
144+
});
145+
146+
$element = $this->getElement($context, $field);
147+
if (!$element->isDisabled()) {
148+
$element->setValue($field['value']);
149+
} else {
150+
throw new \Exception("Unable to set value to field '$name' as it's disabled.");
151+
}
152+
}
153+
}
154+
}
125155
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace Magento\Checkout\Test\Block\Onepage\Payment;
88

99
use Magento\Mtf\Block\Block;
10-
use Magento\Mtf\Client\Locator;
1110

1211
/**
1312
* Checkout payment method block.
@@ -56,6 +55,13 @@ class Method extends Block
5655
*/
5756
protected $payWithBraintreePaypalButton = '#braintree_paypal_pay_with';
5857

58+
/**
59+
* Paypal page elements locator.
60+
*
61+
* @var string
62+
*/
63+
private $popupWindowContent = '#main';
64+
5965
/**
6066
* Wait for PayPal page is loaded.
6167
*
@@ -64,6 +70,7 @@ class Method extends Block
6470
public function waitForFormLoaded()
6571
{
6672
$this->waitForElementNotVisible($this->preloaderSpinner);
73+
$this->waitForElementVisible($this->popupWindowContent);
6774
}
6875

6976
/**
@@ -85,9 +92,12 @@ public function clickPlaceOrder()
8592
public function clickContinueToPaypal()
8693
{
8794
$currentWindow = $this->browser->getCurrentWindow();
95+
$windowsCount = count($this->browser->getWindowHandles());
8896
$this->waitForElementNotVisible($this->waitElement);
8997
$this->_rootElement->find($this->continueToBraintreePaypalButton)->click();
9098
$this->waitForElementNotVisible($this->waitElement);
99+
$this->waitUntilNumberOfWindowsToBe(++$windowsCount);
100+
91101
return $currentWindow;
92102
}
93103

@@ -99,9 +109,12 @@ public function clickContinueToPaypal()
99109
public function clickPayWithPaypal()
100110
{
101111
$currentWindow = $this->browser->getCurrentWindow();
112+
$windowsCount = count($this->browser->getWindowHandles());
102113
$this->waitForElementNotVisible($this->waitElement);
103114
$this->_rootElement->find($this->payWithBraintreePaypalButton)->click();
104115
$this->waitForElementNotVisible($this->waitElement);
116+
$this->waitUntilNumberOfWindowsToBe(++$windowsCount);
117+
105118
return $currentWindow;
106119
}
107120

@@ -111,7 +124,9 @@ public function clickPayWithPaypal()
111124
public function inContextPaypalCheckout()
112125
{
113126
$this->waitForElementNotVisible($this->waitElement);
127+
$windowsCount = count($this->browser->getWindowHandles());
114128
$this->_rootElement->find($this->placeOrderButton)->click();
129+
$this->waitUntilNumberOfWindowsToBe(++$windowsCount);
115130
$this->browser->selectWindow();
116131
$this->waitForFormLoaded();
117132
$this->browser->closeWindow();
@@ -131,4 +146,16 @@ public function getBillingBlock()
131146
['element' => $element]
132147
);
133148
}
149+
150+
/**
151+
* @param int $windowsCount
152+
* @return void
153+
*/
154+
private function waitUntilNumberOfWindowsToBe(int $windowsCount)
155+
{
156+
$browser = $this->browser;
157+
$this->browser->waitUntil(function () use ($browser, $windowsCount) {
158+
return count($browser->getWindowHandles()) === $windowsCount ? true : null;
159+
});
160+
}
134161
}

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/ProceedToCheckoutStep.php

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

99
use Magento\Checkout\Test\Page\CheckoutCart;
10+
use Magento\Cms\Test\Page\CmsIndex;
1011
use Magento\Mtf\TestStep\TestStepInterface;
1112

1213
/**
@@ -23,12 +24,18 @@ class ProceedToCheckoutStep implements TestStepInterface
2324
protected $checkoutCart;
2425

2526
/**
26-
* @constructor
27+
* @var CmsIndex
28+
*/
29+
private $cmsIndex;
30+
31+
/**
2732
* @param CheckoutCart $checkoutCart
33+
* @param CmsIndex $cmsIndex
2834
*/
29-
public function __construct(CheckoutCart $checkoutCart)
35+
public function __construct(CheckoutCart $checkoutCart, CmsIndex $cmsIndex)
3036
{
3137
$this->checkoutCart = $checkoutCart;
38+
$this->cmsIndex = $cmsIndex;
3239
}
3340

3441
/**
@@ -39,6 +46,8 @@ public function __construct(CheckoutCart $checkoutCart)
3946
public function run()
4047
{
4148
$this->checkoutCart->open();
49+
$this->checkoutCart->getCartBlock()->waitCartContainerLoading();
50+
$this->cmsIndex->getCmsPageBlock()->waitPageInit();
4251
$this->checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout();
4352
}
4453
}

dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/InContextCheckoutWithPaypalFromShoppingCartStep.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
namespace Magento\Paypal\Test\TestStep;
88

9-
use Magento\Mtf\TestStep\TestStepInterface;
109
use Magento\Checkout\Test\Page\CheckoutCart;
10+
use Magento\Cms\Test\Page\CmsIndex;
11+
use Magento\Mtf\TestStep\TestStepInterface;
1112

1213
/**
1314
* Checkout with PayPal from Shopping Cart.
@@ -22,13 +23,20 @@ class InContextCheckoutWithPaypalFromShoppingCartStep implements TestStepInterfa
2223
protected $checkoutCart;
2324

2425
/**
25-
* @constructor
26+
* @var CmsIndex
27+
*/
28+
private $cmsIndex;
29+
30+
/**
2631
* @param CheckoutCart $checkoutCart
32+
* @param CmsIndex $cmsIndex
2733
*/
2834
public function __construct(
29-
CheckoutCart $checkoutCart
35+
CheckoutCart $checkoutCart,
36+
CmsIndex $cmsIndex
3037
) {
3138
$this->checkoutCart = $checkoutCart;
39+
$this->cmsIndex = $cmsIndex;
3240
}
3341

3442
/**
@@ -39,6 +47,8 @@ public function __construct(
3947
public function run()
4048
{
4149
$this->checkoutCart->open();
50+
$this->checkoutCart->getCartBlock()->waitCartContainerLoading();
51+
$this->cmsIndex->getCmsPageBlock()->waitPageInit();
4252
$this->checkoutCart->getCartBlock()->inContextPaypalCheckout();
4353
}
4454
}

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function getIds()
8383
*/
8484
public function viewInvoice()
8585
{
86+
$this->resetFilter();
8687
$this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH);
8788
$this->_rootElement->find($this->invoiceId)->click();
8889
}

dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertInvoiceStatusInOrdersGrid.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Sales\Test\Constraint;
88

9+
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
910
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
1011
use Magento\Mtf\Constraint\AbstractConstraint;
1112

@@ -17,17 +18,20 @@ class AssertInvoiceStatusInOrdersGrid extends AbstractConstraint
1718
/**
1819
* Assert invoice status on order page in Admin.
1920
*
21+
* @param OrderIndex $salesOrder
2022
* @param SalesOrderView $salesOrderView
2123
* @param string $invoiceStatus
2224
* @param string $orderId
2325
* @return void
2426
*/
2527
public function processAssert(
28+
OrderIndex $salesOrder,
2629
SalesOrderView $salesOrderView,
2730
$invoiceStatus,
2831
$orderId
2932
) {
30-
$salesOrderView->open(['order_id' => $orderId]);
33+
$salesOrder->open();
34+
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
3135
$salesOrderView->getOrderForm()->openTab('invoices');
3236
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $grid */
3337
$grid = $salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock();

0 commit comments

Comments
 (0)