Skip to content

Commit e258d48

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-69893' into EPAM-PR-59
2 parents f328d00 + c700971 commit e258d48

File tree

13 files changed

+318
-109
lines changed

13 files changed

+318
-109
lines changed

app/code/Magento/Braintree/Test/Mftf/ActionGroup/AdminUserActionGroup.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,4 @@
3838
<waitForPageLoad stepKey="waitForSaveUser" time="10"/>
3939
<see userInput="You saved the user." stepKey="seeSuccessMessage" />
4040
</actionGroup>
41-
42-
<!--Delete User-->
43-
<actionGroup name="AdminDeleteNewUserActionGroup">
44-
45-
<click stepKey="clickOnUser" selector="{{AdminDeleteUserSection.theUser}}"/>
46-
<fillField stepKey="TypeCurrentPassword" selector="{{AdminDeleteUserSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
47-
<scrollToTopOfPage stepKey="scrollToTop"/>
48-
<click stepKey="clickToDeleteUser" selector="{{AdminDeleteUserSection.delete}}"/>
49-
<waitForPageLoad stepKey="waitForDeletePopupOpen" time="5"/>
50-
<click stepKey="clickToConfirm" selector="{{AdminDeleteUserSection.confirm}}"/>
51-
<waitForPageLoad stepKey="waitForPageLoad" time="10"/>
52-
<see userInput="You deleted the user." stepKey="seeSuccessMessage" />
53-
</actionGroup>
54-
5541
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,15 @@
441441
</arguments>
442442
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="searchAndSelectCategory"/>
443443
</actionGroup>
444+
<!--Remove category from product in ProductFrom Page-->
445+
<actionGroup name="removeCategoryFromProduct">
446+
<arguments>
447+
<argument name="categoryName" type="string" defaultValue="{{_defaultCategory.name}}"/>
448+
</arguments>
449+
<click selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="clickCategoriesDropDown"/>
450+
<click selector="{{AdminProductFormSection.unselectCategories(categoryName)}}" stepKey="unselectCategories"/>
451+
<click selector="{{AdminProductFormSection.done}}" stepKey="clickOnDoneAdvancedCategory"/>
452+
</actionGroup>
444453

