Skip to content

Commit

Permalink
ENGCOM-8067: #29704 :- Submit search button in form-mini should be di…
Browse files Browse the repository at this point in the history
…sabled until minimum search length is reached #29724
  • Loading branch information
gabrieldagama committed Sep 7, 2020
2 parents b6e8ec7 + 7b68af8 commit 46b6ed5
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<!-- Filter by search query and select -->
<actionGroup name="AssertStorefrontVerifySearchButtonIsDisabledActionGroup">
<annotations>
<description>Verify search button has disabled attribute</description>
</annotations>

<grabAttributeFrom selector="{{StorefrontQuickSearchSection.searchButton}}" userInput="disabled" stepKey="grabSearchButtonDisabledAttribute"/>

<assertEquals stepKey="assertSearchButtonDisabled">
<actualResult type="const">$grabSearchButtonDisabledAttribute</actualResult>
<expectedResult type="string">true</expectedResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<!-- Filter by search query and select -->
<actionGroup name="AssertStorefrontVerifySearchButtonIsEnabledActionGroup">
<annotations>
<description>Verify search button does not disabled attribute</description>
</annotations>

<grabAttributeFrom selector="{{StorefrontQuickSearchSection.searchButton}}" userInput="disabled" stepKey="grabSearchButtonAttribute"/>

<assertEmpty stepKey="assertSearchButtonEnabled">
<actualResult type="string">$grabSearchButtonAttribute</actualResult>
</assertEmpty>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="StoreFrontFillSearchActionGroup">
<arguments>
<argument name="query" type="string"/>
</arguments>

<fillField stepKey="fillSearchField" selector="{{StorefrontQuickSearchSection.searchPhrase}}" userInput="{{query}}"/>
<waitForElementVisible selector="{{StorefrontQuickSearchSection.searchButton}}" stepKey="waitForSubmitButton"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontVerifySearchButtonDisabledTillMinimumSearchLengthHitTest">
<annotations>
<stories value="Search Term Disabled"/>
<title value="Verify search button is disabled if search term is less than minimum search length"/>
<description value="Storefront verify search button is disabled if search term is less than minimum search length"/>
<severity value="AVERAGE"/>
<testCaseId value="MC-37380"/>
<group value="searchFrontend"/>
</annotations>

<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>

<actionGroup ref="StoreFrontFillSearchActionGroup" stepKey="fillSearchByTextLessThanMinimumSearchLength">
<argument name="query" value="Te"/>
</actionGroup>

<actionGroup ref="AssertStorefrontVerifySearchButtonIsDisabledActionGroup" stepKey="assertSearchButtonIsDisabled"/>
</test>
</tests>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontVerifySearchButtonEnabledAfterMinimumSearchLengthHitTest">
<annotations>
<stories value="Search Button Not Disabled"/>
<title value="Verify search button is not disabled if search term is equal or greater than minimum search length"/>
<description value="Storefront verify search button is not disabled if search term is equal or greater than minimum search length"/>
<severity value="AVERAGE"/>
<testCaseId value="MC-37381"/>
<group value="searchFrontend"/>
</annotations>

<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="openStoreFrontHomePage"/>

<actionGroup ref="StoreFrontFillSearchActionGroup" stepKey="fillSearchByTextMoreThanMinimumSearchLength">
<argument name="query" value="Magento"/>
</actionGroup>

<actionGroup ref="AssertStorefrontVerifySearchButtonIsEnabledActionGroup" stepKey="assertSearchButtonIsNotDisabled"/>
</test>
</tests>
9 changes: 6 additions & 3 deletions app/code/Magento/Search/view/frontend/web/js/form-mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ define([
break;

case $.ui.keyCode.ENTER:
this.searchForm.trigger('submit');
e.preventDefault();
if (this.element.val().length >= parseInt(this.options.minSearchLength, 10)) {
this.searchForm.trigger('submit');
e.preventDefault();
}
break;

case $.ui.keyCode.DOWN:
Expand Down Expand Up @@ -294,9 +296,10 @@ define([
dropdown = $('<ul role="listbox"></ul>'),
value = this.element.val();

this.submitBtn.disabled = isEmpty(value);
this.submitBtn.disabled = true;

if (value.length >= parseInt(this.options.minSearchLength, 10)) {
this.submitBtn.disabled = false;
$.getJSON(this.options.url, {
q: value
}, $.proxy(function (data) {
Expand Down

0 comments on commit 46b6ed5

Please sign in to comment.