Skip to content

Commit c89d353

Browse files
committed
MC-42249: No form validation for negative quantity on bundle products
- Added the MFTF test for negative quantity validation on bundle products.
1 parent 068dd1f commit c89d353

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

app/code/Magento/Bundle/Test/Mftf/Section/StorefrontBundledSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@
4848
<element name="currency" type="select" selector="//a[text()='{{arg}}']" parameterized="true"/>
4949
<element name="multiSelectOption" type="select" selector="//div[@class='field option required']//select"/>
5050
<element name="validationMessageBox" type="block" selector="#validation-message-box"/>
51+
<element name="dropDownQuantityValidation" type="input" selector="//span[contains(text(), '{{productName}}')]/../..//input/following-sibling::div[@class='mage-error']" parameterized="true"/>
52+
<element name="radioButtonQuantityValidation" type="input" selector="//label//span[contains(text(), '{{productName}}')]/../..//div[@class='control']//div[@class='field qty qty-holder']//input/following-sibling::div[@class='mage-error']" parameterized="true"/>
5153
</section>
5254
</sections>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontValidateQuantityBundleProductsTest">
11+
<annotations>
12+
<features value="Bundle"/>
13+
<stories value="Bundle product details page"/>
14+
<title value="Validation for negative quantity on bundle products."/>
15+
<description value="Customer should not be able to add the products to the cart if the quantity is negative value"/>
16+
<severity value="MINOR"/>
17+
<testCaseId value="MC-42765"/>
18+
<group value="Bundle"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
22+
<createData entity="SimpleProduct2" stepKey="createProduct1"/>
23+
<createData entity="SimpleProduct2" stepKey="createProduct2"/>
24+
<magentoCron stepKey="runCronIndex" groups="index"/>
25+
</before>
26+
<after>
27+
<!-- Delete the bundled product -->
28+
<actionGroup stepKey="deleteBundle" ref="DeleteProductUsingProductGridActionGroup">
29+
<argument name="product" value="BundleProduct"/>
30+
</actionGroup>
31+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
32+
<deleteData createDataKey="createProduct1" stepKey="deleteSimpleProduct1"/>
33+
<deleteData createDataKey="createProduct2" stepKey="deleteSimpleProduct2"/>
34+
</after>
35+
36+
<!-- Start creating a bundle product -->
37+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductList"/>
38+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct">
39+
<argument name="product" value="BundleProduct"/>
40+
</actionGroup>
41+
<actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillNameAndSku">
42+
<argument name="product" value="BundleProduct"/>
43+
</actionGroup>
44+
45+
<!-- Add Option One, a "Drop-down" type option -->
46+
<actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts1">
47+
<argument name="x" value="0"/>
48+
<argument name="n" value="1"/>
49+
<argument name="prodOneSku" value="$$createProduct1.sku$$"/>
50+
<argument name="prodTwoSku" value="$$createProduct2.sku$$"/>
51+
<argument name="optionTitle" value="Option One"/>
52+
<argument name="inputType" value="select"/>
53+
</actionGroup>
54+
<checkOption selector="{{AdminProductFormBundleSection.userDefinedQuantity('0', '0')}}" stepKey="userDefinedQuantitiyOption0Product0"/>
55+
<checkOption selector="{{AdminProductFormBundleSection.userDefinedQuantity('0', '1')}}" stepKey="userDefinedQuantitiyOption0Product1"/>
56+
57+
<!-- Add Option Two, a "Radio Buttons" type option -->
58+
<actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts2">
59+
<argument name="x" value="1"/>
60+
<argument name="n" value="2"/>
61+
<argument name="prodOneSku" value="$$createProduct1.sku$$"/>
62+
<argument name="prodTwoSku" value="$$createProduct2.sku$$"/>
63+
<argument name="optionTitle" value="Option Two"/>
64+
<argument name="inputType" value="radio"/>
65+
</actionGroup>
66+
<checkOption selector="{{AdminProductFormBundleSection.userDefinedQuantity('1', '0')}}" stepKey="userDefinedQuantitiyOption1Product0"/>
67+
<checkOption selector="{{AdminProductFormBundleSection.userDefinedQuantity('1', '1')}}" stepKey="userDefinedQuantitiyOption1Product1"/>
68+
69+
<!-- Save product and go to storefront -->
70+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
71+
72+
<wait stepKey="waitBeforeIndexerAfterBundle" time="60"/>
73+
<magentoCLI command="cron:run --group=index" stepKey="runCronIndexerAfterBundle"/>
74+
75+
<amOnPage url="{{BundleProduct.sku}}.html" stepKey="goToStorefront"/>
76+
<waitForPageLoad stepKey="waitForStorefront"/>
77+
<click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/>
78+
79+
<!--"Drop-down" type option-->
80+
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$createProduct1.name$$ +$$$createProduct1.price$$.00" stepKey="selectOption0Product0"/>
81+
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$createProduct1.name$$ +$$$createProduct1.price$$.00" stepKey="checkOption0Product0"/>
82+
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-1" stepKey="fillQuantity00"/>
83+
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-1" stepKey="checkQuantity00"/>
84+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCartDropDown"/>
85+
<see selector="{{StorefrontBundledSection.dropDownQuantityValidation('Option One')}}" userInput="Please enter a quantity greater than 0." stepKey="seeQuantityNegativeErrorMessageDropDown"/>
86+
87+
<!--"Radio Buttons" type option-->
88+
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="selectOption1Product0"/>
89+
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="checkOption1Product0"/>
90+
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-1" stepKey="fillQuantity10"/>
91+
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-1" stepKey="checkQuantity10"/>
92+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCartRadioButton"/>
93+
<see selector="{{StorefrontBundledSection.radioButtonQuantityValidation('Option Two')}}" userInput="Please enter a quantity greater than 0." stepKey="seeQuantityNegativeErrorMessageRadioButton"/>
94+
</test>
95+
</tests>

0 commit comments

Comments
 (0)