diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml index 56488b206f3f6..50b4165a3f34b 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml @@ -233,4 +233,23 @@ + + + + Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data. + + + + + + + + + + + + + + + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml index 75a7484324576..2920a895f607d 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml @@ -173,4 +173,19 @@ Free Shipping in conditions Free Shipping in conditions + + + CatalogPriceRule + Catalog Price Rule Description + 1 + + 0 + + + 1 + + by_percent + 10 + ten + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml index 004ce09efa903..7d375da6dfb65 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml @@ -37,6 +37,8 @@ + +
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml index 09b924603c54a..ee61af180d350 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml @@ -196,4 +196,27 @@ + + + + + + + <description value="Admin can not create catalog price rule with the invalid data"/> + <severity value="MAJOR"/> + <group value="CatalogRule"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> + </after> + + <actionGroup ref="newCatalogPriceRuleWithInvalidData" stepKey="createNewPriceRule"> + <argument name="catalogRule" value="catalogRuleWithInvalid"/> + </actionGroup> + + <see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seeSortOrderError"/> + </test> </tests> diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml index 2af8bb0770b20..59e3c4668e8a4 100644 --- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml +++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml @@ -208,6 +208,9 @@ </item> </argument> <settings> + <validation> + <rule name="validate-digits" xsi:type="boolean">true</rule> + </validation> <dataType>text</dataType> <label translate="true">Priority</label> <dataScope>sort_order</dataScope> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml index 39ea70ddc3df7..4a39e1237841d 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml @@ -464,4 +464,13 @@ <requiredEntity type="SalesRuleLabel">SalesRuleLabelDefault</requiredEntity> <requiredEntity type="SalesRuleLabel">SalesRuleLabelStore1</requiredEntity> </entity> + + <entity name="TestSalesRuleWithInvalidData" type="SalesRule"> + <data key="userPerCustomer">one</data> + <data key="userPerCoupon">one</data> + <data key="priority">one</data> + <data key="discountStep">one</data> + <data key="discountAmount">one</data> + <data key="maximumQtyDiscount">one</data> + </entity> </entities> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml index 39399152f5fab..b164cdde33248 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml @@ -99,5 +99,6 @@ <element name="generateCouponsButton" type="button" selector="#coupons_generate_button" timeout="30"/> <element name="generatedCouponByIndex" type="text" selector="#couponCodesGrid_table > tbody > tr:nth-child({{var}}) > td.col-code" parameterized="true"/> <element name="couponGridUsedHeader" type="text" selector="#couponCodesGrid thead th[data-sort='used']"/> + <element name="fieldError" type="text" selector="//input[@name='{{fieldName}}']/following-sibling::label[@class='admin__field-error']" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml new file mode 100644 index 0000000000000..620112e323ff5 --- /dev/null +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml @@ -0,0 +1,53 @@ +<?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="AdminCreateInvalidRuleTest"> + <annotations> + <features value="SalesRule"/> + <stories value="Create cart price rule with invalid data"/> + <title value="Admin can not create rule with invalid data"/> + <description value="Admin can not create rule with invalid data"/> + <severity value="MAJOR"/> + <group value="SalesRule"/> + </annotations> + + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + + <after> + <actionGroup ref="logout" stepKey="adminLogout"/> + </after> + + <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="amOnCartPriceList"/> + <waitForPageLoad stepKey="waitForRulesPage"/> + <click selector="{{AdminCartPriceRulesSection.addNewRuleButton}}" stepKey="clickAddNewRule"/> + + <click selector="{{AdminCartPriceRulesFormSection.actionsHeader}}" stepKey="clickToExpandActions"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.apply}}" userInput="Buy X get Y free (discount amount is Y)" stepKey="selectActionType"/> + <fillField selector="{{AdminCartPriceRulesFormSection.discountAmount}}" userInput="{{TestSalesRuleWithInvalidData.discountAmount}}" stepKey="fillDiscountAmount"/> + <fillField selector="{{AdminCartPriceRulesFormSection.maximumQtyDiscount}}" userInput="{{TestSalesRuleWithInvalidData.maximumQtyDiscount}}" stepKey="fillDiscountQty"/> + <fillField selector="{{AdminCartPriceRulesFormSection.discountStep}}" userInput="{{TestSalesRuleWithInvalidData.discountStep}}" stepKey="fillDiscountStep"/> + + <fillField selector="{{AdminCartPriceRulesFormSection.userPerCustomer}}" userInput="{{TestSalesRuleWithInvalidData.userPerCustomer}}" stepKey="fillUsePerCustomer"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="Specific Coupon" stepKey="selectCouponType"/> + <fillField selector="{{AdminCartPriceRulesFormSection.userPerCoupon}}" userInput="{{TestSalesRuleWithInvalidData.userPerCoupon}}" stepKey="fillUsePerCoupon"/> + <fillField selector="{{AdminCartPriceRulesFormSection.priority}}" userInput="{{TestSalesRuleWithInvalidData.priority}}" stepKey="fillPriority"/> + + <click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/> + + <see selector="{{AdminNewCatalogPriceRule.fieldError('uses_per_coupon')}}" userInput="Please enter a valid number in this field." stepKey="seePerCouponError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('uses_per_customer')}}" userInput="Please enter a valid number in this field." stepKey="seePerCustomerError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('sort_order')}}" userInput="Please enter a valid number in this field." stepKey="seePriorityError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('discount_amount')}}" userInput="Please enter a valid number in this field." stepKey="seeDiscountAmountError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('discount_qty')}}" userInput="Please enter a valid number in this field." stepKey="seeMaximumQtyError"/> + <see selector="{{AdminNewCatalogPriceRule.fieldError('discount_step')}}" userInput="Please enter a valid number in this field." stepKey="seeDiscountStepError"/> + </test> +</tests> diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml index 639e12006232b..e1c12f45012ee 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml +++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml @@ -297,6 +297,9 @@ </item> </argument> <settings> + <validation> + <rule name="validate-digits" xsi:type="boolean">true</rule> + </validation> <dataType>text</dataType> <label translate="true">Uses per Coupon</label> <dataScope>uses_per_coupon</dataScope> @@ -309,6 +312,9 @@ </item> </argument> <settings> + <validation> + <rule name="validate-digits" xsi:type="boolean">true</rule> + </validation> <notice translate="true"> Usage limit enforced for logged in customers only. </notice> @@ -356,6 +362,9 @@ </item> </argument> <settings> + <validation> + <rule name="validate-digits" xsi:type="boolean">true</rule> + </validation> <dataType>text</dataType> <label translate="true">Priority</label> <dataScope>sort_order</dataScope> @@ -422,6 +431,8 @@ <settings> <validation> <rule name="required-entry" xsi:type="boolean">true</rule> + <rule name="validate-number" xsi:type="boolean">true</rule> + <rule name="validate-zero-or-greater" xsi:type="boolean">true</rule> </validation> <dataType>text</dataType> <label translate="true">Discount Amount</label> @@ -435,6 +446,10 @@ </item> </argument> <settings> + <validation> + <rule name="validate-number" xsi:type="boolean">true</rule> + <rule name="validate-zero-or-greater" xsi:type="boolean">true</rule> + </validation> <dataType>text</dataType> <label translate="true">Maximum Qty Discount is Applied To</label> <dataScope>discount_qty</dataScope> @@ -447,6 +462,10 @@ </item> </argument> <settings> + <validation> + <rule name="validate-number" xsi:type="boolean">true</rule> + <rule name="validate-zero-or-greater" xsi:type="boolean">true</rule> + </validation> <dataType>text</dataType> <label translate="true">Discount Qty Step (Buy X)</label> <dataScope>discount_step</dataScope>