<?xml version="1.0" encoding="UTF-8"?>
<!--
 /**
  * Copyright © Magento, Inc. All rights reserved.
  * See COPYING.txt for license details.
  */
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
    <actionGroup name="AdminAssignUserRoleActionGroup">
        <arguments>
            <argument name="user_restricted"/>
            <argument name="user_role" />
        </arguments>
        <amOnPage url="{{AdminUsersPage.url}}" stepKey="amOnAdminUsersPage"/>
        <waitForPageLoad stepKey="wait1" time="10"/>
        <fillField stepKey="fillUsernameSearch" selector="{{AdminUserGridSection.usernameFilterTextField}}" userInput="{{user_restricted.username}}"/>
        <click stepKey="clickSearchButton" selector="{{AdminUserGridSection.searchButton}}"/>
        <waitForPageLoad stepKey="wait2" time="10"/>
        <see stepKey="seeFoundUsername" selector="{{AdminUserGridSection.usernameInFirstRow}}" userInput="{{user_restricted.username}}"/>
        <click stepKey="clickFoundUsername" selector="{{AdminUserGridSection.searchResultFirstRow}}"/>
        <waitForPageLoad stepKey="wait3" time="30"/>
        <seeInField stepKey="seeUsernameInField" selector="{{AdminEditUserSection.usernameTextField}}" userInput="{{user_restricted.username}}"/>
        <fillField stepKey="fillCurrentPassword" selector="{{AdminEditUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
        <scrollToTopOfPage stepKey="scrollToTopOfPage" />
        <click stepKey="clickUserRoleTab" selector="{{AdminEditUserSection.userRoleTab}}"/>
        <fillField selector="{{AdminEditUserSection.roleNameFilterTextField}}" userInput="{{user_role.rolename}}" stepKey="fillRoleNameSearch"/>
        <click stepKey="clickSearchButtonUserRole" selector="{{AdminEditUserSection.searchButton}}"/>
        <waitForPageLoad stepKey="wait4" time="10"/>
        <see stepKey="seeFoundRoleName" selector="{{AdminEditUserSection.roleNameInFirstRow}}" userInput="{{user_role.rolename}}"/>
        <click stepKey="clickFoundRoleName" selector="{{AdminEditUserSection.searchResultFirstRow}}"/>
        <click stepKey="clickSaveButton" selector="{{AdminEditUserSection.saveButton}}"/>
        <waitForPageLoad stepKey="wait5" time="10"/>
        <see stepKey="saveUserSuccessMessage" selector="{{AdminUserGridSection.successMessage}}" userInput="You saved the user."/>
    </actionGroup>
</actionGroups>
