Skip to content

Commit 1b66fb4

Browse files
committed
cover issue 25172 with mftf test
1 parent 79fdffb commit 1b66fb4

File tree

9 files changed

+125
-4
lines changed

9 files changed

+125
-4
lines changed

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,23 @@
208208
<waitForElementVisible selector="{{AdminMessagesSection.success}}" after="clickToConfirm" stepKey="waitForSuccessMessage"/>
209209
<see selector="{{AdminMessagesSection.success}}" userInput="You deleted the rule." after="waitForSuccessMessage" stepKey="verifyRuleIsDeleted"/>
210210
</actionGroup>
211+
212+
<actionGroup name="newCatalogPriceRuleWithInvalidData">
213+
<annotations>
214+
<description>Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data.</description>
215+
</annotations>
216+
<arguments>
217+
<argument name="catalogRule" defaultValue="catalogRuleWithInvalid"/>
218+
</arguments>
219+
220+
<!-- Go to the admin Catalog rule grid and add a new one -->
221+
<amOnPage stepKey="goToPriceRulePage" url="{{CatalogRulePage.url}}"/>
222+
<waitForPageLoad stepKey="waitForPriceRulePage"/>
223+
224+
<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
225+
<fillField stepKey="fillPriority" selector="{{AdminNewCatalogPriceRule.priority}}" userInput="{{catalogRule.priority}}"/>
226+
<scrollToTopOfPage stepKey="scrollToTop"/>
227+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/>
228+
<waitForPageLoad stepKey="waitForApplied"/>
229+
</actionGroup>
211230
</actionGroups>

app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,19 @@
173173
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
174174
<data key="defaultStoreView">Free Shipping in conditions</data>
175175
</entity>
176+
177+
<entity name="catalogRuleWithInvalid" type="catalogRule">
178+
<data key="name" unique="suffix">CatalogPriceRule</data>
179+
<data key="description">Catalog Price Rule Description</data>
180+
<data key="is_active">1</data>
181+
<array key="customer_group_ids">
182+
<item>0</item>
183+
</array>
184+
<array key="website_ids">
185+
<item>1</item>
186+
</array>
187+
<data key="simple_action">by_percent</data>
188+
<data key="discount_amount">10</data>
189+
<data key="priority">ten</data>
190+
</entity>
176191
</entities>

app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
<element name="priority" type="input" selector="[name='sort_order']"/>
3838
<element name="conditionsTab" type="block" selector="[data-index='block_promo_catalog_edit_tab_conditions']"/>
3939
<element name="actionsTab" type="block" selector="[data-index='actions']"/>
40+
41+
<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
4042
</section>
4143

4244
<section name="AdminNewCatalogPriceRuleActions">

app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,27 @@
196196
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createProduct.name$$" stepKey="seeProduct2"/>
197197
<see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$123.00" stepKey="seeDiscountedPrice2"/>
198198
</test>
199+
200+
<test name="AdminCreateCatalogPriceRuleWithInvalidDataTest">
201+
<annotations>
202+
<features value="CatalogRule"/>
203+
<stories value="Create Catalog Price Rule"/>
204+
<title value="Admin can not create catalog price rule with the invalid data"/>
205+
<description value="Admin can not create catalog price rule with the invalid data"/>
206+
<severity value="MAJOR"/>
207+
<group value="CatalogRule"/>
208+
</annotations>
209+
<before>
210+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
211+
</before>
212+
<after>
213+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
214+
</after>
215+
216+
<actionGroup ref="newCatalogPriceRuleWithInvalidData" stepKey="createNewPriceRule">
217+
<argument name="catalogRule" value="catalogRuleWithInvalid"/>
218+
</actionGroup>
219+
220+
<see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seeSortOrderError"/>
221+
</test>
199222
</tests>

app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@
209209
</argument>
210210
<settings>
211211
<validation>
212-
<rule name="validate-number" xsi:type="boolean">true</rule>
213-
<rule name="validate-zero-or-greater" xsi:type="boolean">true</rule>
212+
<rule name="validate-digits" xsi:type="boolean">true</rule>
214213
</validation>
215214
<dataType>text</dataType>
216215
<label translate="true">Priority</label>

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,13 @@
457457
<requiredEntity type="SalesRuleLabel">SalesRuleLabelDefault</requiredEntity>
458458
<requiredEntity type="SalesRuleLabel">SalesRuleLabelStore1</requiredEntity>
459459
</entity>
460+
461+
<entity name="TestSalesRuleWithInvalidData" type="SalesRule">
462+
<data key="userPerCustomer">one</data>
463+
<data key="userPerCoupon">one</data>
464+
<data key="priority">one</data>
465+
<data key="discountStep">one</data>
466+
<data key="discountAmount">one</data>
467+
<data key="maximumQtyDiscount">one</data>
468+
</entity>
460469
</entities>

