Skip to content

Commit 3a27f1c

Browse files
committed
Add test for admin user delete functionality
1 parent fb3fb8e commit 3a27f1c

File tree

9 files changed

+203
-0
lines changed

9 files changed

+203
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminOpenUserEditPageActionGroup">
11+
<arguments>
12+
<argument name="user" type="entity"/>
13+
</arguments>
14+
<amOnPage url="{{AdminUsersPage.url}}" stepKey="navigateToUserGrid"/>
15+
<click selector="{{AdminUserGridSection.resetButton}}" stepKey="resetGridFilter"/>
16+
<waitForPageLoad stepKey="waitForFiltersReset"/>
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+
<click selector="{{AdminUserGridSection.searchResultFirstRow}}" stepKey="openUserEdit"/>
22+
<waitForPageLoad stepKey="waitForUserEditPageLoad" time="15"/>
23+
</actionGroup>
24+
</actionGroups>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminUpdateUserRoleActionGroup">
11+
<arguments>
12+
<argument name="role" type="entity"/>
13+
</arguments>
14+
<fillField selector="{{AdminEditUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="enterThePassword"/>
15+
<scrollToTopOfPage stepKey="scrollToTop"/>
16+
<waitForPageLoad stepKey="waitForPageScrollToTop" time="15"/>
17+
<click selector="{{AdminNewUserFormSection.userRoleTab}}" stepKey="openUserRoleTab"/>
18+
<waitForPageLoad stepKey="waitForUserRoleTabOpened"/>
19+
<click selector="{{AdminNewUserFormSection.resetFilter}}" stepKey="resetGridFilter"/>
20+
<waitForPageLoad stepKey="waitForFiltersReset"/>
21+
<fillField selector="{{AdminNewUserFormSection.roleFilterField}}" userInput="{{role.name}}" stepKey="fillRoleFilterField"/>
22+
<click selector="{{AdminNewUserFormSection.search}}" stepKey="clickSearchButton"/>
23+
<waitForPageLoad stepKey="waitForFiltersApplied"/>
24+
<checkOption selector="{{AdminNewUserFormSection.roleRadiobutton(role.name)}}" stepKey="assignRole"/>
25+
</actionGroup>
26+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertImpossibleDeleteYourOwnAccountActionGroup">
11+
<fillField selector="{{AdminEditUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="enterThePassword" />
12+
<click selector="{{AdminMainActionsSection.delete}}" stepKey="deleteUser"/>
13+
<waitForElementVisible selector="{{AdminConfirmationModalSection.message}}" stepKey="waitForConfirmModal"/>
14+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
15+
<waitForElementVisible selector="{{AdminMessagesSection.error}}" stepKey="waitErrorMessage"/>
16+
<see selector="{{AdminMessagesSection.error}}" userInput="You cannot delete your own account." stepKey="seeErrorMessage"/>
17+
</actionGroup>
18+
</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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertUserInGridActionGroup">
11+
<arguments>
12+
<argument name="userName" type="string"/>
13+
</arguments>
14+
<amOnPage url="{{AdminUsersPage.url}}" stepKey="navigateToUsersGrid"/>
15+
<click selector="{{AdminUserGridSection.resetButton}}" stepKey="resetGridFilter"/>
16+
<waitForPageLoad stepKey="waitForFiltersReset"/>
17+
<fillField selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{userName}}" stepKey="enterUserName"/>
18+
<click selector="{{AdminUserGridSection.searchButton}}" stepKey="clickSearch"/>
19+
<waitForPageLoad stepKey="waitForGridToLoad" time="15"/>
20+
<see selector="{{AdminUserGridSection.usernameInFirstRow}}" userInput="{{userName}}" stepKey="seeUser"/>
21+
</actionGroup>
22+
</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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertUserNotInGridActionGroup">
11+
<arguments>
12+
<argument name="userName" type="string"/>
13+
</arguments>
14+
<amOnPage url="{{AdminUsersPage.url}}" stepKey="navigateToUsersGrid"/>
15+
<click selector="{{AdminUserGridSection.resetButton}}" stepKey="resetGridFilter"/>
16+
<waitForPageLoad stepKey="waitForFiltersReset"/>
17+
<fillField selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{userName}}" stepKey="enterUserName"/>
18+
<click selector="{{AdminUserGridSection.searchButton}}" stepKey="clickSearch"/>
19+
<waitForPageLoad stepKey="waitForGridToLoad" time="15"/>
20+
<see selector="{{AdminUserGridSection.emptyRecords}}" userInput="We couldn't find any records." stepKey="seeEmptyRecordMessage"/>
21+
</actionGroup>
22+
</actionGroups>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@
2424
<data key="resourceAccess">Custom</data>
2525
<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>
2626
</entity>
27+
<entity name="restrictedRole" type="role">
28+
<data key="name" unique="suffix">Restricted Role </data>
29+
<data key="resourceAccess">Custom</data>
30+
<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_User::acl', 'Magento_User::acl_users', 'Magento_User::locks', 'Magento_User::acl_roles']</data>
31+
</entity>
2732
</entities>

