Skip to content

Commit d80ac9a

Browse files
committed
33099-Added Validation for text swatch and Mftf added for visual and text swatch
1 parent 131f707 commit d80ac9a

7 files changed

+201
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminCreateAttributeTextSwatchNthValueActionGroup" >
12+
<annotations>
13+
<description>Fills in the Text swatch Field.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="row" type="string"/>
17+
<argument name="swatchNameStore" type="string"/>
18+
<argument name="storeName" type="string"/>
19+
<argument name="swatchNameAdmin" type="string"/>
20+
<argument name="adminName" type="string"/>
21+
</arguments>
22+
23+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.addValue}}" stepKey="scrollToOption"/>
24+
<click selector="{{AdminCreateNewProductAttributeSection.addValue}}" stepKey="clickOnAddSwatch"/>
25+
<waitForPageLoad stepKey="waitForNewTextSwatch"/>
26+
<fillField selector="{{AdminCreateNewProductAttributeSection.adminOptionTextSwatch(row)}}" userInput="{{swatchNameAdmin}}" stepKey="fillAdminSwatchField"/>
27+
<fillField selector="{{AdminCreateNewProductAttributeSection.adminOptionTextOption(row)}}" userInput="{{adminName}}" stepKey="fillAdminOptionField"/>
28+
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultStoreViewTextSwatch(row)}}" userInput="{{swatchNameStore}}" stepKey="fillDefaultStoreViewSwatchField"/>
29+
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultStoreViewTextOption(row)}}" userInput="{{storeName}}" stepKey="fillDefaultStoreViewOptionField"/>
30+
</actionGroup>
31+
</actionGroups>
32+
33+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminCreateAttributeVisualSwatchNthValueActionGroup" >
12+
<annotations>
13+
<description>Fills in the visual swatch Field.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="row" type="string"/>
17+
<argument name="adminName" type="string"/>
18+
<argument name="storeName" type="string"/>
19+
</arguments>
20+
21+
<scrollTo selector="{{AdminCreateNewProductAttributeSection.addValue}}" stepKey="scrollToOption"/>
22+
<click selector="{{AdminCreateNewProductAttributeSection.addValue}}" stepKey="clickOnAddSwatch"/>
23+
<waitForPageLoad stepKey="waitForNewTextSwatch"/>
24+
<waitForPageLoad stepKey="waitForNewVisualSwatch"/>
25+
<fillField selector="{{AdminCreateNewProductAttributeSection.visualSwatchAdmin(row)}}" userInput="{{adminName}}" stepKey="fillSwatchForAdmin"/>
26+
<fillField selector="{{AdminCreateNewProductAttributeSection.visualSwatchStore(row)}}" userInput="{{storeName}}" stepKey="fillSwatchForStore"/>
27+
</actionGroup>
28+
</actionGroups>
29+
30+

app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,22 @@
321321
<data key="option3_admin" unique="suffix">opt3Admin</data>
322322
<data key="option3_frontend" unique="suffix">opt3Front</data>
323323
</entity>
324+
<entity name="visualSwatchProductAttribute" extends="newProductAttribute" type="ProductAttribute">
325+
<data key="frontend_input">swatch_visual</data>
326+
<data key="frontend_input_admin">Visual Swatch</data>
327+
<data key="is_required_admin">No</data>
328+
<data key="option1_admin" unique="suffix">opt1Admin</data>
329+
<data key="option1_store" unique="suffix">opt1Front</data>
330+
</entity>
331+
<entity name="textSwatchProductAttribute" extends="newProductAttribute" type="ProductAttribute">
332+
<data key="frontend_input">text_visual</data>
333+
<data key="frontend_input_admin">Text Swatch</data>
334+
<data key="is_required_admin">No</data>
335+
<data key="swatchStore" unique="suffix">opt1swatch</data>
336+
<data key="store" unique="suffix">opt1store</data>
337+
<data key="SwatchAdmin" unique="suffix">opt1SwatchAdmin</data>
338+
<data key="admin" unique="suffix">opt1Admin</data>
339+
</entity>
324340
<entity name="dropdownProductAttributeWithQuote" extends="productAttributeWysiwyg" type="ProductAttribute">
325341
<data key="frontend_input">select</data>
326342
<data key="frontend_input_admin">Dropdown</data>

