Skip to content

Commit 16dd439

Browse files
authored
ENGCOM-7222: Issue 27358 #27359
2 parents e2dd73c + 82d8659 commit 16dd439

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-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+
<actionGroup name="StorefrontAssertUnableSearchNegativeForPriceFieldActionGroup" extends="StorefrontFillFormAdvancedSearchActionGroup">
12+
<remove keyForRemoval="waitForPageLoad" />
13+
<grabTextFrom selector="{{StorefrontCatalogSearchAdvancedFormSection.PriceFromError}}" stepKey="grabPriceFromError"/>
14+
<grabTextFrom selector="{{StorefrontCatalogSearchAdvancedFormSection.PriceToError}}" stepKey="grabPriceToError"/>
15+
<assertEquals stepKey="assertErrorMessagePriceFrom">
16+
<actualResult type="string">{{UnableNegativePrice.Error_message}}</actualResult>
17+
<expectedResult type="string">$grabPriceFromError</expectedResult>
18+
</assertEquals>
19+
<assertEquals stepKey="assertErrorMessagePriceTo">
20+
<actualResult type="string">{{UnableNegativePrice.Error_message}}</actualResult>
21+
<expectedResult type="string">$grabPriceToError</expectedResult>
22+
</assertEquals>
23+
</actionGroup>
24+
</actionGroups>

app/code/Magento/CatalogSearch/Test/Mftf/Data/MinMaxQueryLengthHintsData.xml renamed to app/code/Magento/CatalogSearch/Test/Mftf/Data/MessageAndHintData.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
<entity name="MinMaxQueryLength" type="constant">
1212
<data key="Hint">This value must be compatible with the corresponding setting in the configured search engine</data>
1313
</entity>
14+
<entity name="UnableNegativePrice" type="constant">
15+
<data key="Error_message">Please enter a number 0 or greater in this field.</data>
16+
</entity>
1417
</entities>

app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchAdvancedFormSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<element name="ShortDescription" type="input" selector="#short_description"/>
1717
<element name="PriceFrom" type="input" selector="#price"/>
1818
<element name="PriceTo" type="input" selector="#price_to"/>
19+
<element name="PriceFromError" type="text" selector="#price-error"/>
20+
<element name="PriceToError" type="text" selector="#price_to-error"/>
1921
<element name="AttributeByCode" type="input" selector="#{{var1}}" parameterized="true"/>
2022
<element name="SubmitButton" type="button" selector="//*[@id='form-validate']//button[@type='submit']"/>
2123
</section>
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontCheckUnableAdvancedSearchWithNegativePriceTest">
12+
<annotations>
13+
<stories value="Use Advanced Search"/>
14+
<title value="Unable negative price use to advanced search"/>
15+
<description value="Check unable negative price use to advanced search by price from and price to"/>
16+
</annotations>
17+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToStorefront"/>
18+
<actionGroup ref="StorefrontOpenAdvancedSearchActionGroup" stepKey="openAdvancedSearch"/>
19+
<actionGroup ref="StorefrontAssertUnableSearchNegativeForPriceFieldActionGroup" stepKey="assertUnableSearch">
20+
<argument name="price_to" value="-50"/>
21+
<argument name="price_from" value="-10"/>
22+
</actionGroup>
23+
</test>
24+
</tests>

app/code/Magento/CatalogSearch/view/frontend/templates/advanced/form.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
8+
// @codingStandardsIgnoreFile
89
?>
910
<?php
1011
/**
@@ -68,7 +69,7 @@
6869
class="input-text"
6970
type="text"
7071
maxlength="<?= $block->escapeHtmlAttr($maxQueryLength) ?>"
71-
data-validate="{number:true, 'less-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>_to'}" />
72+
data-validate="{number:true, 'validate-not-negative-number':true, 'less-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>_to'}" />
7273
</div>
7374
</div>
7475
<div class="field with-addon no-label">
@@ -81,7 +82,7 @@
8182
class="input-text"
8283
type="text"
8384
maxlength="<?= $block->escapeHtmlAttr($maxQueryLength) ?>"
84-
data-validate="{number:true, 'greater-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>'}" />
85+
data-validate="{number:true, 'validate-not-negative-number':true, 'greater-than-equals-to':'#<?= $block->escapeHtmlAttr($_code) ?>'}" />
8586
<label class="addafter"
8687
for="<?= $block->escapeHtmlAttr($_code) ?>_to">
8788
<?= $block->escapeHtml($block->getCurrency($_attribute)) ?>

0 commit comments

Comments
 (0)