app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<element name="usernameInFirstRow" type="text" selector=".col-username"/>
1414
<element name="searchResultFirstRow" type="text" selector=".data-grid>tbody>tr"/>
1515
<element name="successMessage" type="text" selector=".message-success"/>
16+
<element name="emptyRecords" type="text" selector="//tr[@class='data-grid-tr-no-data even']/td[@class='empty-text']"/>
1617
</section>
1718

1819
<section name="AdminDeleteUserSection">
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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="AdminDeleteAdminUserEntityTest">
12+
<annotations>
13+
<features value="User"/>
14+
<stories value="Delete Admin User"/>
15+
<title value="Admin user is not able to delete the own account"/>
16+
<description value="Admin user is not able to delete the own account"/>
17+
<group value="user"/>
18+
<group value="mtf_migrated"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="logIn"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="logout" stepKey="logOut"/>
26+
</after>
27+
28+
<!--Create New User-->
29+
<actionGroup ref="AdminOpenNewUserPageActionGroup" stepKey="goToNewUserPage"/>
30+
<actionGroup ref="AdminFillNewUserFormRequiredFieldsActionGroup" stepKey="fillNewUserForm">
31+
<argument name="user" value="NewAdminUser"/>
32+
</actionGroup>
33+
<actionGroup ref="AdminClickSaveButtonOnUserFormActionGroup" stepKey="saveNewUser"/>
34+
35+
<!--Create New Role-->
36+
<actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePage"/>
37+
<actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleForm">
38+
<argument name="role" value="restrictedRole"/>
39+
</actionGroup>
40+
<actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRole"/>
41+
42+
<!--Assign New Role-->
43+
<actionGroup ref="AdminOpenUserEditPageActionGroup" stepKey="openUserEditPage">
44+
<argument name="user" value="NewAdminUser"/>
45+
</actionGroup>
46+
<actionGroup ref="AdminUpdateUserRoleActionGroup" stepKey="assignNewUserRole">
47+
<argument name="role" value="restrictedRole"/>
48+
</actionGroup>
49+
<actionGroup ref="AdminClickSaveButtonOnUserFormActionGroup" stepKey="saveUser"/>
50+
<actionGroup ref="logout" stepKey="logOutAsDefaultAdminUser"/>
51+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsNewUser">
52+
<argument name="adminUser" value="NewAdminUser"/>
53+
</actionGroup>
54+
55+
<!--Assert Impossible Delete Your Own Account-->
56+
<actionGroup ref="AdminOpenUserEditPageActionGroup" stepKey="openUserEditPageForDeleting">
57+
<argument name="user" value="NewAdminUser"/>
58+
</actionGroup>
59+
<actionGroup ref="AssertImpossibleDeleteYourOwnAccountActionGroup" stepKey="assertErrorMessage"/>
60+
<actionGroup ref="AssertUserInGridActionGroup" stepKey="assertUserInGrid">
61+
<argument name="userName" value="{{NewAdminUser.username}}"/>
62+
</actionGroup>
63+
64+
<actionGroup ref="logout" stepKey="logOutAsNewUser"/>
65+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsDefaultAdminUser"/>
66+
67+
<!--Delete New Role-->
68+
<actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteCustomRole">
69+
<argument name="roleName" value="{{restrictedRole.name}}"/>
70+
</actionGroup>
71+
72+
<!--Delete New User-->
73+
<actionGroup ref="AdminDeleteCustomUserActionGroup" stepKey="deleteNewUser">
74+
<argument name="user" value="NewAdminUser"/>
75+
</actionGroup>
76+
<actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage">
77+
<argument name="message" value="You deleted the user."/>
78+
</actionGroup>
79+
<actionGroup ref="AssertUserNotInGridActionGroup" stepKey="assertUserNotInGrid">
80+
<argument name="userName" value="{{NewAdminUser.username}}"/>
81+
</actionGroup>
82+
</test>
83+
</tests>

dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
<data name="systemAdmin/dataset" xsi:type="string">system_admin</data>
1313
<constraint name="Magento\User\Test\Constraint\AssertImpossibleDeleteYourOwnAccount" />
1414
<constraint name="Magento\User\Test\Constraint\AssertUserInGrid" />
15+
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
1516
</variation>
1617
<variation name="DeleteAdminUserEntityTestVariation2">
1718
<data name="isDefaultUser" xsi:type="string">1</data>
1819
<data name="systemAdmin/dataset" xsi:type="string">system_admin</data>
1920
<constraint name="Magento\User\Test\Constraint\AssertUserSuccessDeleteMessage" />
2021
<constraint name="Magento\User\Test\Constraint\AssertUserNotInGrid" />
22+
<data name="tag" xsi:type="string">mftf_migrated:yes</data>
2123
</variation>
2224
</testCase>
2325
</config>

0 commit comments

Comments
 (0)