Skip to content

Commit a18f3b6

Browse files
committed
MC-4416: Convert CreateProductAttributeEntityTest to MFTF
- Variation MC-10894
1 parent dd03a6d commit a18f3b6

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,21 @@
4747
<seeElement selector="{{AdminProductMessagesSection.successMessage}}"
4848
stepKey="waitForSuccessMessage"/>
4949
</actionGroup>
50+
<!--Clicks createNewAttribute and fills out form-->
51+
<actionGroup name="createProductAttribute">
52+
<arguments>
53+
<argument name="attribute" type="entity" defaultValue="productAttributeWysiwyg"/>
54+
</arguments>
55+
<click stepKey="createNewAttribute" selector="{{AdminProductAttributeGridSection.NewAttribute}}"/>
56+
<fillField stepKey="fillDefaultLabel" selector="{{AttributePropertiesSection.DefaultLabel}}" userInput="{{attribute.attribute_code}}"/>
57+
<selectOption selector="{{AttributePropertiesSection.InputType}}" stepKey="checkInputType" userInput="{{attribute.frontend_input}}"/>
58+
<selectOption selector="{{AttributePropertiesSection.ValueRequired}}" stepKey="checkRequired" userInput="{{attribute.is_required_admin}}"/>
59+
<click stepKey="saveAttribute" selector="{{AttributePropertiesSection.Save}}"/>
60+
</actionGroup>
61+
<!-- Inputs default value and attribute code-->
62+
<actionGroup name="createProductAttributeWithTextField" extends="createProductAttribute" insertAfter="checkRequired">
63+
<click stepKey="openAdvancedProperties" selector="{{AdvancedAttributePropertiesSection.AdvancedAttributePropertiesSectionToggle}}"/>
64+
<fillField stepKey="fillCode" selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" userInput="{{attribute.attribute_code}}"/>
65+
<fillField stepKey="fillDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueText}}" userInput="{{attribute.default_value}}"/>
66+
</actionGroup>
5067
</actionGroups>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,9 @@
115115
<data key="used_for_sort_by">true</data>
116116
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
117117
</entity>
118+
<entity name="textProductAttribute" extends="productAttributeWysiwyg" type="ProductAttribute">
119+
<data key="frontend_input">text</data>
120+
<data key="default_value" unique="suffix">defaultValue</data>
121+
<data key="is_required_admin">No</data>
122+
</entity>
118123
</entities>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
<element name="useInLayeredNavigation" type="select" selector="#is_filterable"/>
2525
<element name="addSwatch" type="button" selector="#add_new_swatch_text_option_button"/>
2626
</section>
27+
<section name="AttributeDeleteModalSection">
28+
<element name="confirm" type="button" selector=".modal-popup.confirm button.action-accept"/>
29+
<element name="cancel" type="button" selector=".modal-popup.confirm button.action-dismiss"/>
30+
</section>
2731
<section name="AttributeManageSwatchSection">
2832
<element name="swatchField" type="input" selector="//th[contains(@class, 'col-swatch')]/span[contains(text(), '{{arg}}')]/ancestor::thead/following-sibling::tbody//input[@placeholder='Swatch']" parameterized="true"/>
2933
<element name="descriptionField" type="input" selector="//th[contains(@class, 'col-swatch')]/span[contains(text(), '{{arg}}')]/ancestor::thead/following-sibling::tbody//input[@placeholder='Description']" parameterized="true"/>
@@ -77,6 +81,10 @@
7781
<element name="AdvancedAttributePropertiesSectionToggle"
7882
type="button" selector="#advanced_fieldset-wrapper"/>
7983
<element name="AttributeCode" type="text" selector="#attribute_code"/>
84+
<element name="DefaultValueText" type="textarea" selector="#default_value_text"/>
85+
<element name="DefaultValueTextArea" type="textarea" selector="#default_value_textarea"/>
86+
<element name="DefaultValueDate" type="textarea" selector="#default_value_date"/>
87+
<element name="DefaultValueYesNo" type="textarea" selector="#default_value_yesno"/>
8088
<element name="Scope" type="select" selector="#is_global"/>
8189
<element name="AddToColumnOptions" type="select" selector="#is_used_in_grid"/>
8290
<element name="UseInFilterOptions" type="select" selector="#is_filterable_in_grid"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductAttributeGridSection">
1212
<element name="AttributeCode" type="text" selector="//td[contains(text(),'{{var1}}')]" parameterized="true" timeout="30"/>
13-
<element name="createNewAttributeBtn" type="button" selector="button[data-index='add_new_attribute_button']"/>
13+
<element name="NewAttribute" type="button" selector="#add"/>
1414
<element name="GridFilterFrontEndLabel" type="input" selector="#attributeGrid_filter_frontend_label"/>
1515
<element name="Search" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
1616
<element name="ResetFilter" type="button" selector="button[data-action='grid-filter-reset']" timeout="30"/>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="CreateProductAttributeEntityTextFieldTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="Create Product Attributes"/>
15+
<title value="Admin should be able to create a TextField product attribute"/>
16+
<description value="Admin should be able to create a TextField product attribute"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-10894"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="navigateToEditProductAttribute" stepKey="goToEditPage">
26+
<argument name="ProductAttribute" value="{{textProductAttribute.attribute_code}}"/>
27+
</actionGroup>
28+
<click stepKey="clickDelete" selector="{{AttributePropertiesSection.DeleteAttribute}}"/>
29+
<click stepKey="clickOk" selector="{{AttributeDeleteModalSection.confirm}}"/>
30+
<waitForPageLoad stepKey="waitForDeletion"/>
31+
</after>
32+
33+
<!--Navigate to Stores > Attributes > Product.-->
34+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/>
35+
36+
<!--Create new Product Attribute as TextField, with code and default value.-->
37+
<actionGroup ref="createProductAttributeWithTextField" stepKey="key1">
38+
<argument name="attribute" value="textProductAttribute"/>
39+
</actionGroup>
40+
41+
<!--Save Product Attribute.-->
42+
<actionGroup ref="navigateToEditProductAttribute" stepKey="goToEditPage">
43+
<argument name="ProductAttribute" value="{{textProductAttribute.attribute_code}}"/>
44+
</actionGroup>
45+
46+
<!--Perform appropriate assertions against textProductAttribute entity-->
47+
<seeInField stepKey="assertLabel" selector="{{AttributePropertiesSection.DefaultLabel}}" userInput="{{textProductAttribute.attribute_code}}"/>
48+
<seeOptionIsSelected stepKey="assertInputType" selector="{{AttributePropertiesSection.InputType}}" userInput="{{textProductAttribute.frontend_input}}"/>
49+
<seeOptionIsSelected stepKey="assertRequired" selector="{{AttributePropertiesSection.ValueRequired}}" userInput="{{textProductAttribute.is_required_admin}}"/>
50+
<seeInField stepKey="assertAttrCode" selector="{{AdvancedAttributePropertiesSection.AttributeCode}}" userInput="{{textProductAttribute.attribute_code}}"/>
51+
<seeInField stepKey="assertDefaultValue" selector="{{AdvancedAttributePropertiesSection.DefaultValueText}}" userInput="{{textProductAttribute.default_value}}"/>
52+
</test>
53+
</tests>

0 commit comments

Comments
 (0)