Skip to content

Commit 27945bc

Browse files
Lilit5Yauhen_Lyskavets
authored andcommitted
MC-16455: Admin user with permission for 1 store can manage categories
- Added automation test script.
1 parent 7ea4c6c commit 27945bc

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AdminCategoryProductsSection">
1212
<element name="sectionHeader" type="button" selector="div[data-index='assign_products']" timeout="30"/>
1313
<element name="addProducts" type="button" selector="#catalog_category_add_product_tabs" timeout="30"/>
14+
<element name="addProductsDisabled" type="button" selector="#catalog_category_add_product_tabs[disabled]" timeout="30"/>
1415
</section>
1516
</sections>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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="AdminManageCategoriesByUserWithPermissionFor1StoreTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<stories value="user role"/>
15+
<title value="Ability to manage categories by admin user with permission for 1 store"/>
16+
<description value="Ability to manage categories by admin user with permission for 1 store"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-19264"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
<!--Create new store and store view-->
24+
<comment userInput="Create new store and store view" stepKey="createStoreAndStoreView"/>
25+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createStore1">
26+
<argument name="website" value="Main Website"/>
27+
<argument name="storeGroupName" value="{{SecondStoreGroupUnique.name}}"/>
28+
<argument name="storeGroupCode" value="{{SecondStoreGroupUnique.code}}"/>
29+
</actionGroup>
30+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreViewA"/>
31+
<!--Create simple category and product-->
32+
<comment userInput="Create simple product and category" stepKey="createCategoryAndProduct"/>
33+
<createData entity="_defaultCategory" stepKey="createCategory"/>
34+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
35+
<requiredEntity createDataKey="createCategory"/>
36+
</createData>
37+
<!--Create restricted user role-->
38+
<actionGroup ref="AdminAddNewUserRoleWithCustomRoleScopes" stepKey="createLimitedRole">
39+
<argument name="role" value="restrictedRole"/>
40+
<argument name="customWebsiteName" value="{{SecondStoreGroupUnique.name}}"/>
41+
</actionGroup>
42+
<!--Create admin user with restricted role-->
43+
<comment userInput="Create admin user with restricted role" stepKey="createUserWithRestrictedRole"/>
44+
<actionGroup ref="AdminCreateUserWithRoleActionGroup" stepKey="createRestrictedAdmin">
45+
<argument name="role" value="restrictedRole"/>
46+
<argument name="user" value="Admin3"/>
47+
</actionGroup>
48+
</before>
49+
<after>
50+
<!--Delete product and category-->
51+
<comment userInput="Delete product and category" stepKey="deleteProdAndCategory"/>
52+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
53+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
54+
<actionGroup ref="logout" stepKey="logout"/>
55+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
56+
<!-- Delete User-->
57+
<comment userInput="Delete User" stepKey="deleteUser"/>
58+
<actionGroup ref="AdminDeleteCreatedUserActionGroup" stepKey="deleteLimitedUser">
59+
<argument name="user" value="Admin3"/>
60+
</actionGroup>
61+
<!--Delete users roles-->
62+
<comment userInput="Delete users roles" stepKey="deleteUserRole"/>
63+
<actionGroup ref="AdminDeleteUserRoleWithSpecifiedPermissionActionGroup" stepKey="deleteRestrictedRole">
64+
<argument name="role" value="restrictedRole"/>
65+
</actionGroup>
66+
<!--Delete store view-->
67+
<comment userInput="Delete store view" stepKey="deleteStoreView"/>
68+
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteFirstStoreView">
69+
<argument name="customStore" value="customStore"/>
70+
</actionGroup>
71+
</after>
72+
<!--Login as restricted user-->
73+
<comment userInput="Login as restricted user" stepKey="loginAsRestrictedUser"/>
74+
<actionGroup ref="logout" stepKey="logout"/>
75+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin">
76+
<argument name="adminUser" value="Admin3"/>
77+
</actionGroup>
78+
<!--Open Product page-->
79+
<comment userInput="openProductPage" stepKey="openProdPage"/>
80+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="visitAdminProductPage"/>
81+
<waitForPageLoad stepKey="waitForPageLoad"/>
82+
<!--Check that ability to manage category is disabled-->
83+
<comment userInput="Check that ability to manage category is disabled" stepKey="checkAbilityToManageCategory"/>
84+
<grabAttributeFrom userInput="class" selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="grabAttributeFromInput"/>
85+
<assertContains expectedType="string" expected="disabled" actual="$grabAttributeFromInput" stepKey="assertCategoryIsDisabled"/>
86+
<!--Go to created category page-->
87+
<comment userInput="Go to created category page" stepKey="visitAdminCategoryPage"/>
88+
<actionGroup ref="goToAdminCategoryPageById" stepKey="goToAdminCategoryPage0">
89+
<argument name="id" value="$$createCategory.id$$"/>
90+
</actionGroup>
91+
<!--Expand products in category tab-->
92+
<comment userInput="Expand products in category tab" stepKey="expandProductsInCategoryTab"/>
93+
<conditionalClick selector="{{AdminCategoryProductsSection.sectionHeader}}" dependentSelector="{{AdminCategoryProductsSection.matchByRule}}" visible="false" stepKey="openProductsInCategoryTab"/>
94+
<!--Check that the ability to add product is disabled-->
95+
<comment userInput="Check that the ability to add product is disabled" stepKey="checkAbilityToAddProduct"/>
96+
<seeElement selector="{{AdminCategoryProductsSection.addProductsDisabled}}" stepKey="checkAbilityToAddProductIsDisabled"/>
97+
</test>
98+
</tests>

0 commit comments

Comments
 (0)