From aeeffe43622551587b63e09625fa5eeb2b3aed09 Mon Sep 17 00:00:00 2001 From: Kate Kyzyma Date: Fri, 26 Jul 2019 15:47:42 +0300 Subject: [PATCH 1/3] Add test for admin user role create functionality --- .../AssertRoleInGridActionGroup.xml | 20 +++++ .../AssertRoleNotInGridActionGroup.xml | 20 +++++ .../User/Test/Mftf/Data/UserRoleData.xml | 6 +- .../Mftf/Section/AdminRoleGridSection.xml | 1 + .../Test/AdminCreateUserRoleEntityTest.xml | 77 +++++++++++++++++++ .../CreateAdminUserRoleEntityTest.xml | 3 + 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml create mode 100644 app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml new file mode 100644 index 0000000000000..4703563f57d7a --- /dev/null +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml new file mode 100644 index 0000000000000..fe7cbb4774b1e --- /dev/null +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml index 1c18ca13b9731..981d5948a3c88 100644 --- a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml +++ b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml @@ -13,12 +13,16 @@ 1 1 - Administrator All [] + + Admin + All + [] + Role Sales Custom diff --git a/app/code/Magento/User/Test/Mftf/Section/AdminRoleGridSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminRoleGridSection.xml index 8413081237fd1..d540397676594 100644 --- a/app/code/Magento/User/Test/Mftf/Section/AdminRoleGridSection.xml +++ b/app/code/Magento/User/Test/Mftf/Section/AdminRoleGridSection.xml @@ -13,6 +13,7 @@ +
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml new file mode 100644 index 0000000000000..5370f8245a665 --- /dev/null +++ b/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml @@ -0,0 +1,77 @@ + + + + + + + + + + <description value="Creating a new role with different data sets"/> + <group value="user"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <actionGroup ref="LoginAsAdmin" stepKey="logIn"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logOut"/> + </after> + + <!--Create a new role with custom access--> + <actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePage"/> + <actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleForm"> + <argument name="role" value="roleSales"/> + </actionGroup> + <actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRole"/> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage"> + <argument name="message" value="You saved the role."/> + </actionGroup> + <actionGroup ref="AssertRoleInGridActionGroup" stepKey="assertRoleInGrid"> + <argument name="roleName" value="{{roleSales.name}}"/> + </actionGroup> + + <!--Create a new role with full access--> + <actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePageSecondTime"/> + <actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleFormSecondTime"> + <argument name="role" value="roleAdministrator"/> + </actionGroup> + <actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRoleSecondTime"/> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessageSecondTime"> + <argument name="message" value="You saved the role."/> + </actionGroup> + <actionGroup ref="AssertRoleInGridActionGroup" stepKey="assertRoleInGridSecondTime"> + <argument name="roleName" value="{{roleAdministrator.name}}"/> + </actionGroup> + + <!--Create a new role using incorrect current_password--> + <actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePageThirdTime"/> + <actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleFormThirdTime"> + <argument name="role" value="roleAdmin"/> + <argument name="currentAdminPassword" value="WrongPassword"/> + </actionGroup> + <actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRoleThirdTime"/> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertErrorMessage"> + <argument name="messageType" value="error"/> + <argument name="message" value="The password entered for the current user is invalid. Verify the password and try again."/> + </actionGroup> + <actionGroup ref="AssertRoleNotInGridActionGroup" stepKey="assertRoleNotInGrid"> + <argument name="roleName" value="{{roleAdmin.name}}"/> + </actionGroup> + + <!--Delete New Roles--> + <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteSaleRole"> + <argument name="roleName" value="{{roleSales.name}}"/> + </actionGroup> + <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteAdministratorRole"> + <argument name="roleName" value="{{roleAdministrator.name}}"/> + </actionGroup> + </test> +</tests> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml index 19b7406139584..693ba079cb43f 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml @@ -15,6 +15,7 @@ <data name="role/data/roles_resources" xsi:type="string">Sales</data> <constraint name="Magento\User\Test\Constraint\AssertRoleSuccessSaveMessage" /> <constraint name="Magento\User\Test\Constraint\AssertRoleInGrid" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> <variation name="CreateAdminUserRoleEntityTestVariation2"> <data name="role/data/rolename" xsi:type="string">AdminRole%isolation%</data> @@ -22,6 +23,7 @@ <data name="role/data/resource_access" xsi:type="string">All</data> <constraint name="Magento\User\Test\Constraint\AssertRoleSuccessSaveMessage" /> <constraint name="Magento\User\Test\Constraint\AssertRoleInGrid" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> <variation name="CreateAdminUserRoleEntityTestVariation3"> <data name="role/data/rolename" xsi:type="string">AdminRole%isolation%</data> @@ -29,6 +31,7 @@ <data name="role/data/resource_access" xsi:type="string">All</data> <constraint name="Magento\User\Test\Constraint\AssertIncorrectUserPassword" /> <constraint name="Magento\User\Test\Constraint\AssertRoleNotInGrid" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> </testCase> </config> From 02ef2f9b0c3132dfcd1dcece54264004a0fb680e Mon Sep 17 00:00:00 2001 From: Kate Kyzyma <kate@atwix.com> Date: Wed, 7 Aug 2019 17:05:04 +0300 Subject: [PATCH 2/3] Fixing issues --- ...l => AssertAdminRoleInGridActionGroup.xml} | 4 +-- ...> AssertAdminRoleNotInGridActionGroup.xml} | 4 +-- .../User/Test/Mftf/Data/UserRoleData.xml | 5 ---- .../Test/AdminCreateUserRoleEntityTest.xml | 29 ++++++++++--------- .../CreateAdminUserRoleEntityTest.xml | 3 +- 5 files changed, 20 insertions(+), 25 deletions(-) rename app/code/Magento/User/Test/Mftf/ActionGroup/{AssertRoleInGridActionGroup.xml => AssertAdminRoleInGridActionGroup.xml} (92%) rename app/code/Magento/User/Test/Mftf/ActionGroup/{AssertRoleNotInGridActionGroup.xml => AssertAdminRoleNotInGridActionGroup.xml} (92%) diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminRoleInGridActionGroup.xml similarity index 92% rename from app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml rename to app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminRoleInGridActionGroup.xml index 4703563f57d7a..93ff97e8bbf8c 100644 --- a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleInGridActionGroup.xml +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminRoleInGridActionGroup.xml @@ -7,7 +7,7 @@ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertRoleInGridActionGroup"> + <actionGroup name="AssertAdminRoleInGridActionGroup"> <arguments> <argument name="roleName" type="string"/> </arguments> @@ -17,4 +17,4 @@ <waitForPageLoad stepKey="waitForGridToLoad" time="15"/> <see selector="{{AdminRoleGridSection.roleNameInFirstRow}}" userInput="{{roleName}}" stepKey="seeTheRole"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminRoleNotInGridActionGroup.xml similarity index 92% rename from app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml rename to app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminRoleNotInGridActionGroup.xml index fe7cbb4774b1e..bb6af04e0e7b6 100644 --- a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertRoleNotInGridActionGroup.xml +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminRoleNotInGridActionGroup.xml @@ -7,7 +7,7 @@ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertRoleNotInGridActionGroup"> + <actionGroup name="AssertAdminRoleNotInGridActionGroup"> <arguments> <argument name="roleName" type="string"/> </arguments> @@ -17,4 +17,4 @@ <waitForPageLoad stepKey="waitForGridToLoad" time="15"/> <see selector="{{AdminRoleGridSection.emptyRecords}}" userInput="We couldn't find any records." stepKey="seeEmptyRecordMessage"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml index 981d5948a3c88..c067f3f07c656 100644 --- a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml +++ b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml @@ -18,11 +18,6 @@ <data key="resourceAccess">All</data> <data key="resources">[]</data> </entity> - <entity name="roleAdmin" type="role"> - <data key="name" unique="suffix">Admin </data> - <data key="resourceAccess">All</data> - <data key="resources">[]</data> - </entity> <entity name="roleSales" type="role"> <data key="name" unique="suffix">Role Sales </data> <data key="resourceAccess">Custom</data> diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml index 5370f8245a665..ffec604793f75 100644 --- a/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml +++ b/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml @@ -34,7 +34,11 @@ <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage"> <argument name="message" value="You saved the role."/> </actionGroup> - <actionGroup ref="AssertRoleInGridActionGroup" stepKey="assertRoleInGrid"> + <actionGroup ref="AssertAdminRoleInGridActionGroup" stepKey="assertRoleInGrid"> + <argument name="roleName" value="{{roleSales.name}}"/> + </actionGroup> + <!--Delete New Roles--> + <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteSaleRole"> <argument name="roleName" value="{{roleSales.name}}"/> </actionGroup> @@ -47,31 +51,28 @@ <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessageSecondTime"> <argument name="message" value="You saved the role."/> </actionGroup> - <actionGroup ref="AssertRoleInGridActionGroup" stepKey="assertRoleInGridSecondTime"> + <actionGroup ref="AssertAdminRoleInGridActionGroup" stepKey="assertRoleInGridSecondTime"> + <argument name="roleName" value="{{roleAdministrator.name}}"/> + </actionGroup> + <!--Delete New Roles--> + <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteAdministratorRole"> <argument name="roleName" value="{{roleAdministrator.name}}"/> </actionGroup> <!--Create a new role using incorrect current_password--> <actionGroup ref="AdminOpenCreateRolePageActionGroup" stepKey="goToNewRolePageThirdTime"/> <actionGroup ref="AdminFillUserRoleFormActionGroup" stepKey="fillNewRoleFormThirdTime"> - <argument name="role" value="roleAdmin"/> - <argument name="currentAdminPassword" value="WrongPassword"/> + <argument name="role" value="roleAdministrator"/> + <argument name="currentAdminPassword" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}INVALID"/> </actionGroup> <actionGroup ref="AdminClickSaveButtonOnUserRoleFormActionGroup" stepKey="saveNewRoleThirdTime"/> <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertErrorMessage"> <argument name="messageType" value="error"/> <argument name="message" value="The password entered for the current user is invalid. Verify the password and try again."/> </actionGroup> - <actionGroup ref="AssertRoleNotInGridActionGroup" stepKey="assertRoleNotInGrid"> - <argument name="roleName" value="{{roleAdmin.name}}"/> - </actionGroup> - - <!--Delete New Roles--> - <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteSaleRole"> - <argument name="roleName" value="{{roleSales.name}}"/> - </actionGroup> - <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteAdministratorRole"> + <actionGroup ref="AssertAdminRoleNotInGridActionGroup" stepKey="assertRoleNotInGrid"> <argument name="roleName" value="{{roleAdministrator.name}}"/> </actionGroup> + </test> -</tests> \ No newline at end of file +</tests> diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml index 693ba079cb43f..4ae4c476a959b 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/CreateAdminUserRoleEntityTest.xml @@ -8,14 +8,13 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\User\Test\TestCase\CreateAdminUserRoleEntityTest" summary="Create Admin User Role" ticketId="MAGETWO-23413"> <variation name="CreateAdminUserRoleEntityTestVariation1"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, mftf_migrated:yes</data> <data name="role/data/rolename" xsi:type="string">AdminRole%isolation%</data> <data name="role/data/current_password" xsi:type="string">%current_password%</data> <data name="role/data/resource_access" xsi:type="string">Custom</data> <data name="role/data/roles_resources" xsi:type="string">Sales</data> <constraint name="Magento\User\Test\Constraint\AssertRoleSuccessSaveMessage" /> <constraint name="Magento\User\Test\Constraint\AssertRoleInGrid" /> - <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> <variation name="CreateAdminUserRoleEntityTestVariation2"> <data name="role/data/rolename" xsi:type="string">AdminRole%isolation%</data> From 1bf38ad09dc48083d95923a3184c571fd1678699 Mon Sep 17 00:00:00 2001 From: Kate Kyzyma <kate@atwix.com> Date: Thu, 8 Aug 2019 15:40:08 +0300 Subject: [PATCH 3/3] Code refactoring --- .../User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml index ffec604793f75..c50728bfda024 100644 --- a/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml +++ b/app/code/Magento/User/Test/Mftf/Test/AdminCreateUserRoleEntityTest.xml @@ -37,7 +37,7 @@ <actionGroup ref="AssertAdminRoleInGridActionGroup" stepKey="assertRoleInGrid"> <argument name="roleName" value="{{roleSales.name}}"/> </actionGroup> - <!--Delete New Roles--> + <!--Delete the new role with custom access--> <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteSaleRole"> <argument name="roleName" value="{{roleSales.name}}"/> </actionGroup> @@ -54,7 +54,7 @@ <actionGroup ref="AssertAdminRoleInGridActionGroup" stepKey="assertRoleInGridSecondTime"> <argument name="roleName" value="{{roleAdministrator.name}}"/> </actionGroup> - <!--Delete New Roles--> + <!--Delete the new role with full access--> <actionGroup ref="AdminDeleteUserRoleActionGroup" stepKey="deleteAdministratorRole"> <argument name="roleName" value="{{roleAdministrator.name}}"/> </actionGroup>