Skip to content

Commit 46b6ed5

Browse files
ENGCOM-8067: #29704 :- Submit search button in form-mini should be disabled until minimum search length is reached #29724
2 parents b6e8ec7 + 7b68af8 commit 46b6ed5

6 files changed

+130
-3
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>Verify search button has disabled attribute</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="AssertStorefrontVerifySearchButtonIsEnabledActionGroup">
13+
<annotations>
14+
<description>Verify search button does not disabled attribute</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="StorefrontVerifySearchButtonDisabledTillMinimumSearchLengthHitTest">
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="AVERAGE"/>
17+
<testCaseId value="MC-37380"/>
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="StorefrontVerifySearchButtonEnabledAfterMinimumSearchLengthHitTest">
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="AVERAGE"/>
17+
<testCaseId value="MC-37381"/>
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="AssertStorefrontVerifySearchButtonIsEnabledActionGroup" stepKey="assertSearchButtonIsNotDisabled"/>
28+
</test>
29+
</tests>

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

Lines changed: 6 additions & 3 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:
@@ -294,9 +296,10 @@ define([
294296
dropdown = $('<ul role="listbox"></ul>'),
295297
value = this.element.val();
296298

297-
this.submitBtn.disabled = isEmpty(value);
299+
this.submitBtn.disabled = true;
298300

299301
if (value.length >= parseInt(this.options.minSearchLength, 10)) {
302+
this.submitBtn.disabled = false;
300303
$.getJSON(this.options.url, {
301304
q: value
302305
}, $.proxy(function (data) {

0 commit comments

Comments
 (0)