app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateNewProductAttributeSection.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,11 @@
3030
<element name="allowHtmlTags" type="checkbox" selector="//input[contains(@name, 'is_html_allowed_on_front')]/..//label"/>
3131
<element name="visibleOnStorefront" type="checkbox" selector="//input[contains(@name, 'is_visible_on_front')]/..//label"/>
3232
<element name="sortProductListing" type="checkbox" selector="//input[contains(@name, 'is_visible_on_front')]/..//label"/>
33+
<element name="visualSwatchAdmin" type="input" selector="input[name='optionvisual[value][option_{{var}}][1]']" parameterized="true"/>
34+
<element name="visualSwatchStore" type="input" selector="input[name='optionvisual[value][option_{{var}}][0]']" parameterized="true"/>
35+
<element name="adminOptionTextOption" type="input" selector="input[name='swatchtext[value][option_{{var}}][0]']" parameterized="true"/>
36+
<element name="adminOptionTextSwatch" type="input" selector="input[name='optiontext[value][option_{{var}}][0]']" parameterized="true"/>
37+
<element name="defaultStoreViewTextSwatch" type="input" selector="input[name='swatchtext[value][option_{{var}}][1]']" parameterized="true"/>
38+
<element name="defaultStoreViewTextOption" type="input" selector="input[name='optiontext[value][option_{{var}}][1]']" parameterized="true"/>
3339
</section>
3440
</sections>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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="AdminCreateProductAttributeTextSwatchFromProductPageTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Create Product Attributes"/>
14+
<title value="Admin should be able to create a Text swatch product attribute from product page"/>
15+
<description value="Admin should be able to create a Text swatch product attribute from product page"/>
16+
<severity value="BLOCKER"/>
17+
<testCaseId value="MC-42510"/>
18+
<group value="Catalog"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
25+
<after>
26+
<actionGroup ref="NavigateToEditProductAttributeActionGroup" stepKey="goToEditPage">
27+
<argument name="ProductAttribute" value="{{textSwatchProductAttribute.attribute_code}}"/>
28+
</actionGroup>
29+
<click stepKey="clickDelete" selector="{{AttributePropertiesSection.DeleteAttribute}}"/>
30+
<click stepKey="clickOk" selector="{{AttributeDeleteModalSection.confirm}}"/>
31+
<waitForPageLoad stepKey="waitForDeletion"/>
32+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
33+
</after>
34+
35+
<!-- Open Product Index Page and open Create product attribute Page-->
36+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="visitAdminProductPage"/>
37+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct"/>
38+
39+
<!-- Create product attribute-->
40+
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickAddAttributeBtn"/>
41+
<waitForText userInput="Select Attribute" stepKey="checkNewAttributePopUpAppeared"/>
42+
<click selector="{{AdminProductFormAttributeSection.createNewAttribute}}" stepKey="clickCreateNewAttribute"/>
43+
<waitForElementVisible selector="{{AdminProductFormNewAttributeSection.attributeLabel}}" stepKey="waitForAttrLabel" />
44+
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" userInput="{{textSwatchProductAttribute.attribute_code}}" stepKey="fillAttributeLabel"/>
45+
<selectOption selector="{{AdminCreateNewProductAttributeSection.inputType}}" userInput="{{textSwatchProductAttribute.frontend_input}}" stepKey="selectTextField"/>
46+
<actionGroup ref="AdminCreateAttributeTextSwatchNthValueActionGroup" stepKey="createValue">
47+
<argument name="row" value="0"/>
48+
<argument name="swatchNameStore" value="{{textSwatchProductAttribute.swatchStore}}"/>
49+
<argument name="storeName" value="{{textSwatchProductAttribute.store}}"/>
50+
<argument name="swatchNameAdmin" value="{{textSwatchProductAttribute.SwatchAdmin}}"/>
51+
<argument name="adminName" value="{{textSwatchProductAttribute.admin}}"/>
52+
</actionGroup>
53+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
54+
<click selector="{{AdminCreateNewProductAttributeSection.saveAttribute}}" stepKey="clickOnSaveAttribute"/>
55+
<waitForPageLoad stepKey="waitForAttributeToSave"/>
56+
</test>
57+
</tests>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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="AdminCreateProductAttributeVisualSwatchFromProductPageTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Create Product Attributes"/>
14+
<title value="Admin should be able to create a Visual swatch product attribute from product page"/>
15+
<description value="Admin should be able to create a Visual swatch product attribute from product page"/>
16+
<severity value="BLOCKER"/>
17+
<testCaseId value="MC-42510"/>
18+
<group value="Catalog"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
25+
<after>
26+
<actionGroup ref="NavigateToEditProductAttributeActionGroup" stepKey="goToEditPage">
27+
<argument name="ProductAttribute" value="{{visualSwatchProductAttribute.attribute_code}}"/>
28+
</actionGroup>
29+
<click stepKey="clickDelete" selector="{{AttributePropertiesSection.DeleteAttribute}}"/>
30+
<click stepKey="clickOk" selector="{{AttributeDeleteModalSection.confirm}}"/>
31+
<waitForPageLoad stepKey="waitForDeletion"/>
32+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
33+
</after>
34+
35+
<!-- Open Product Index Page and open Create product attribute Page-->
36+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="visitAdminProductPage"/>
37+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct"/>
38+
39+
<!-- Create product attribute-->
40+
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickAddAttributeBtn"/>
41+
<waitForText userInput="Select Attribute" stepKey="checkNewAttributePopUpAppeared"/>
42+
<click selector="{{AdminProductFormAttributeSection.createNewAttribute}}" stepKey="clickCreateNewAttribute"/>
43+
<waitForElementVisible selector="{{AdminProductFormNewAttributeSection.attributeLabel}}" stepKey="waitForAttrLabel" />
44+
<fillField selector="{{AdminCreateNewProductAttributeSection.defaultLabel}}" userInput="{{visualSwatchProductAttribute.attribute_code}}" stepKey="fillAttributeLabel"/>
45+
<selectOption selector="{{AdminCreateNewProductAttributeSection.inputType}}" userInput="{{visualSwatchProductAttribute.frontend_input}}" stepKey="selectTextField"/>
46+
<actionGroup ref="AdminCreateAttributeVisualSwatchNthValueActionGroup" stepKey="createValue">
47+
<argument name="row" value="0"></argument>
48+
<argument name="adminName" value="{{visualSwatchProductAttribute.option1_admin}}"></argument>
49+
<argument name="storeName" value="{{visualSwatchProductAttribute.option1_store}}"></argument>
50+
</actionGroup>
51+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
52+
<click selector="{{AdminCreateNewProductAttributeSection.saveAttribute}}" stepKey="clickOnSaveAttribute"/>
53+
<waitForPageLoad stepKey="waitForAttributeToSave"/>
54+
</test>
55+
</tests>

app/code/Magento/Swatches/view/adminhtml/ui_component/product_attribute_add_form.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@
170170
<settings>
171171
<dataType>text</dataType>
172172
<label translate="true">Admin</label>
173+
<required>true</required>
174+
<validation>
175+
<rule name="required-entry" xsi:type="boolean">true</rule>
176+
</validation>
173177
</settings>
174178
</field>
175179
<field name="position" component="Magento_Catalog/js/form/element/input" formElement="input">

0 commit comments

Comments
 (0)