Skip to content

Commit 4a14950

Browse files
committed
Fix functional tests.
1 parent e99d90a commit 4a14950

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Wishlist\Test\Block\Customer\Wishlist\Items;
9+
10+
use Magento\Mtf\Block\Block;
11+
use Magento\Mtf\Client\Locator;
12+
13+
/**
14+
* Pager block for wishlist items page.
15+
*/
16+
class TopToolbar extends Block
17+
{
18+
/**
19+
* Selector next active element
20+
*
21+
* @var string
22+
*/
23+
private $nextPageSelector = '.item.current + .item a';
24+
25+
/**
26+
* Selector first element
27+
*
28+
* @var string
29+
*/
30+
private $firstPageSelector = '.item>.page';
31+
32+
/**
33+
* Selector option element
34+
*
35+
* @var string
36+
*/
37+
private $optionSelector = './/option';
38+
39+
/**
40+
* Go to the next page
41+
*
42+
* @return bool
43+
*/
44+
public function nextPage()
45+
{
46+
$nextPageItem = $this->_rootElement->find($this->nextPageSelector);
47+
if ($nextPageItem->isVisible()) {
48+
$nextPageItem->click();
49+
return true;
50+
}
51+
return false;
52+
}
53+
54+
/**
55+
* Go to the first page
56+
*
57+
* @return bool
58+
*/
59+
public function firstPage()
60+
{
61+
$firstPageItem = $this->_rootElement->find($this->firstPageSelector);
62+
if ($firstPageItem->isVisible()) {
63+
$firstPageItem->click();
64+
return true;
65+
}
66+
return false;
67+
}
68+
69+
/**
70+
* Set value for limiter element by index
71+
*
72+
* @param int $index
73+
* @return $this
74+
*/
75+
public function setLimiterValueByIndex($index)
76+
{
77+
$options = $this->_rootElement->getElements($this->optionSelector, Locator::SELECTOR_XPATH);
78+
if (isset($options[$index])) {
79+
$options[$index]->click();
80+
}
81+
return $this;
82+
}
83+
84+
/**
85+
* Get value for limiter element by index
86+
*
87+
* @param int $index
88+
* @return int|null
89+
*/
90+
public function getLimitedValueByIndex($index)
91+
{
92+
$options = $this->_rootElement->getElements($this->optionSelector, Locator::SELECTOR_XPATH);
93+
if (isset($options[$index])) {
94+
return $options[$index]->getValue();
95+
}
96+
return null;
97+
}
98+
}

dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductIsPresentInWishlist.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public function processAssert(
3636
$cmsIndex->getLinksBlock()->openLink('My Account');
3737
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
3838

39+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
40+
->isVisible();
41+
while (!$isProductVisible && $wishlistIndex->getTopToolbar()->nextPage()) {
42+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
43+
->isVisible();
44+
}
45+
3946
\PHPUnit\Framework\Assert::assertTrue(
4047
$wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)->isVisible(),
4148
$product->getName() . ' is not visible on Wish List page.'

dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductRegularPriceOnStorefront.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public function processAssert(
4444
$cmsIndex->getLinksBlock()->openLink('My Account');
4545
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
4646

47+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
48+
->isVisible();
49+
while (!$isProductVisible && $wishlistIndex->getTopToolbar()->nextPage()) {
50+
$isProductVisible = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product)
51+
->isVisible();
52+
}
53+
4754
$productRegularPrice = 0;
4855
if ($product instanceof GroupedProduct) {
4956
$associatedProducts = $product->getAssociated();

dev/tests/functional/tests/app/Magento/Wishlist/Test/Page/WishlistIndex.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<page name="WishlistIndex" mca="wishlist/index/index" module="Magento_Wishlist">
1010
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".messages" strategy="css selector"/>
1111
<block name="wishlistBlock" class="Magento\Wishlist\Test\Block\Customer\Wishlist" locator="#wishlist-view-form" strategy="css selector"/>
12+
<block name="topToolbar" class="Magento\Wishlist\Test\Block\Customer\Wishlist\Items\TopToolbar" locator=".//*[contains(@class,'wishlist-toolbar')][2]" strategy="xpath"/>
1213
</page>
1314
</config>

0 commit comments

Comments
 (0)