Skip to content

Commit 8ef08d0

Browse files
committed
Merge branch 'MC-248' into RE-develop
2 parents b65ba22 + 784c1e1 commit 8ef08d0

File tree

5 files changed

+160
-0
lines changed

5 files changed

+160
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
11+
12+
13+
<actionGroup name="CreateCustomRadioOptions">
14+
15+
<!-- ActionGroup will add a single custom option to a product -->
16+
<!-- You must already be on the product creation page -->
17+
<arguments>
18+
<argument name="customOptionName"/>
19+
<argument name="productOption"/>
20+
<argument name="productOption2"/>
21+
</arguments>
22+
23+
<!-- opens the custom option panel and clicks add options -->
24+
<click stepKey="openCustomizableOptions" selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}"/>
25+
<click stepKey="clickAddOptions" selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}"/>
26+
27+
<!-- Fill in the option and select the type of radio (once) -->
28+
<fillField stepKey="fillInOptionTitle" selector="{{AdminProductCustomizableOptionsSection.lastOptionTitle}}" userInput="{{customOptionName}}"/>
29+
<click stepKey="clickOptionTypeParent" selector="{{AdminProductCustomizableOptionsSection.lastOptionTypeParent}}"/>
30+
<click stepKey="clickOptionType" selector="{{AdminProductCustomizableOptionsSection.optionType('Radio Buttons')}}"/>
31+
32+
<!-- Add three radio options based on the parameter -->
33+
<click stepKey="clickAddValue" selector="{{AdminProductCustomizableOptionsSection.addValue}}"/>
34+
35+
<fillField stepKey="fillInValueTitle" selector="{{AdminProductCustomizableOptionsSection.valueTitle}}" userInput="{{productOption.title}}"/>
36+
<fillField stepKey="fillInValuePrice" selector="{{AdminProductCustomizableOptionsSection.valuePrice}}" userInput="{{productOption.price}}"/>
37+
38+
<click stepKey="clickAddValue2" selector="{{AdminProductCustomizableOptionsSection.addValue}}"/>
39+
40+
<fillField stepKey="fillInValueTitle2" selector="{{AdminProductCustomizableOptionsSection.valueTitle}}" userInput="{{productOption2.title}}"/>
41+
<fillField stepKey="fillInValuePrice2" selector="{{AdminProductCustomizableOptionsSection.valuePrice}}" userInput="{{productOption2.price}}"/>
42+
43+
<!-- close the custom option dropdown -->
44+
<click stepKey="closeCustomizableOptions" selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}"/>
45+
46+
</actionGroup>
47+
48+
</actionGroups>

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Data/ProductOptionData.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
<data key="price_type">fixed</data>
1919
<data key="max_characters">0</data>
2020
</entity>
21+
<entity name="ProductOptionField2" type="product_option">
22+
<var key="product_sku" entityType="product" entityKey="sku" />
23+
<data key="title">OptionField2</data>
24+
<data key="type">field</data>
25+
<data key="is_require">true</data>
26+
<data key="sort_order">1</data>
27+
<data key="price">20</data>
28+
<data key="price_type">fixed</data>
29+
<data key="max_characters">0</data>
30+
</entity>
2131
<entity name="ProductOptionArea" type="product_option">
2232
<var key="product_sku" entityType="product" entityKey="sku" />
2333
<data key="title">OptionArea</data>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,14 @@
2323
<element name="clickSelectPriceType" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody//tr[@data-repeat-index='{{var2}}']//span[text()='Price Type']/parent::label/parent::div//select" parameterized="true"/>
2424
<element name="checkboxUseDefaultTitle" type="checkbox" selector="//span[text()='Option Title']/parent::label/parent::div/div//input[@type='checkbox']"/>
2525
<element name="checkboxUseDefaultOption" type="checkbox" selector="//table[@data-index='values']//tbody//tr[@data-repeat-index='{{var1}}']//div[@class='admin__field-control']//input[@type='checkbox']" parameterized="true"/>
26+
27+
<!-- Elements that make it easier to select the most recently added element -->
28+
<element name="lastOptionTitle" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, '_required')]//input" />
29+
<element name="lastOptionTypeParent" type="block" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__action-multiselect-text')]" />
30+
<!-- var 1 represents the option type that you want to select, i.e "radio buttons" -->
31+
<element name="optionType" type="block" selector="//*[@data-index='custom_options']//label[text()='{{var1}}'][ancestor::*[contains(@class, '_active')]]" parameterized="true" />
32+
<element name="addValue" type="button" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[@data-action='add_new_row']" />
33+
<element name="valueTitle" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__control-table')]//tbody/tr[last()]//*[@data-index='title']//input" />
34+
<element name="valuePrice" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__control-table')]//tbody/tr[last()]//*[@data-index='price']//input" />
2635
</section>
2736
</sections>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
<element name="productOptionAreaInput" type="textarea" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//textarea" parameterized="true"/>
2424
<element name="productOptionFile" type="file" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'OptionFile')]/../div[@class='control']//input[@type='file']" parameterized="true"/>
2525
<element name="productOptionSelect" type="select" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//select" parameterized="true"/>
26+
27+
28+
<!-- The parameter is the nth custom option that you want to get -->
29+
<element name="nthCustomOption" type="block" selector="//*[@id='product-options-wrapper']/*[@class='fieldset']/*[contains(@class, 'field')][{{customOptionNum}}]" parameterized="true" />
30+
<!-- The 1st parameter is the nth custom option, the 2nd parameter is the nth value in the option -->
31+
<element name="nthCustomOptionInput" type="radio" selector="//*[@id='product-options-wrapper']/*[@class='fieldset']/*[contains(@class, 'field')][{{customOptionNum}}]//*[contains(@class, 'admin__field-option')][{{customOptionValueNum}}]//input" parameterized="true" />
2632
<element name="productOptionRadioButtonsCheckbox" type="checkbox" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//input[@price='{{var2}}']" parameterized="true"/>
33+
2734
<element name="productOptionDataMonth" type="date" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//legend[contains(.,'{{var1}}')]/../div[@class='control']//select[@data-calendar-role='month']" parameterized="true"/>
2835
<element name="productOptionDataDay" type="date" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//legend[contains(.,'{{var1}}')]/../div[@class='control']//select[@data-calendar-role='day']" parameterized="true"/>
2936
<element name="productOptionDataYear" type="date" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//legend[contains(.,'{{var1}}')]/../div[@class='control']//select[@data-calendar-role='year']" parameterized="true"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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="SimpleProductTwoCustomOptionsTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Create simple product with two custom options" />
15+
<title value="Admin should be able to create simple product with two custom options"/>
16+
<description value="Admin should be able to create simple product with two custom options"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="MC-248"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<!-- log in as admin -->
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
25+
<!--Create product-->
26+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
27+
<waitForPageLoad stepKey="waitForProductIndexPage"/>
28+
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateSimpleProduct">
29+
<argument name="product" value="SimpleProduct3"/>
30+
</actionGroup>
31+
<actionGroup ref="fillMainProductFormNoWeight" stepKey="fillSimpleProductMain">
32+
<argument name="product" value="SimpleProduct3"/>
33+
</actionGroup>
34+
</before>
35+
<after>
36+
<!-- Delete the created product -->
37+
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
38+
<argument name="product" value="SimpleProduct3"/>
39+
</actionGroup>
40+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
41+
</after>
42+
<!-- ADD TEST STEPS HERE -->
43+
44+
<!-- Create a custom option with 2 values -->
45+
<actionGroup ref="CreateCustomRadioOptions" stepKey="createCustomOption1">
46+
<argument name="customOptionName" value="ProductOptionRadiobutton.title"/>
47+
<argument name="productOption" value="ProductOptionField"/>
48+
<argument name="productOption2" value="ProductOptionField2"/>
49+
</actionGroup>
50+
51+
<!-- Create another custom option with 2 values -->
52+
<actionGroup ref="CreateCustomRadioOptions" stepKey="createCustomOption2">
53+
<argument name="customOptionName" value="ProductOptionRadiobutton.title"/>
54+
<argument name="productOption" value="ProductOptionField"/>
55+
<argument name="productOption2" value="ProductOptionField2"/>
56+
</actionGroup>
57+
58+
<!-- Save the product -->
59+
<click stepKey="saveProduct" selector="{{AdminProductFormActionSection.saveButton}}"/>
60+
<waitForPageLoad stepKey="waitForProductSaved"/>
61+
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccess"/>
62+
63+
<!-- navigate to the created product page -->
64+
<amOnPage url="/{{SimpleProduct3.name}}.html" stepKey="goToCreatedProduct"/>
65+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
66+
67+
<!-- Check to make sure all of the created names are there -->
68+
<see stepKey="assertNameInFirstOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('1')}}" userInput="{{ProductOptionField.title}}"/>
69+
<see stepKey="assertNameInSecondOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('2')}}" userInput="{{ProductOptionField.title}}"/>
70+
<see stepKey="assertSecondNameInFirstOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('1')}}" userInput="{{ProductOptionField2.title}}"/>
71+
<see stepKey="assertSecondNameInSecondOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('2')}}" userInput="{{ProductOptionField2.title}}"/>
72+
73+
<!-- Check to see that all of the created prices are there -->
74+
<see stepKey="assertPriceInFirstOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('1')}}" userInput="{{ProductOptionField.price}}"/>
75+
<see stepKey="assertPriceInSecondOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('2')}}" userInput="{{ProductOptionField.price}}"/>
76+
<see stepKey="assertSecondPriceInFirstOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('1')}}" userInput="{{ProductOptionField2.price}}"/>
77+
<see stepKey="assertSecondPriceInSecondOption" selector="{{StorefrontProductInfoMainSection.nthCustomOption('2')}}" userInput="{{ProductOptionField2.price}}"/>
78+
79+
<!-- select two of the radio buttons -->
80+
<click stepKey="selectFirstCustomOption" selector="{{StorefrontProductInfoMainSection.nthCustomOptionInput('1','2')}}"/>
81+
<click stepKey="selectSecondCustomOption" selector="{{StorefrontProductInfoMainSection.nthCustomOptionInput('2','1')}}"/>
82+
83+
<!-- Check that the price has actually changed -->
84+
<see stepKey="assertPriceHasChanged" selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="153.00"/>
85+
</test>
86+
</tests>

0 commit comments

Comments
 (0)