Skip to content

Commit 68599ef

Browse files
committed
MC-170: Admin should be able to create new group in an Attribute Set
1 parent 1e7ea98 commit 68599ef

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@
1717
<element name="assignedAttribute" type="text" selector="//*[@id='tree-div1']//span[text()='{{attributeName}}']" parameterized="true"/>
1818
<element name="xThLineItemYthAttributeGroup" type="text" selector="//*[@id='tree-div1']/ul/div/li[{{y}}]//li[{{x}}]" parameterized="true"/>
1919
<element name="xThLineItemAttributeGroup" type="text" selector="//*[@id='tree-div1']//span[text()='{{groupName}}']/parent::*/parent::*/parent::*//li[{{x}}]//a/span" parameterized="true"/>
20+
<element name="attributesInGroup" type="text" selector="//span[text()='{{GroupName}}']/../../following-sibling::ul/li" parameterized="true"/>
2021
<!-- Unassigned Attributes Column -->
2122
<element name="unassignedAttributesTree" type="block" selector="#tree-div2"/>
2223
<element name="unassignedAttribute" type="text" selector="//*[@id='tree-div2']//span[text()='{{attributeName}}']" parameterized="true"/>
2324
<element name="xThLineItemUnassignedAttribute" type="text" selector="//*[@id='tree-div2']//li[{{x}}]//a/span" parameterized="true"/>
25+
<!-- Buttons -->
26+
<element name="AddNewGroup" type="button" selector="button[data-ui-id='adminhtml-catalog-product-set-edit-add-group-button']"/>
27+
<!-- Modal Window Add New Group -->
28+
<element name="newGroupName" type="input" selector="input[data-role='promptField']"/>
29+
<element name="buttonOk" type="button" selector=".modal-footer .action-primary.action-accept"/>
30+
<element name="errorLabel" type="text" selector="label.mage-error"/>
2431
</section>
2532
</sections>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,7 @@
207207
<element name="textAttributeByName" type="text" selector="//div[@data-index='attributes']//fieldset[contains(@class, 'admin__field') and .//*[contains(.,'{{var}}')]]//input" parameterized="true"/>
208208
<element name="dropDownAttribute" type="select" selector="//select[@name='product[{{arg}}]']" parameterized="true" timeout="30"/>
209209
<element name="attributeSection" type="block" selector="//div[@data-index='attributes']/div[contains(@class, 'admin__collapsible-content _show')]" timeout="30"/>
210+
<element name="attributeGroupByName" type="button" selector="//div[@class='fieldset-wrapper-title']//span[text()='{{group}}']" parameterized="true"/>
211+
<element name="attributeByGroupAndName" type="text" selector="//div[@class='fieldset-wrapper-title']//span[text()='{{group}}']/../../following-sibling::div//span[contains(text(),'attribute')]" parameterized="true"/>
210212
</section>
211213
</sections>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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="AdminCreateNewGroupForAttributeSetTest">
12+
<annotations>
13+
<stories value="Edit attribute set"/>
14+
<title value="Admin should be able to create new group in an Attribute Set"/>
15+
<description value="The test verifies creating a new group in an attribute set and a validation message in case of empty group name"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-170"/>
18+
<group value="Catalog"/>
19+
</annotations>
20+
<before>
21+
<!-- Create a custom attribute set and custom product attribute -->
22+
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
23+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
24+
</before>
25+
<after>
26+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
27+
<actionGroup ref="logout" stepKey="logout"/>
28+
</after>
29+
<!-- Login to Admin -->
30+
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
31+
32+
<!-- Navigate to Stores > Attributes > Attribute Set -->
33+
<amOnPage url="{{AdminProductAttributeSetGridPage.url}}" stepKey="goToAttributeSetPage"/>
34+
<waitForPageLoad stepKey="waitForPageLoad"/>
35+
36+
<!-- Search and open Attribute Set from preconditions -->
37+
<actionGroup ref="goToAttributeSetByName" stepKey="searchAttribute">
38+
<argument name="name" value="$$createAttributeSet.attribute_set_name$$"/>
39+
</actionGroup>
40+
41+
<!-- Click 'Add New': Show 'New Group' Modal -->
42+
<click selector="{{AdminProductAttributeSetEditSection.AddNewGroup}}" stepKey="clickAddNew"/>
43+
<waitForAjaxLoad stepKey="waitForAjax"/>
44+
45+
<!-- Fill 'name' for new group and click 'Ok': Name = <empty> -->
46+
<fillField userInput="" selector="{{AdminProductAttributeSetEditSection.newGroupName}}" stepKey="fillName"/>
47+
<click selector="{{AdminProductAttributeSetEditSection.buttonOk}}" stepKey="clickOk"/>
48+
49+
<!-- Error message 'This is a required field.' is displayed -->
50+
<see userInput="This is a required field." selector="{{AdminProductAttributeSetEditSection.errorLabel}}" stepKey="seeErrorMessage"/>
51+
52+
<!-- Fill 'name' for new group and click 'Ok': Name = Custom group -->
53+
<fillField userInput="Custom group" selector="{{AdminProductAttributeSetEditSection.newGroupName}}" stepKey="fillCustomGroupName"/>
54+
<click selector="{{AdminProductAttributeSetEditSection.buttonOk}}" stepKey="clickButtonOk"/>
55+
56+
<!-- Group is created and displayed in 'Groups' block -->
57+
<seeElement selector="{{AdminProductAttributeSetEditSection.attributeGroup('Custom group')}}" stepKey="assertCustomGroup"/>
58+
59+
<!-- Move custom Product Attribute to new 'Custom group' Group -->
60+
<waitForAjaxLoad stepKey="waitForAjaxLoad"/>
61+
<click selector="{{AdminProductAttributeSetEditSection.attributeGroupExtender('Custom group')}}" stepKey="click"/>
62+
<waitForPageLoad stepKey="waitForPageLoadAfterClick"/>
63+
<dragAndDrop selector1="{{AdminProductAttributeSetEditSection.unassignedAttribute($$createConfigProductAttribute.attribute_code$$)}}" selector2="{{AdminProductAttributeSetEditSection.attributeGroupExtender('Custom group')}}" stepKey="moveAttribute"/>
64+
<waitForPageLoad stepKey="waitForDragAndDrop"/>
65+
66+
<!-- Attribute is displayed in the new group -->
67+
<see userInput="$$createConfigProductAttribute.attribute_code$$" selector="{{AdminProductAttributeSetEditSection.groupTree}}" stepKey="seeAttribute"/>
68+
69+
<!-- Click 'Save' -->
70+
<actionGroup ref="SaveAttributeSet" stepKey="saveAttribute"/>
71+
72+
<actionGroup ref="goToAttributeSetByName" stepKey="backTohAttributeSet">
73+
<argument name="name" value="$$createAttributeSet.attribute_set_name$$"/>
74+
</actionGroup>
75+
76+
<!-- Create another group: Name = Empty group -->
77+
<click selector="{{AdminProductAttributeSetEditSection.AddNewGroup}}" stepKey="clickAddEmptyGroup"/>
78+
<waitForAjaxLoad stepKey="waitForLoad"/>
79+
80+
<fillField userInput="Empty group" selector="{{AdminProductAttributeSetEditSection.newGroupName}}" stepKey="fillGroupName"/>
81+
<click selector="{{AdminProductAttributeSetEditSection.buttonOk}}" stepKey="clickOnOk"/>
82+
<waitForPageLoad stepKey="waitForNewGroup"/>
83+
84+
<!-- Empty group is created. No attributes are assigned to it. -->
85+
<seeElement selector="{{AdminProductAttributeSetEditSection.attributeGroup('Empty group')}}" stepKey="assertEmptyGroup"/>
86+
<dontSeeElement selector="{{AdminProductAttributeSetEditSection.attributesInGroup('Empty group')}}" stepKey="seeNoAttributes"/>
87+
88+
<!-- Navigate to Catalog > Products -->
89+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductPage"/>
90+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
91+
92+
<!-- Start to create a new simple product with the custom attribute set from the preconditions -->
93+
<click selector="{{AdminProductGridActionSection.addProductBtn}}" stepKey="clickAddProduct"/>
94+
<waitForPageLoad stepKey="waitForNewProductPage"/>
95+
96+
<actionGroup ref="AdminProductPageSelectAttributeSet" stepKey="selectAttribute">
97+
<argument name="attributeSetName" value="$$createAttributeSet.attribute_set_name$$"/>
98+
</actionGroup>
99+
100+
<!-- New Section 'Custom group' is present in form. The section contains the attribute from preconditions -->
101+
<seeElement selector="{{AdminProductAttributeSection.attributeGroupByName('Custom group')}}" stepKey="seeSectionCustomGroup"/>
102+
<click selector="{{AdminProductAttributeSection.attributeGroupByName('Custom group')}}" stepKey="openCustomGroupSection"/>
103+
<waitForAjaxLoad stepKey="waitForOpenSection"/>
104+
<scrollTo selector="//footer" stepKey="scrollToFooter"/>
105+
<seeElement selector="{{AdminProductAttributeSection.attributeByGroupAndName('Custom group')}}" stepKey="seeAttributePresent"/>
106+
107+
<!-- Empty section is absent in Product Form -->
108+
<dontSeeElement selector="{{AdminProductAttributeSection.attributeGroupByName('Empty group')}}" stepKey="dontSeeEmptyGroup"/>
109+
</test>
110+
</tests>

0 commit comments

Comments
 (0)