Skip to content

Commit 3cec033

Browse files
committed
MQE-1714: Community MTF to MFTF test conversion code review
- minor fixes and added testCaseId
1 parent e48908d commit 3cec033

File tree

9 files changed

+141
-100
lines changed

9 files changed

+141
-100
lines changed

app/code/Magento/Security/Test/Mftf/Test/AdminUserLockWhenEditingUserTest.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
<group value="mtf_migrated"/>
2121
</annotations>
2222
<before>
23-
<!--
24-
@TODO: Remove "executeJS" in scope of MQE-1561
25-
Hack to be able to pass current admin user password without hardcoding it.
26-
-->
27-
<executeJS function="return '{{DefaultAdminUser.password}}'" stepKey="adminPassword" />
28-
<createData entity="NewAdminUser" stepKey="user">
29-
<field key="current_password">{$adminPassword}</field>
30-
</createData>
23+
<createData entity="NewAdminUser" stepKey="user" />
3124
<!-- Log in to Admin Panel -->
3225
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
3326
</before>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
<argument name="currentAdminPassword" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" />
1818
</arguments>
1919

20-
<fillField selector="{{AdminCreateRoleSection.name}}" userInput="{{role.name}}" stepKey="fillRoleName"/>
20+
<fillField selector="{{AdminCreateRoleSection.name}}" userInput="{{role.rolename}}" stepKey="fillRoleName"/>
2121
<fillField selector="{{AdminCreateRoleSection.password}}" userInput="{{currentAdminPassword}}" stepKey="fillCurrentUserPassword"/>
2222

2323
<click selector="{{AdminCreateRoleSection.roleResources}}" stepKey="clickToOpenRoleResources"/>
2424
<waitForPageLoad stepKey="waitForRoleResourceTab" />
2525

2626
<selectOption userInput="{{role.resourceAccess}}" selector="{{AdminCreateRoleSection.resourceAccess}}" stepKey="selectResourceAccess" />
27-
<performOn stepKey="checkNeededResources" selector="{{AdminCreateRoleSection.resourceTree}}" function="function($I,$userRoles={{role.resources}}){foreach($userRoles as $userRole){$I->conditionalClick('//li[@data-id=\'' . $userRole . '\']//*[@class=\'jstree-checkbox\']','//li[@data-id=\'' . $userRole . '\' and contains(@class, \'jstree-checked\')]',false);}}" />
27+
<performOn stepKey="checkNeededResources" selector="{{AdminCreateRoleSection.resourceTree}}" function="function($I,$userRoles={{role.resource}}){foreach($userRoles as $userRole){$I->conditionalClick('//li[@data-id=\'' . $userRole . '\']//*[@class=\'jstree-checkbox\']','//li[@data-id=\'' . $userRole . '\' and contains(@class, \'jstree-checked\')]',false);}}" />
2828
</actionGroup>
2929
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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="AssertAdminUserIsInGridActionGroup">
12+
<arguments>
13+
<argument name="user" type="entity"/>
14+
</arguments>
15+
<click selector="{{AdminUserGridSection.resetButton}}" stepKey="resetGridFilter"/>
16+
<waitForPageLoad stepKey="waitForFiltersReset" time="15"/>
17+
<fillField selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{user.username}}" stepKey="enterUserName"/>
18+
<click selector="{{AdminUserGridSection.searchButton}}" stepKey="clickSearch"/>
19+
<waitForPageLoad stepKey="waitForGridToLoad" time="15"/>
20+
<see selector="{{AdminUserGridSection.usernameInFirstRow}}" userInput="{{user.username}}" stepKey="seeUser"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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="AssertUserRoleRestrictedAccessActionGroup">
12+
<see selector="{{AdminHeaderSection.pageHeading}}" userInput="Sorry, you need permissions to view this content." stepKey="seeErrorMessage"/>
13+
</actionGroup>
14+
</actionGroups>

app/code/Magento/User/Test/Mftf/Data/UserData.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
<item>1</item>
3434
</array>
3535
</entity>
36+
<entity name="AdminUserWithUpdatedUserRoleToSales" extends="NewAdminUser">
37+
<data key="password">123123qA</data>
38+
<data key="password_confirmation">123123qA</data>
39+
<data key="role">{{roleSales.rolename}}</data>
40+
</entity>
41+
3642
<entity name="EditAdminUser" type="user">
3743
<data key="username" unique="suffix">admin</data>
3844
<data key="firstname">John</data>

app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,38 @@
1414
<data key="access">1</data>
1515
</entity>
1616

17-
<entity name="roleAdministrator" type="role">
18-
<data key="name" unique="suffix">Administrator </data>
17+
<entity name="roleAdministrator" type="user_role">
18+
<data key="rolename" unique="suffix">Administrator </data>
1919
<data key="resourceAccess">All</data>
20-
<data key="resources">[]</data>
20+
<data key="all">1</data>
21+
<data key="current_password">{{_ENV.MAGENTO_ADMIN_PASSWORD}}</data>
22+
<data key="resource">[]</data>
2123
</entity>
2224

23-
<entity name="roleSales" type="role">
24-
<data key="name" unique="suffix">Role Sales </data>
25+
<entity name="roleSales">
26+
<data key="rolename" unique="suffix">Role Sales </data>
2527
<data key="resourceAccess">Custom</data>
26-
<data key="resources">['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails','Magento_Backend::system','Magento_Backend::system_other_settings','Magento_AdminNotification::adminnotification','Magento_AdminNotification::show_list']</data>
28+
<data key="all">0</data>
29+
<data key="current_password">{{_ENV.MAGENTO_ADMIN_PASSWORD}}</data>
30+
<data key="resource">['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails','Magento_Backend::system_other_settings','Magento_AdminNotification::adminnotification','Magento_AdminNotification::show_list']</data>
2731
</entity>
2832

