Skip to content

Commit c4e63e9

Browse files
MAGETWO-91688: Exception when login as restricted admin with access only to CMS Block
- Stabilize functional tests.
1 parent 6f158a9 commit c4e63e9

File tree

6 files changed

+180
-19
lines changed

6 files changed

+180
-19
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
11+
<actionGroup name="GoToUserRoles">
12+
<click selector="#menu-magento-backend-system" stepKey="clickOnSystemIcon"/>
13+
<waitForPageLoad stepKey="waitForSystemsPageToOpen"/>
14+
<click selector="//span[contains(text(), 'User Roles')]" stepKey="clickToSelectUserRoles"/>
15+
<waitForPageLoad stepKey="waitForUserRolesPageToOpen"/>
16+
</actionGroup>
17+
18+
<!--Create new role-->
19+
<actionGroup name="AdminCreateNewRole">
20+
<arguments>
21+
<argument name="role" type="string" defaultValue=""/>
22+
<argument name="resource" type="string" defaultValue="All"/>
23+
<argument name="scope" type="string" defaultValue="Custom"/>
24+
<argument name="websites" type="string" defaultValue="Main Website"/>
25+
</arguments>
26+
<click selector="{{AdminCreateRoleSection.create}}" stepKey="clickToAddNewRole"/>
27+
<fillField selector="{{AdminCreateRoleSection.name}}" userInput="{{role.name}}" stepKey="setRoleName"/>
28+
<fillField stepKey="setPassword" selector="{{AdminCreateRoleSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
29+
<click selector="{{AdminCreateRoleSection.roleResources}}" stepKey="clickToOpenRoleResources"/>
30+
<waitForPageLoad stepKey="waitForRoleResourcePage" time="5"/>
31+
<click stepKey="checkSales" selector="//a[text()='Sales']"/>
32+
<click selector="{{AdminCreateRoleSection.save}}" stepKey="clickToSaveRole"/>
33+
<waitForPageLoad stepKey="waitForPageLoad" time="10"/>
34+
<see userInput="You saved the role." stepKey="seeSuccessMessage" />
35+
</actionGroup>
36+
37+
38+
<!--Delete role-->
39+
<actionGroup name="AdminDeleteRoleActionGroup">
40+
<arguments>
41+
<argument name="role" defaultValue=""/>
42+
</arguments>
43+
<click stepKey="clickOnRole" selector="{{AdminDeleteRoleSection.theRole}}"/>
44+
<fillField stepKey="TypeCurrentPassword" selector="{{AdminDeleteRoleSection.current_pass}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
45+
<click stepKey="clickToDeleteRole" selector="{{AdminDeleteRoleSection.delete}}"/>
46+
<waitForAjaxLoad stepKey="waitForDeleteConfirmationPopup" time="5"/>
47+
<click stepKey="clickToConfirm" selector="{{AdminDeleteRoleSection.confirm}}"/>
48+
<waitForPageLoad stepKey="waitForPageLoad" time="10"/>
49+
<see stepKey="seeSuccessMessage" userInput="You deleted the role."/>
50+
</actionGroup>
51+
</actionGroups>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
11+
<!--Go to all users-->
12+
<actionGroup name="GoToAllUsers">
13+
<click selector="{{AdminCreateUserSection.system}}" stepKey="clickOnSystemIcon"/>
14+
<waitForPageLoad stepKey="waitForSystemsPageToOpen"/>
15+
<click selector="{{AdminCreateUserSection.allUsers}}" stepKey="clickToSelectUserRoles"/>
16+
<waitForPageLoad stepKey="waitForUserRolesPageToOpen"/>
17+
</actionGroup>
18+
19+
<!--Create new user with specified role-->
20+
<actionGroup name="AdminCreateUserAction">
21+
<click selector="{{AdminCreateUserSection.create}}" stepKey="clickToCreateNewUser"/>
22+
<waitForPageLoad stepKey="waitForNewUserPageLoad" time="10"/>
23+
<fillField selector="{{AdminCreateUserSection.usernameTextField}}" userInput="{{NewAdmin.username}}" stepKey="enterUserName" />
24+
<fillField selector="{{AdminCreateUserSection.firstNameTextField}}" userInput="{{NewAdmin.firstName}}" stepKey="enterFirstName" />
25+
<fillField selector="{{AdminCreateUserSection.lastNameTextField}}" userInput="{{NewAdmin.lastName}}" stepKey="enterLastName" />
26+
<fillField selector="{{AdminCreateUserSection.emailTextField}}" userInput="{{NewAdmin.email}}" stepKey="enterEmail" />
27+
<fillField selector="{{AdminCreateUserSection.passwordTextField}}" userInput="{{NewAdmin.password}}" stepKey="enterPassword" />
28+
<fillField selector="{{AdminCreateUserSection.pwConfirmationTextField}}" userInput="{{NewAdmin.password}}" stepKey="confirmPassword" />
29+
<fillField selector="{{AdminCreateUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="enterCurrentPassword" />
30+
<scrollToTopOfPage stepKey="scrollToTopOfPage" />
31+
<click selector="{{AdminCreateUserSection.userRoleTab}}" stepKey="clickUserRole" />
32+
<waitForAjaxLoad stepKey="waitForRoles" time="5"/>
33+
<fillField selector="{{AdminCreateRoleSection.roleNameFilterTextField}}" userInput="{{role.name}}" stepKey="filterRole" />
34+
<click selector="{{AdminCreateRoleSection.searchButton}}" stepKey="clickSearch" />
35+
<waitForPageLoad stepKey="waitForSearch" time="10"/>
36+
<click selector="{{AdminCreateRoleSection.searchResultFirstRow}}" stepKey="selectRole" />
37+
<click selector="{{AdminCreateUserSection.saveButton}}" stepKey="clickSaveUser" />
38+
<waitForPageLoad stepKey="waitForSaveUser" time="10"/>
39+
<see userInput="You saved the user." stepKey="seeSuccessMessage" />
40+
</actionGroup>
41+
42+
43+
<!--Delete User-->
44+
<actionGroup name="AdminDeleteNewUserActionGroup">
45+
46+
<click stepKey="clickOnUser" selector="{{AdminDeleteUserSection.theUser}}"/>
47+
<fillField stepKey="TypeCurrentPassword" selector="{{AdminDeleteUserSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
48+
<scrollToTopOfPage stepKey="scrollToTop"/>
49+
<click stepKey="clickToDeleteUser" selector="{{AdminDeleteUserSection.delete}}"/>
50+
<waitForPageLoad stepKey="waitForDeletePopupOpen" time="5"/>
51+
<click stepKey="clickToConfirm" selector="{{AdminDeleteUserSection.confirm}}"/>
52+
<waitForPageLoad stepKey="waitForPageLoad" time="10"/>
53+
<see userInput="You deleted the user." stepKey="seeSuccessMessage" />
54+
</actionGroup>
55+
56+
</actionGroups>
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
9+
<section name="AdminCreateRoleSection">
10+
<element name="create" type="button" selector="#add"/>
11+
<element name="name" type="button" selector="#role_name"/>
12+
<element name="password" type="input" selector="#current_password"/>
13+
<element name="roleResources" type="button" selector="#role_info_tabs_account"/>
14+
<element name="roleResource" type="button" selector="#gws_is_all"/>
15+
<element name="resourceValue" type="button" selector="//*[text()='{{arg1}}']" parameterized="true"/>
16+
<element name="roleScope" type="button" selector="#all"/>
17+
<element name="scopeValue" type="button" selector="//select[@id='all']/*[text()='{{arg2}}']" parameterized="true"/>
18+
<element name="website" type="checkbox" selector="//*[contains(text(), '{{arg3}}')]" parameterized="true"/>
19+
<element name="save" type="button" selector="//button[@title='Save Role']"/>
20+
<element name="roleNameFilterTextField" type="input" selector="#permissionsUserRolesGrid_filter_role_name"/>
21+
<element name="searchButton" type="button" selector=".admin__data-grid-header button[title=Search]"/>
22+
<element name="searchResultFirstRow" type="text" selector=".data-grid>tbody>tr"/>
23+
</section>
24+
</sections>

