Skip to content

Commit 4b8dcbc

Browse files
committed
MAGETWO-69893: Error appears when restricted user tries to add new category from product page
- Added automated test script
1 parent 5d04e3c commit 4b8dcbc

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<element name="selectMultipleCategories" type="input" selector="//*[@data-index='container_category_ids']//*[contains(@class, '_selected')]"/>
7171
<element name="countryOfManufacture" type="select" selector="select[name='product[country_of_manufacture]']"/>
7272
<element name="newAddedAttribute" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]" parameterized="true"/>
73+
<element name="newCategoryButton" type="button" selector="button[data-index='create_category_button']" timeout="30"/>
7374
</section>
7475
<section name="ProductInWebsitesSection">
7576
<element name="sectionHeader" type="button" selector="div[data-index='websites']" timeout="30"/>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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="AdminRestrictedUserAddCategoryFromProductPageTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Adding new category from product page by restricted user"/>
15+
<description value="Adding new category from product page by restricted user"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-99063"/>
18+
<useCaseId value="MAGETWO-69893"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
<!--Create category-->
24+
<comment userInput="Create category" stepKey="commentCreateCategory"/>
25+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
26+
</before>
27+
<after>
28+
<!--Delete created product-->
29+
<comment userInput="Delete created product" stepKey="commentDeleteProduct"/>
30+
<actionGroup ref="deleteProductBySku" stepKey="deleteProduct">
31+
<argument name="sku" value="{{_defaultProduct.sku}}"/>
32+
</actionGroup>
33+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetFiltersIfExist"/>
34+
<actionGroup ref="SignOut" stepKey="signOut"/>
35+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
36+
<!--Delete created data-->
37+
<comment userInput="Delete created data" stepKey="commentDeleteCreatedData"/>
38+
<actionGroup ref="AdminDeleteCreatedRoleActionGroup" stepKey="deleteUserRole">
39+
<argument name="role" value="adminRole"/>
40+
</actionGroup>
41+
<actionGroup ref="AdminDeleteCreatedUserActionGroup" stepKey="deleteUser">
42+
<argument name="user" value="newAdmin"/>
43+
</actionGroup>
44+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
45+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
46+
</after>
47+
<!--Create user role-->
48+
<comment userInput="Create user role" stepKey="commentCreateUserRole"/>
49+
<actionGroup ref="AdminFillUserRoleRequiredData" stepKey="fillUserRoleRequiredData">
50+
<argument name="User" value="adminRole"/>
51+
<argument name="restrictedRole" value="Stores"/>
52+
</actionGroup>
53+
<click selector="{{AdminEditRoleInfoSection.roleResourcesTab}}" stepKey="clickRoleResourcesTab" />
54+
<actionGroup ref="AdminAddRestrictedRole" stepKey="addRestrictedRoleStores">
55+
<argument name="User" value="adminRole"/>
56+
<argument name="restrictedRole" value="Stores"/>
57+
</actionGroup>
58+
<actionGroup ref="AdminAddRestrictedRole" stepKey="addRestrictedRoleProducts">
59+
<argument name="User" value="adminRole"/>
60+
<argument name="restrictedRole" value="Products"/>
61+
</actionGroup>
62+
<click selector="{{AdminEditRoleInfoSection.saveButton}}" stepKey="clickSaveRoleButton" />
63+
<see userInput="You saved the role." stepKey="seeUserRoleSavedMessage"/>
64+
<!--Create user and assign role to it-->
65+
<comment userInput="Create user and assign role to it" stepKey="commentCreateUser"/>
66+
<actionGroup ref="AdminCreateUserActionGroup" stepKey="createAdminUser">
67+
<argument name="role" value="adminRole"/>
68+
<argument name="User" value="newAdmin"/>
69+
</actionGroup>
70+
<!--Log out of admin and login with newly created user-->
71+
<comment userInput="Log out of admin and login with newly created user" stepKey="commentLoginWithNewUser"/>
72+
<actionGroup ref="SignOut" stepKey="signOut"/>
73+
<actionGroup ref="LoginAsAnyUser" stepKey="loginActionGroup">
74+
<argument name="uname" value="{{newAdmin.username}}"/>
75+
<argument name="passwd" value="{{newAdmin.password}}"/>
76+
</actionGroup>
77+
<!--Go to create product page-->
78+
<comment userInput="Go to create product page" stepKey="commentGoCreateProductPage"/>
79+
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateProductPage"/>
80+
<dontSeeElement selector="{{AdminProductFormSection.newCategoryButton}}" stepKey="dontSeeNewCategoryButton"/>
81+
<!--Fill product data and assign to category-->
82+
<comment userInput="Fill product data and assign to category" stepKey="commentFillProductData"/>
83+
<actionGroup ref="fillMainProductForm" stepKey="fillMainProductForm"/>
84+
<actionGroup ref="SetCategoryByName" stepKey="addCategoryToProduct">
85+
<argument name="categoryName" value="$$createCategory.name$$"/>
86+
</actionGroup>
87+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
88+
</test>
89+
</tests>

app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateRoleActionGroup.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@
2424
<click selector="{{AdminEditRoleInfoSection.saveButton}}" stepKey="clickSaveRoleButton" />
2525
<waitForPageLoad stepKey="waitForPageLoad2" />
2626
</actionGroup>
27+
<actionGroup name="AdminFillUserRoleRequiredData" extends="AdminCreateRoleActionGroup">
28+
<remove keyForRemoval="clickRoleResourcesTab"/>
29+
<remove keyForRemoval="waitForScopeSelection"/>
30+
<remove keyForRemoval="selectResourceAccessCustom"/>
31+
<remove keyForRemoval="waitForElementVisible"/>
32+
<remove keyForRemoval="clickContentBlockCheckbox"/>
33+
<remove keyForRemoval="clickSaveRoleButton"/>
34+
<remove keyForRemoval="waitForPageLoad2"/>
35+
</actionGroup>
36+
<actionGroup name="AdminAddRestrictedRole" extends="AdminCreateRoleActionGroup">
37+
<remove keyForRemoval="navigateToNewRole"/>
38+
<remove keyForRemoval="waitForPageLoad1"/>
39+
<remove keyForRemoval="fillRoleName"/>
40+
<remove keyForRemoval="enterPassword"/>
41+
<remove keyForRemoval="clickRoleResourcesTab"/>
42+
<remove keyForRemoval="clickSaveRoleButton"/>
43+
<remove keyForRemoval="waitForPageLoad2"/>
44+
<scrollTo selector="{{AdminEditRoleInfoSection.blockName('restrictedRole')}}" x="0" y="-100" stepKey="scrollToResourceElement" after="selectResourceAccessCustom"/>
45+
</actionGroup>
2746
<!--Create new role-->
2847
<actionGroup name="AdminCreateRole">
2948
<arguments>

0 commit comments

Comments
 (0)