2933
<entity name="limitedRole" type="role">
30-
<data key="name" unique="suffix">Limited</data>
34+
<data key="rolename" unique="suffix">Limited</data>
3135
<data key="roleScopes">Custom</data>
3236
<data key="resourceAccess">All</data>
3337
</entity>
3438

3539
<entity name="restrictedRole" type="role">
36-
<data key="name" unique="suffix">Restricted</data>
40+
<data key="rolename" unique="suffix">Restricted</data>
3741
<data key="roleScopes">Custom</data>
3842
<data key="resourceAccess">All</data>
3943
</entity>
4044

4145
<!-- This admin created for checking turn off "Bulk Actions" -->
4246
<entity name="adminWithoutBulkActionRole" type="user_role">
4347
<data key="rolename">restrictedWebsiteRole</data>
44-
<data key="current_password">123123q</data>
48+
<data key="current_password">{{_ENV.MAGENTO_ADMIN_PASSWORD}}</data>
4549
<data key="gws_is_all">0</data>
4650
<array key="gws_websites">
4751
<item>1</item>

app/code/Magento/User/Test/Mftf/Metadata/user_role-meta.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
<operation name="CreateUserRole" dataType="user_role" type="create"
1111
auth="adminFormKey" url="/admin/user_role/saverole/" method="POST" successRegex="/messages-message-success/" returnRegex="" >
1212
<contentType>application/x-www-form-urlencoded</contentType>
13-
<field key="rolename">string</field>
14-
<field key="current_password">string</field>
15-
<array key="resource">
13+
<field key="rolename" required="true">string</field>
14+
<field key="current_password" required="true">string</field>
15+
<field key="all" required="true">integer</field>
16+
<array key="resource" required="false">
1617
<value>string</value>
1718
</array>
1819
</operation>

app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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="AdminUpdateUserTest">
12+
<annotations>
13+
<features value="User"/>
14+
<title value="Update admin user entity by changing user role"/>
15+
<stories value="Update User" />
16+
<testCaseId value="MC-14264" />
17+
<severity value="MAJOR" />
18+
<description value="Change full access role for admin user to custom one with restricted permission (Sales)"/>
19+
<group value="user"/>
20+
<group value="mtf_migrated"/>
21+
</annotations>
22+
23+
<before>
24+
<actionGroup ref="LoginAsAdmin" stepKey="logIn"/>
25+
26+
<!--Create New User-->
27+
<actionGroup ref="AdminOpenNewUserPageActionGroup" stepKey="goToNewUserPage"/>
28+
<actionGroup ref="AdminFillNewUserFormRequiredFieldsActionGroup" stepKey="fillNewUserForm">
29+
<argument name="user" value="NewAdminUser"/>
30+
</actionGroup>
31+
<actionGroup ref="AdminClickSaveButtonOnUserFormActionGroup" stepKey="saveNewUser"/>
32+
33+
<!--Create New Role-->
34+
<actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePage"/>
35+
<actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleForm">
36+
<argument name="role" value="roleSales"/>
37+
</actionGroup>
38+
<actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRole"/>
39+
</before>
40+
<after>
41+
<!--Delete new User-->
42+
<actionGroup ref="logout" stepKey="logoutAsSaleRoleUser"/>
43+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUser"/>
44+
<actionGroup ref="AdminDeleteCustomUserActionGroup" stepKey="deleteNewUser">
45+
<argument name="user" value="AdminUserWithUpdatedUserRoleToSales"/>
46+
</actionGroup>
47+
48+
<!--Delete new Role-->
49+
<actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteCustomRole">
50+
<argument name="roleName" value="{{roleSales.rolename}}"/>
51+
</actionGroup>
52+
<actionGroup ref="logout" stepKey="logOut"/>
53+
</after>
54+
55+
56+
<!--Assign new role-->
57+
<actionGroup ref="AdminOpenUserEditPageActionGroup" stepKey="openUserEditPage">
58+
<argument name="user" value="NewAdminUser"/>
59+
</actionGroup>
60+
<actionGroup ref="AdminFillNewUserFormRequiredFieldsActionGroup" stepKey="fillUserForm">
61+
<argument name="user" value="AdminUserWithUpdatedUserRoleToSales"/>
62+
</actionGroup>
63+
<actionGroup ref="AdminClickSaveButtonOnUserFormActionGroup" stepKey="saveUser"/>
64+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage">
65+
<argument name="message" value="You saved the user."/>
66+
</actionGroup>
67+
68+
<actionGroup ref="AssertAdminUserIsInGridActionGroup" stepKey="seeUserInGrid">
69+
<argument name="user" value="AdminUserWithUpdatedUserRoleToSales"/>
70+
</actionGroup>
71+
<actionGroup ref="logout" stepKey="logOutFromAdminPanel"/>
72+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsSaleRoleUser">
73+
<argument name="adminUser" value="AdminUserWithUpdatedUserRoleToSales"/>
74+
</actionGroup>
75+
<actionGroup ref="AssertAdminSuccessLoginActionGroup" stepKey="seeSuccessloginMessage"/>
76+
<actionGroup ref="AdminOpenAdminUsersPageActionGroup" stepKey="navigateToAdminUsersPage"/>
77+
<actionGroup ref="AssertUserRoleRestrictedAccessActionGroup" stepKey="seeErrorMessage"/>
78+
</test>
79+
</tests>

0 commit comments

Comments
 (0)