Skip to content

Commit 1973efb

Browse files
MFTF test added and fixed the issue if user press return
1 parent f230257 commit 1973efb

6 files changed

+128
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<!-- Filter by search query and select -->
12+
<actionGroup name="AssertStorefrontVerifySearchButtonIsDisabledActionGroup">
13+
<annotations>
14+
<description>Fills in the provided Search Query on the Admin Search Term grid page.</description>
15+
</annotations>
16+
17+
<grabAttributeFrom selector="{{StorefrontQuickSearchSection.searchButton}}" userInput="disabled" stepKey="grabSearchButtonDisabledAttribute"/>
18+
19+
<assertEquals stepKey="assertSearchButtonDisabled">
20+
<actualResult type="const">$grabSearchButtonDisabledAttribute</actualResult>
21+
<expectedResult type="string">true</expectedResult>
22+
</assertEquals>
23+
</actionGroup>
24+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<!-- Filter by search query and select -->
12+
<actionGroup name="AssertStorefrontVerifySearchButtonIsNotDisabledActionGroup">
13+
<annotations>
14+
<description>Fills in the provided Search Query on the Admin Search Term grid page.</description>
15+
</annotations>
16+
17+
<grabAttributeFrom selector="{{StorefrontQuickSearchSection.searchButton}}" userInput="disabled" stepKey="grabSearchButtonAttribute"/>
18+
19+
<assertEmpty stepKey="assertSearchButtonEnabled">
20+
<actualResult type="string">$grabSearchButtonAttribute</actualResult>
21+
</assertEmpty>
22+
</actionGroup>
23+
</actionGroups>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StoreFrontFillSearchActionGroup">
12+
<arguments>
13+
<argument name="query" type="string"/>
14+
</arguments>
15+
16+
<fillField stepKey="fillSearchField" selector="{{StorefrontQuickSearchSection.searchPhrase}}" userInput="{{query}}"/>
17+
<waitForElementVisible selector="{{StorefrontQuickSearchSection.searchButton}}" stepKey="waitForSubmitButton"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontVerifySearchButtonDisabledTillMinimumSearchLengthHit">
12+
<annotations>
13+
<stories value="Search Term Disabled"/>
14+
<title value="Verify search button is disabled if search term is less than minimum search length"/>
15+
<description value="Storefront verify search button is disabled if search term is less than minimum search length"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="https://github.com/magento/magento2/issues/29704"/>
18+
<group value="searchFrontend"/>
19+
</annotations>
20+
21+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>
22+
23+
<actionGroup ref="StoreFrontFillSearchActionGroup" stepKey="fillSearchByTextLessThanMinimumSearchLength">
24+
<argument name="query" value="Te"/>
25+
</actionGroup>
26+
27+
<actionGroup ref="AssertStorefrontVerifySearchButtonIsDisabledActionGroup" stepKey="assertSearchButtonIsDisabled"/>
28+
</test>
29+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontVerifySearchButtonNotDisabledAfterMinimumSearchLengthHit">
12+
<annotations>
13+
<stories value="Search Button Not Disabled"/>
14+
<title value="Verify search button is not disabled if search term is equal or greater than minimum search length"/>
15+
<description value="Storefront verify search button is not disabled if search term is equal or greater than minimum search length"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="https://github.com/magento/magento2/issues/29704"/>
18+
<group value="searchFrontend"/>
19+
</annotations>
20+
21+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>
22+
23+
<actionGroup ref="StoreFrontFillSearchActionGroup" stepKey="fillSearchByTextMoreThanMinimumSearchLength">
24+
<argument name="query" value="Magento"/>
25+
</actionGroup>
26+
27+
<actionGroup ref="AssertStorefrontVerifySearchButtonIsNotDisabledActionGroup" stepKey="assertSearchButtonIsNotDisabled"/>
28+
</test>
29+
</tests>

app/code/Magento/Search/view/frontend/web/js/form-mini.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ define([
232232
break;
233233

234234
case $.ui.keyCode.ENTER:
235-
this.searchForm.trigger('submit');
236-
e.preventDefault();
235+
if (this.element.val().length >= parseInt(this.options.minSearchLength, 10)) {
236+
this.searchForm.trigger('submit');
237+
e.preventDefault();
238+
}
237239
break;
238240

239241
case $.ui.keyCode.DOWN:

0 commit comments

Comments
 (0)