445454
<actionGroup name="expandAdminProductSection">
446455
<arguments>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<element name="selectMultipleCategories" type="input" selector="//*[@data-index='container_category_ids']//*[contains(@class, '_selected')]"/>
7373
<element name="countryOfManufacture" type="select" selector="select[name='product[country_of_manufacture]']"/>
7474
<element name="newAddedAttribute" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]" parameterized="true"/>
75+
<element name="newCategoryButton" type="button" selector="button[data-index='create_category_button']" timeout="30"/>
7576
<element name="footerBlock" type="block" selector="//footer"/>
7677
</section>
7778
<section name="ProductInWebsitesSection">
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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="AdminRestrictedUserAddCategoryFromProductPageTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Adding new category from product page by restricted user"/>
15+
<description value="Adding new category from product page by restricted user"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-17229"/>
18+
<useCaseId value="MAGETWO-69893"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
<!--Create category-->
24+
<comment userInput="Create category" stepKey="commentCreateCategory"/>
25+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
26+
</before>
27+
<after>
28+
<!--Delete created product-->
29+
<comment userInput="Delete created product" stepKey="commentDeleteProduct"/>
30+
<actionGroup ref="deleteProductBySku" stepKey="deleteProduct">
31+
<argument name="sku" value="{{_defaultProduct.sku}}"/>
32+
</actionGroup>
33+
<actionGroup ref="resetProductGridToDefaultView" stepKey="resetFiltersIfExist"/>
34+
<actionGroup ref="logout" stepKey="logoutOfUser"/>
35+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
36+
<!--Delete created data-->
37+
<comment userInput="Delete created data" stepKey="commentDeleteCreatedData"/>
38+
<amOnPage url="{{AdminRolesPage.url}}" stepKey="navigateToUserRoleGrid" />
39+
<waitForPageLoad stepKey="waitForRolesGridLoad" />
40+
<actionGroup ref="AdminDeleteRoleActionGroup" stepKey="deleteUserRole">
41+
<argument name="role" value="adminRole"/>
42+
</actionGroup>
43+
<amOnPage url="{{AdminUsersPage.url}}" stepKey="goToAllUsersPage"/>
44+
<waitForPageLoad stepKey="waitForUsersGridLoad" />
45+
<actionGroup ref="AdminDeleteNewUserActionGroup" stepKey="deleteUser">
46+
<argument name="userName" value="{{admin2.username}}"/>
47+
</actionGroup>
48+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
49+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
50+
</after>
51+
<!--Create user role-->
52+
<comment userInput="Create user role" stepKey="commentCreateUserRole"/>
53+
<actionGroup ref="AdminFillUserRoleRequiredData" stepKey="fillUserRoleRequiredData">
54+
<argument name="User" value="adminRole"/>
55+
<argument name="restrictedRole" value="Stores"/>
56+
</actionGroup>
57+
<click selector="{{AdminEditRoleInfoSection.roleResourcesTab}}" stepKey="clickRoleResourcesTab" />
58+
<actionGroup ref="AdminAddRestrictedRole" stepKey="addRestrictedRoleStores">
59+
<argument name="User" value="adminRole"/>
60+
<argument name="restrictedRole" value="Stores"/>
61+
</actionGroup>
62+
<actionGroup ref="AdminAddRestrictedRole" stepKey="addRestrictedRoleProducts">
63+
<argument name="User" value="adminRole"/>
64+
<argument name="restrictedRole" value="Products"/>
65+
</actionGroup>
66+
<click selector="{{AdminEditRoleInfoSection.saveButton}}" stepKey="clickSaveRoleButton" />
67+
<see userInput="You saved the role." stepKey="seeUserRoleSavedMessage"/>
68+
<!--Create user and assign role to it-->
69+
<comment userInput="Create user and assign role to it" stepKey="commentCreateUser"/>
70+
<actionGroup ref="AdminCreateUserActionGroup" stepKey="createAdminUser">
71+
<argument name="role" value="adminRole"/>
72+
<argument name="User" value="admin2"/>
73+
</actionGroup>
74+
<!--Log out of admin and login with newly created user-->
75+
<comment userInput="Log out of admin and login with newly created user" stepKey="commentLoginWithNewUser"/>
76+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
77+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsNewUser">
78+
<argument name="adminUser" value="admin2"/>
79+
</actionGroup>
80+
<!--Go to create product page-->
81+
<comment userInput="Go to create product page" stepKey="commentGoCreateProductPage"/>
82+
<actionGroup ref="goToCreateProductPage" stepKey="goToCreateProductPage"/>
83+
<dontSeeElement selector="{{AdminProductFormSection.newCategoryButton}}" stepKey="dontSeeNewCategoryButton"/>
84+
<!--Fill product data and assign to category-->
85+
<comment userInput="Fill product data and assign to category" stepKey="commentFillProductData"/>
86+
<actionGroup ref="fillMainProductForm" stepKey="fillMainProductForm"/>
87+
<actionGroup ref="SetCategoryByName" stepKey="addCategoryToProduct">
88+
<argument name="categoryName" value="$$createCategory.name$$"/>
89+
</actionGroup>
90+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
91+
<!--Assert that category exist in field-->
92+
<comment userInput="Assert that category exist in field" stepKey="commentAssertion"/>
93+
<grabTextFrom selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="grabCategoryName"/>
94+
<assertContains stepKey="assertThatCategory">
95+
<expectedResult type="variable">$$createCategory.name$$</expectedResult>
96+
<actualResult type="variable">$grabCategoryName</actualResult>
97+
</assertContains>
98+
<!--Remove the category from the product and assert that it removed-->
99+
<comment userInput="Remove the category from the product and assert that it removed" stepKey="assertCategoryRemoved"/>
100+
<actionGroup ref="removeCategoryFromProduct" stepKey="removeCategoryFromProduct">
101+
<argument name="categoryName" value="$$createCategory.name$$"/>
102+
</actionGroup>
103+
<actionGroup ref="saveProductForm" stepKey="saveProductAfterRemovingCategory"/>
104+
<grabTextFrom selector="{{AdminProductFormSection.categoriesDropdown}}" stepKey="grabCategoryFieldContent"/>
105+
<assertNotContains stepKey="assertThatCategoryRemoved">
106+
<expectedResult type="variable">$$createCategory.name$$</expectedResult>
107+
<actualResult type="variable">$grabCategoryFieldContent</actualResult>
108+
</assertNotContains>
109+
</test>
110+
</tests>

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
79

810
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
@@ -12,6 +14,7 @@
1214
use Magento\Framework\DB\Helper as DbHelper;
1315
use Magento\Framework\UrlInterface;
1416
use Magento\Store\Model\Store;
17+
use Magento\Framework\AuthorizationInterface;
1518

1619
/**
1720
* Class CategoriesTest
@@ -45,6 +48,11 @@ class CategoriesTest extends AbstractModifierTest
4548
*/
4649
protected $categoryCollectionMock;
4750

51+
/**
52+
* @var AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject
53+
*/
54+
private $authorizationMock;
55+
4856
protected function setUp()
4957
{
5058
parent::setUp();
@@ -63,6 +71,9 @@ protected function setUp()
6371
$this->categoryCollectionMock = $this->getMockBuilder(CategoryCollection::class)
6472
->disableOriginalConstructor()
6573
->getMock();
74+
$this->authorizationMock = $this->getMockBuilder(AuthorizationInterface::class)
75+
->disableOriginalConstructor()
76+
->getMock();
6677

6778
$this->categoryCollectionFactoryMock->expects($this->any())
6879
->method('create')
@@ -86,11 +97,15 @@ protected function setUp()
8697
*/
8798
protected function createModel()
8899
{
89-
return $this->objectManager->getObject(Categories::class, [
90-
'locator' => $this->locatorMock,
91-
'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
92-
'arrayManager' => $this->arrayManagerMock,
93-
]);
100+
return $this->objectManager->getObject(
101+
Categories::class,
102+
[
103+
'locator' => $this->locatorMock,
104+
'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
105+
'arrayManager' => $this->arrayManagerMock,
106+
'authorization' => $this->authorizationMock
107+
]
108+
);
94109
}
95110

96111
public function testModifyData()
@@ -130,7 +145,9 @@ public function testModifyMetaLocked($locked)
130145
],
131146
],
132147
];
133-
148+
$this->authorizationMock->expects($this->exactly(2))
149+
->method('isAllowed')
150+
->willReturn(true);
134151
$this->arrayManagerMock->expects($this->any())
135152
->method('findPath')
136153
->willReturn('path');

0 commit comments

Comments
 (0)