app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,20 @@
3939
<actionGroup ref="ConfigureBraintree" stepKey="configureBraintree"/>
4040

4141
<!--Create New Role-->
42-
<actionGroup ref="AdminCreateRoleActionGroup" stepKey="adminCreateRole">
43-
<argument name="restrictedRole" value="Sales"/>
44-
<argument name="User" value="adminRole"/>
45-
</actionGroup>
42+
<actionGroup ref="GoToUserRoles" stepKey="GoToUserRoles"/>
43+
<waitForPageLoad stepKey="waitForAllRoles" time="15"/>
44+
<actionGroup ref="AdminCreateNewRole" stepKey="AdminCreateNewRole"/>
4645

4746
<!--Create new admin user-->
48-
<actionGroup ref="AdminCreateUserActionGroup" stepKey="adminCreateUser">
49-
<argument name="role" value="adminRole"/>
50-
</actionGroup>
47+
<actionGroup ref="GoToAllUsers" stepKey="GoToAllUsers"/>
48+
<waitForPageLoad stepKey="waitForUsers" time="15"/>
49+
<actionGroup ref="AdminCreateUserAction" stepKey="AdminCreateNewUser"/>
5150

5251
<!--SignOut-->
5352
<actionGroup ref="logout" stepKey="signOutFromAdmin"/>
5453

