Skip to content

Commit 42d1adb

Browse files
ENGCOM-3569: fixed issue #19292 for 2.3-develop #19305
- Merge Pull Request #19305 from webkul-ratnesh/magento2:issue-for-2.3-19292 - Merged commits: 1. 23e6250 2. 3ebcc33 3. edc8404 4. 4ddc22b 5. 60a0dd4 6. ce8765b 7. 4fb3c8d 8. 71ee75b 9. b153c06 10. ff416b9 11. 00a2131 12. 8923046 13. 7c5b9a5 14. dc407d9 15. 2b3deab 16. 4bfacbb 17. c41ec76 18. e068042 19. 8b06ed6 20. 5e2bbb6 21. bd89f7b 22. 35c033e 23. 4fbcf8c 24. 249aa07 25. 177f814 26. c772d44 27. e99d90a 28. 4a14950
2 parents de537af + 4a14950 commit 42d1adb

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)