Skip to content

Commit 3cb99f8

Browse files
committed
Merge branch 'MTA-3285' of github.com:magento-qmt/magento2ce into MTA-3333
2 parents 840d539 + ce5868b commit 3cb99f8

File tree

3 files changed

+61
-4
lines changed

3 files changed

+61
-4
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Search.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ class Search extends Block
5050
*/
5151
protected $placeholder = '//input[@id="search" and contains(@placeholder, "%s")]';
5252

53+
/**
54+
* Locator value for list items.
55+
*
56+
* @var string
57+
*/
58+
private $searchListItems = './/div[@id="search_autocomplete"]//li';
59+
60+
/**
61+
* Locator value for body with aria-busy attribute.
62+
*
63+
* @var string
64+
*/
65+
private $selectorAriaBusy = './/body[@aria-busy="false"]';
66+
5367
/**
5468
* Perform search by a keyword.
5569
*
@@ -73,6 +87,27 @@ public function search($keyword)
7387
public function fillSearch($text)
7488
{
7589
$this->_rootElement->find($this->searchInput)->setValue($text);
90+
$this->waitUntilSearchPrepared();
91+
}
92+
93+
/**
94+
* Wait until "Suggest Search" block will be prepared.
95+
*
96+
* @return bool
97+
*/
98+
public function waitUntilSearchPrepared()
99+
{
100+
$this->browser->waitUntil(
101+
function () {
102+
$count = count($this->_rootElement->getElements($this->searchListItems, Locator::SELECTOR_XPATH));
103+
sleep(0.2);
104+
$newCount = count($this->_rootElement->getElements($this->searchListItems, Locator::SELECTOR_XPATH));
105+
return $this->browser->find($this->selectorAriaBusy, Locator::SELECTOR_XPATH)->isVisible()
106+
&& ($newCount == $count)
107+
? true
108+
: null;
109+
}
110+
);
76111
}
77112

78113
/**
@@ -108,4 +143,16 @@ function () use ($rootElement, $searchAutocomplete) {
108143
}
109144
);
110145
}
146+
147+
/**
148+
* Click on suggested text.
149+
*
150+
* @param string $text
151+
* @return void
152+
*/
153+
public function clickSuggestedText($text)
154+
{
155+
$searchAutocomplete = sprintf($this->searchAutocomplete, $text);
156+
$this->_rootElement->find($searchAutocomplete, Locator::SELECTOR_XPATH)->click();
157+
}
111158
}

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertSuggestSearchingResult.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\CatalogSearch\Test\Fixture\CatalogSearchQuery;
1010
use Magento\Cms\Test\Page\CmsIndex;
1111
use Magento\Mtf\Constraint\AbstractConstraint;
12+
use Magento\CatalogSearch\Test\Page\AdvancedResult;
1213

1314
/**
1415
* Class AssertSuggestSearchingResult
@@ -18,13 +19,20 @@ class AssertSuggestSearchingResult extends AbstractConstraint
1819
/**
1920
* Check that after input some text(e.g. product name) into search field, drop-down window is appeared.
2021
* Window contains requested entity and number of quantity.
22+
* Click on search suggestion and verify that search is performed.
2123
*
2224
* @param CmsIndex $cmsIndex
2325
* @param CatalogSearchQuery $catalogSearch
26+
* @param AssertCatalogSearchResult $assertCatalogSearchResult
27+
* @param AdvancedResult $resultPage
2428
* @return void
2529
*/
26-
public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSearch)
27-
{
30+
public function processAssert(
31+
CatalogSearchQuery $catalogSearch,
32+
CmsIndex $cmsIndex,
33+
AssertCatalogSearchResult $assertCatalogSearchResult,
34+
AdvancedResult $resultPage
35+
) {
2836
$cmsIndex->open();
2937
$searchBlock = $cmsIndex->getSearchBlock();
3038

@@ -41,6 +49,8 @@ public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSea
4149
$isVisible,
4250
'Block "Suggest Search" when searching was not found'
4351
);
52+
$searchBlock->clickSuggestedText($queryText);
53+
$assertCatalogSearchResult->processAssert($catalogSearch, $resultPage);
4454
}
4555

4656
/**
@@ -50,6 +60,6 @@ public function processAssert(CmsIndex $cmsIndex, CatalogSearchQuery $catalogSea
5060
*/
5161
public function toString()
5262
{
53-
return 'Asserts window contains requested entity and quantity';
63+
return 'Asserts window contains requested entity and quantity. Searched product has been successfully found.';
5464
}
5565
}

dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/SearchEntityResultsTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9-
<testCase name="Magento\CatalogSearch\Test\TestCase\SearchEntityResultsTest" summary="Use Simple Product Search" ticketId="MAGETWO-25095">
9+
<testCase name="Magento\CatalogSearch\Test\TestCase\SearchEntityResultsTest" summary="Use Quick Search to Find Product" ticketId="MAGETWO-25095">
1010
<variation name="SearchEntityResultsTestVariation1" summary="Use Quick Search to Find the Product" ticketId="MAGETWO-12420">
1111
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
1212
<data name="catalogSearch/data/query_text/value" xsi:type="string">catalogProductSimple::default::sku</data>

0 commit comments

Comments
 (0)