Skip to content

Commit edc930b

Browse files
committed
MC-233: Customer should not be able to add a Bundle Product to the cart without selecting options
1 parent 26cbef3 commit edc930b

File tree

5 files changed

+166
-1
lines changed

5 files changed

+166
-1
lines changed

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Bundle/ActionGroup/CreateBundleProductActionGroup.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,39 @@
2121
<!--Fill URL input-->
2222
<fillField userInput="{{BundleProduct.urlKey}}" selector="{{AdminProductFormBundleSection.urlKey}}" stepKey="FillsinSEOlinkExtension"/>
2323
</actionGroup>
24+
25+
<actionGroup name="addBundleOptionWithTwoProducts">
26+
<arguments>
27+
<argument name="x" type="string"/>
28+
<argument name="n" type="string"/>
29+
<argument name="prodOneSku" type="string"/>
30+
<argument name="prodTwoSku" type="string"/>
31+
<argument name="optionTitle" type="string"/>
32+
<argument name="inputType" type="string"/>
33+
</arguments>
34+
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
35+
<scrollTo selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" stepKey="scrollUpABit"/>
36+
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption"/>
37+
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle(x)}}" stepKey="waitForOptions"/>
38+
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle(x)}}" userInput="{{optionTitle}}" stepKey="fillTitle"/>
39+
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType(x)}}" userInput="{{inputType}}" stepKey="selectType"/>
40+
<waitForElementVisible selector="{{AdminProductFormBundleSection.nthAddProductsToOption(n)}}" stepKey="waitForAddBtn"/>
41+
<click selector="{{AdminProductFormBundleSection.nthAddProductsToOption(n)}}" stepKey="clickAdd"/>
42+
<waitForPageLoad stepKey="waitForAdd"/>
43+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters1"/>
44+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters1"/>
45+
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{prodOneSku}}" stepKey="fillProductSkuFilter1"/>
46+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters1"/>
47+
<waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad1" time="30"/>
48+
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectProduct1"/>
49+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters2"/>
50+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters2"/>
51+
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{prodTwoSku}}" stepKey="fillProductSkuFilter2"/>
52+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters2"/>
53+
<waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad2" time="30"/>
54+
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectProduct2"/>
55+
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddButton1"/>
56+
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity(x, '0')}}" userInput="50" stepKey="fillQuantity1"/>
57+
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity(x, '1')}}" userInput="50" stepKey="fillQuantity2"/>
58+
</actionGroup>
2459
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Bundle/Section/AdminProductFormBundleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<element name="bundleOptionXRequired" type="checkbox" selector="[name='bundle_options[bundle_options][{{x}}][required]']" parameterized="true"/>
2222
<element name="bundleOptionXProductYQuantity" type="input" selector="[name='bundle_options[bundle_options][{{x}}][bundle_selections][{{y}}][selection_qty]']" parameterized="true"/>
2323
<element name="addProductsToOption" type="button" selector="[data-index='modal_set']" timeout="30"/>
24+
<element name="nthAddProductsToOption" type="button" selector="//tr[{{var}}]//button[@data-index='modal_set']" timeout="30" parameterized="true"/>
2425
<!--Select"url Key"InputForm-->
2526
<element name="urlKey" type="input" selector="//input[@name='product[url_key]']" timeout="30"/>
2627
<!--AddSelectedProducts-->

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Bundle/Section/StorefrontBundledSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
<element name="customizeProduct" type="button" selector="//*[@id='bundle-slide']"/>
1919
<element name="customizableBundleItemOption" type="text" selector="//div[@class='field choice'][1]//input[@type='checkbox']"/>
2020
<element name="customizableBundleItemOption2" type="text" selector="//div[@class='field choice'][2]//input[@type='checkbox']"/>
21+
<element name="nthOptionDiv" type="block" selector="#product-options-wrapper div.field.option:nth-of-type({{var}})" parameterized="true"/>
2122
</section>
2223
</sections>
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="StorefrontBundleCartTest">
12+
<annotations>
13+
<features value="Bundle"/>
14+
<stories value="Bundle product details page"/>
15+
<title value="Customer should not be able to add the product to the cart without to select customisable bundle product options"/>
16+
<description value="Customer should not be able to add the product to the cart without to select customisable bundle product options"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-233"/>
19+
<group value="Bundle"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
23+
<createData entity="SimpleProduct2" stepKey="simpleProduct1"/>
24+
<createData entity="SimpleProduct2" stepKey="simpleProduct2"/>
25+
</before>
26+
<after>
27+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="logout"/>
28+
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>
29+
<deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/>
30+
</after>
31+
32+
<!-- Start creating a bundle product -->
33+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductList"/>
34+
<waitForPageLoad stepKey="waitForProductList"/>
35+
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateProduct">
36+
<argument name="product" value="BundleProduct"/>
37+
</actionGroup>
38+
<actionGroup ref="fillProductNameAndSkuInProductForm" stepKey="fillNameAndSku">
39+
<argument name="product" value="BundleProduct"/>
40+
</actionGroup>
41+
42+
<!-- Add Option One, a "Drop-down" type option -->
43+
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addBundleOptionWithTwoProducts1">
44+
<argument name="x" value="0"/>
45+
<argument name="n" value="1"/>
46+
<argument name="prodOneSku" value="$$simpleProduct1.sku$$"/>
47+
<argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/>
48+
<argument name="optionTitle" value="Option One"/>
49+
<argument name="inputType" value="select"/>
50+
</actionGroup>
51+
52+
<!-- Add Option Two, a "Radio Buttons" type option -->
53+
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addBundleOptionWithTwoProducts2">
54+
<argument name="x" value="1"/>
55+
<argument name="n" value="2"/>
56+
<argument name="prodOneSku" value="$$simpleProduct1.sku$$"/>
57+
<argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/>
58+
<argument name="optionTitle" value="Option Two"/>
59+
<argument name="inputType" value="radio"/>
60+
</actionGroup>
61+
62+
<!-- Add Option Three, a "Checkbox" type option -->
63+
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addBundleOptionWithTwoProducts3">
64+
<argument name="x" value="2"/>
65+
<argument name="n" value="3"/>
66+
<argument name="prodOneSku" value="$$simpleProduct1.sku$$"/>
67+
<argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/>
68+
<argument name="optionTitle" value="Option Three"/>
69+
<argument name="inputType" value="checkbox"/>
70+
</actionGroup>
71+
72+
<!-- Add Option Four, a "Multi Select" type option -->
73+
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addBundleOptionWithTwoProducts4">
74+
<argument name="x" value="3"/>
75+
<argument name="n" value="4"/>
76+
<argument name="prodOneSku" value="$$simpleProduct1.sku$$"/>
77+
<argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/>
78+
<argument name="optionTitle" value="Option Four"/>
79+
<argument name="inputType" value="multi"/>
80+
</actionGroup>
81+
82+
<!-- Save product and go to storefront -->
83+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
84+
<amOnPage url="{{BundleProduct.sku}}.html" stepKey="goToStorefront"/>
85+
<waitForPageLoad stepKey="waitForStorefront"/>
86+
<click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/>
87+
88+
<!-- See validation errors for all 4 options -->
89+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart1"/>
90+
<see selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="error1"/>
91+
<see selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="error2"/>
92+
<see selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="error3"/>
93+
<see selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="error4"/>
94+
95+
<!-- Fill option 1, see validation errors for 3 other options -->
96+
<selectOption selector="select.bundle-option-select" userInput="$$simpleProduct1.name$$ +$123.00" stepKey="selectOption1"/>
97+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart2"/>
98+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="error5"/>
99+
<see selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="error6"/>
100+
<see selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="error7"/>
101+
<see selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="error8"/>
102+
103+
<!-- Fill option 2, see validation errors for 2 other options -->
104+
<click selector="input[type='radio']:nth-of-type(1)" stepKey="selectOption2"/>
105+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart3"/>
106+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="error9"/>
107+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="error10"/>
108+
<see selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="error11"/>
109+
<see selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="error12"/>
110+
111+
<!-- Fill option 3, see validation errors for 1 other options -->
112+
<checkOption selector="input[type='checkbox']:nth-of-type(1)" stepKey="selectOption3"/>
113+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart4"/>
114+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="error13"/>
115+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="error14"/>
116+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="error15"/>
117+
<see selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="error16"/>
118+
119+
<!-- Fill option 4, dont see any validation errors -->
120+
<selectOption selector="select[multiple='multiple']" userInput="$$simpleProduct1.name$$ +$123.00" stepKey="selectOption4"/>
121+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart5"/>
122+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="error17"/>
123+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="error18"/>
124+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="error19"/>
125+
<dontSee selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="error20"/>
126+
</test>
127+
</tests>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminAddProductsToOptionPanelSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<element name="filters" type="button" selector=".product_form_product_form_bundle-items_modal button[data-action='grid-filter-expand']" timeout="30"/>
1414
<element name="applyFilters" type="button" selector=".product_form_product_form_bundle-items_modal [data-action='grid-filter-apply']" timeout="30"/>
1515
<element name="nameFilter" type="input" selector=".product_form_product_form_bundle-items_modal input[name='name']"/>
16-
<element name="firstCheckbox" type="input" selector="tr[data-repeat-index='0'] .admin__control-checkbox"/>
16+
<element name="firstCheckbox" type="input" selector="//tr[1]//input[@data-action='select-row']"/>
17+
<element name="nthCheckbox" type="input" selector="//tr[{{var}}]//input[@data-action='select-row']" parameterized="true"/>
1718
</section>
1819
</sections>

0 commit comments

Comments
 (0)