app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,7 @@
9898
<element name="couponQty" type="input" selector="#coupons_qty"/>
9999
<element name="generateCouponsButton" type="button" selector="#coupons_generate_button" timeout="30"/>
100100
<element name="generatedCouponByIndex" type="text" selector="#couponCodesGrid_table > tbody > tr:nth-child({{var}}) > td.col-code" parameterized="true"/>
101+
102+
<element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/>
101103
</section>
102104
</sections>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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="AdminCreateInvalidRuleTest">
12+
<annotations>
13+
<features value="SalesRule"/>
14+
<stories value="Create cart price rule with invalid data"/>
15+
<title value="Admin can not create rule with invalid data"/>
16+
<description value="Admin can not create rule with invalid data"/>
17+
<severity value="MAJOR"/>
18+
<group value="SalesRule"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
</before>
24+
25+
<after>
26+
<actionGroup ref="logout" stepKey="adminLogout"/>
27+
</after>
28+
29+
<amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/>
30+
<waitForPageLoad stepKey="waitForRulesPage"/>
31+
<click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/>
32+
33+
<click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/>
34+
<selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Buy X get Y free (discount amount is Y)" stepKey="selectActionType"/>
35+
<fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="{{TestSalesRuleWithInvalidData.discountAmount}}" stepKey="fillDiscountAmount"/>
36+
<fillField selector="{{AdminCartPriceRulesFormSection.maximumQtyDiscount}}" userInput="{{TestSalesRuleWithInvalidData.maximumQtyDiscount}}" stepKey="fillDiscountQty"/>
37+
<fillField selector="{{AdminCartPriceRulesFormSection.discountStep}}" userInput="{{TestSalesRuleWithInvalidData.discountStep}}" stepKey="fillDiscountStep"/>
38+
39+
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCustomer}}" userInput="{{TestSalesRuleWithInvalidData.userPerCustomer}}" stepKey="fillUsePerCustomer"/>
40+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Specific Coupon" stepKey="selectCouponType"/>
41+
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCoupon}}" userInput="{{TestSalesRuleWithInvalidData.userPerCoupon}}" stepKey="fillUsePerCoupon"/>
42+
<fillField selector="{{AdminCartPriceRulesFormSection.priority}}" userInput="{{TestSalesRuleWithInvalidData.priority}}" stepKey="fillPriority"/>
43+
44+
<click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/>
45+
46+
<see selector="{{AdminNewCatalogPriceRule.fieldError('uses_per_coupon')}}" userInput="Please enter a valid number in this field." stepKey="seePerCouponError"/>
47+
<see selector="{{AdminNewCatalogPriceRule.fieldError('uses_per_customer')}}" userInput="Please enter a valid number in this field." stepKey="seePerCustomerError"/>
48+
<see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seePriorityError"/>
49+
<see selector="{{AdminNewCatalogPriceRule.fieldError('discount_amount')}}" userInput="Please enter a valid number in this field." stepKey="seeDiscountAmountError"/>
50+
<see selector="{{AdminNewCatalogPriceRule.fieldError('discount_qty')}}" userInput="Please enter a valid number in this field." stepKey="seeMaximumQtyError"/>
51+
<see selector="{{AdminNewCatalogPriceRule.fieldError('discount_step')}}" userInput="Please enter a valid number in this field." stepKey="seeDiscountStepError"/>
52+
</test>
53+
</tests>

app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@
363363
</argument>
364364
<settings>
365365
<validation>
366-
<rule name="validate-number" xsi:type="boolean">true</rule>
367-
<rule name="validate-zero-or-greater" xsi:type="boolean">true</rule>
366+
<rule name="validate-digits" xsi:type="boolean">true</rule>
368367
</validation>
369368
<dataType>text</dataType>
370369
<label translate="true">Priority</label>

0 commit comments

Comments
 (0)