5554
<!--Log in as new user-->
56-
<actionGroup ref="LoginAsAnyUser" stepKey="LoginActionGroup">
57-
<argument name="uname" value="{{newAdmin.username}}"/>
58-
<argument name="passwd" value="{{newAdmin.password}}"/>
59-
</actionGroup>
55+
<actionGroup ref="LoginNewUser" stepKey="signInNewUser"/>
6056
<waitForPageLoad stepKey="waitForLogin" time="3"/>
6157

6258
<!--Create New Order-->
@@ -97,15 +93,13 @@
9793
<!--Delete Customer-->
9894
<deleteData stepKey="deleteCustomer" createDataKey="createCustomer"/>
9995

100-
<!--Delete created user-->
101-
<actionGroup ref="AdminDeleteUserActionGroup" stepKey="AdminDeleteUserActionGroup">
102-
<argument name="user" value="adminRole"/>
103-
</actionGroup>
96+
<!--Delete User -->
97+
<actionGroup ref="GoToAllUsers" stepKey="GoBackToAllUsers"/>
98+
<actionGroup ref="AdminDeleteNewUserActionGroup" stepKey="AdminDeleteUserActionGroup"/>
10499

105-
<!--Delete created role-->
106-
<actionGroup ref="AdminDeleteCreatedRoleActionGroup" stepKey="AdminDeleteRoleActionGroup">
107-
<argument name="role" value="adminRole"/>
108-
</actionGroup>
100+
<!--Delete Role-->
101+
<actionGroup ref="GoToUserRoles" stepKey="GoBackToUserRoles"/>
102+
<actionGroup ref="AdminDeleteRoleActionGroup" stepKey="AdminDeleteRoleActionGroup"/>
109103
</after>
110104
</test>
111105
</tests>

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,22 @@
2424
<click selector="{{AdminEditRoleInfoSection.saveButton}}" stepKey="clickSaveRoleButton" />
2525
<waitForPageLoad stepKey="waitForPageLoad2" />
2626
</actionGroup>
27+
<!--Create new role-->
28+
<actionGroup name="AdminCreateRole">
29+
<arguments>
30+
<argument name="role" type="string" defaultValue=""/>
31+
<argument name="resource" type="string" defaultValue="All"/>
32+
<argument name="scope" type="string" defaultValue="Custom"/>
33+
<argument name="websites" type="string" defaultValue="Main Website"/>
34+
</arguments>
35+
<click selector="{{AdminCreateRoleSection.create}}" stepKey="clickToAddNewRole"/>
36+
<fillField selector="{{AdminCreateRoleSection.name}}" userInput="{{role.name}}" stepKey="setRoleName"/>
37+
<fillField stepKey="setPassword" selector="{{AdminCreateRoleSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
38+
<click selector="{{AdminCreateRoleSection.roleResources}}" stepKey="clickToOpenRoleResources"/>
39+
<waitForPageLoad stepKey="waitForRoleResourcePage" time="5"/>
40+
<click stepKey="checkSales" selector="//a[text()='Sales']"/>
41+
<click selector="{{AdminCreateRoleSection.save}}" stepKey="clickToSaveRole"/>
42+
<waitForPageLoad stepKey="waitForPageLoad" time="10"/>
43+
<see userInput="You saved the role." stepKey="seeSuccessMessage" />
44+
</actionGroup>
2745
</actionGroups>

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,22 @@
2222
<waitForPageLoad stepKey="waitForPageLoad"/>
2323
<see stepKey="seeDeleteMessageForUser" userInput="You deleted the user."/>
2424
</actionGroup>
25+
<actionGroup name="AdminDeleteCustomUserActionGroup">
26+
<arguments>
27+
<argument name="user"/>
28+
</arguments>
29+
<amOnPage url="{{AdminUsersPage.url}}" stepKey="navigateToUserGrid" />
30+
<fillField selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{user.username}}" stepKey="enterUserName" />
31+
<click selector="{{AdminUserGridSection.searchButton}}" stepKey="clickSearch" />
32+
<waitForPageLoad stepKey="waitForGridToLoad"/>
33+
<see selector="{{AdminUserGridSection.usernameInFirstRow}}" userInput="{{user.username}}" stepKey="seeUser" />
34+
<click selector="{{AdminUserGridSection.searchResultFirstRow}}" stepKey="openUserEdit"/>
35+
<waitForPageLoad stepKey="waitForUserEditPageLoad"/>
36+
<fillField selector="{{AdminEditUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="enterThePassword" />
37+
<click selector="{{AdminMainActionsSection.delete}}" stepKey="deleteUser"/>
38+
<waitForElementVisible selector="{{AdminConfirmationModalSection.message}}" stepKey="waitForConfirmModal"/>
39+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
40+
<waitForPageLoad stepKey="waitForSave" />
41+
<see selector="{{AdminMessagesSection.success}}" userInput="You deleted the user." stepKey="seeUserDeleteMessage"/>
42+
</actionGroup>
2543
</actionGroups>

0 commit comments

Comments
 (0)