Skip to content

Commit 72d20ae

Browse files
committed
MC-18165: Quick search with two chars shows all products
1 parent 434dc3e commit 72d20ae

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@
4545
<annotations>
4646
<description>Fill the Storefront Search field. Submits the Form. Validates that 'Minimum Search query length' warning appears.</description>
4747
</annotations>
48+
<arguments>
49+
<argument name="minQueryLength" type="string"/>
50+
</arguments>
4851

49-
<see selector="{{StorefrontQuickSearchResultsSection.messageSection}}" userInput="Minimum Search query length is 3" stepKey="assertQuickSearchNeedThreeOrMoreChars"/>
52+
<see selector="{{StorefrontQuickSearchResultsSection.messageSection}}" userInput="Minimum Search query length is {{minQueryLength}}" stepKey="assertQuickSearchNeedThreeOrMoreChars"/>
5053
</actionGroup>
5154

5255
<actionGroup name="StorefrontQuickSearchRelatedSearchTermsAppearsActionGroup">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="MinimalQueryLengthDefaultConfigData">
12+
<data key="path">catalog/search/min_query_length</data>
13+
<data key="value">3</data>
14+
</entity>
15+
<entity name="MinimalQueryLengthFourConfigData">
16+
<data key="path">catalog/search/min_query_length</data>
17+
<data key="value">4</data>
18+
</entity>
19+
</entities>

app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
</test>
7575
<test name="QuickSearchEmptyResults">
7676
<annotations>
77+
<features value="CatalogSearch"/>
7778
<stories value="Search Product on Storefront"/>
7879
<title value="User should not get search results on query that doesn't return anything"/>
7980
<description value="Use invalid query to return no products"/>
@@ -89,8 +90,8 @@
8990
</createData>
9091
</before>
9192
<after>
92-
<deleteData stepKey="deleteProduct" createDataKey="createSimpleProduct"/>
93-
<deleteData stepKey="deleteCategory" createDataKey="createCategory"/>
93+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
94+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
9495
</after>
9596

9697
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToFrontPage"/>
@@ -99,6 +100,7 @@
99100
</actionGroup>
100101
<actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmpty"/>
101102
</test>
103+
102104
<test name="QuickSearchWithTwoCharsEmptyResults" extends="QuickSearchEmptyResults">
103105
<annotations>
104106
<features value="CatalogSearch"/>
@@ -110,19 +112,30 @@
110112
<group value="CatalogSearch"/>
111113
<group value="mtf_migrated"/>
112114
</annotations>
115+
116+
<before>
117+
<magentoCLI command="config:set {{MinimalQueryLengthFourConfigData.path}} {{MinimalQueryLengthFourConfigData.value}}" after="createSimpleProduct" stepKey="setMinimalQueryLengthToFour"/>
118+
</before>
119+
120+
<after>
121+
<magentoCLI command="config:set {{MinimalQueryLengthDefaultConfigData.path}} {{MinimalQueryLengthDefaultConfigData.value}}" after="deleteCategory" stepKey="setMinimalQueryLengthToFour"/>
122+
</after>
123+
113124
<executeJS function="var s = '$createSimpleProduct.name$'; var ret=s.substring(0,2); return ret;" before="searchStorefront" stepKey="getFirstTwoLetters"/>
114-
<executeJS function="var s = '$createSimpleProduct.name$'; var ret=s.substring(0,3); return ret;" before="searchStorefront" stepKey="getFirstThreeLetters"/>
125+
<executeJS function="var s = '$createSimpleProduct.name$'; var ret=s.substring(0,{{MinimalQueryLengthFourConfigData.value}}); return ret;" after="getFirstTwoLetters" stepKey="getFirstConfigLetters"/>
115126

116-
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" after="checkEmpty" stepKey="searchStorefrontThreeLetters">
117-
<argument name="phrase" value="$getFirstThreeLetters"/>
127+
<actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" after="checkEmpty" stepKey="searchStorefrontConfigLetters">
128+
<argument name="phrase" value="$getFirstConfigLetters"/>
118129
</actionGroup>
119-
<actionGroup ref="StorefrontQuickSearchTooShortStringActionGroup" after="searchStorefrontThreeLetters" stepKey="checkCannotSearchWithTooShortString">
130+
<actionGroup ref="StorefrontQuickSearchTooShortStringActionGroup" after="searchStorefrontConfigLetters" stepKey="checkCannotSearchWithTooShortString">
120131
<argument name="phrase" value="$getFirstTwoLetters"/>
132+
<argument name="minQueryLength" value="{{MinimalQueryLengthFourConfigData.value}}"/>
121133
</actionGroup>
122134
<actionGroup ref="StorefrontQuickSearchRelatedSearchTermsAppearsActionGroup" after="checkCannotSearchWithTooShortString" stepKey="checkRelatedSearchTerm">
123-
<argument name="term" value="$getFirstThreeLetters"/>
135+
<argument name="term" value="$getFirstConfigLetters"/>
124136
</actionGroup>
125137
</test>
138+
126139
<test name="QuickSearchProductByNameWithThreeLetters" extends="QuickSearchProductBySku">
127140
<annotations>
128141
<stories value="Search Product on Storefront"/>

0 commit comments

Comments
 (0)