Skip to content

Commit 99f206f

Browse files
authored
Merge pull request #4869 from magento-epam/EPAM-PR-81
[epam] EPAM-PR-81
2 parents 128c2ad + 17f05b3 commit 99f206f

File tree

32 files changed

+805
-48
lines changed

32 files changed

+805
-48
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@
191191
<click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories"/>
192192
<dontSee selector="{{AdminCategorySidebarTreeSection.categoryInTree(categoryEntity.name)}}" stepKey="dontSeeCategoryInTree"/>
193193
</actionGroup>
194+
<actionGroup name="AdminDeleteCategoryByName" extends="DeleteCategory">
195+
<arguments>
196+
<argument name="categoryName" type="string" defaultValue="category1"/>
197+
</arguments>
198+
<remove keyForRemoval="clickCategoryLink"/>
199+
<remove keyForRemoval="dontSeeCategoryInTree"/>
200+
<remove keyForRemoval="expandToSeeAllCategories"/>
201+
<conditionalClick selector="{{AdminCategorySidebarTreeSection.expandAll}}" dependentSelector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" visible="false" stepKey="expandCategories" after="waitForCategoryPageLoad"/>
202+
<click selector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" stepKey="clickCategory" after="expandCategories"/>
203+
<conditionalClick selector="{{AdminCategorySidebarTreeSection.expandAll}}" dependentSelector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" visible="false" stepKey="expandCategoriesToSeeAll" after="seeDeleteSuccess"/>
204+
<dontSee selector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" stepKey="dontSeeCategory" after="expandCategoriesToSeeAll"/>
205+
</actionGroup>
194206

195207
<!-- Actions to fill out a new category from the product page-->
196208
<!-- The action assumes that you are already on an admin product configuration page -->
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="CatalogPriceScopeWebsiteConfigData">
12+
<data key="path">catalog/price/scope</data>
13+
<data key="value">1</data>
14+
</entity>
15+
<entity name="CatalogPriceScopeGlobalConfigData">
16+
<data key="path">catalog/price/scope</data>
17+
<data key="value">0</data>
18+
</entity>
19+
</entities>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<element name="lastCreatedCategory" type="block" selector=".x-tree-root-ct li li:last-child" />
2020
<element name="treeContainer" type="block" selector=".tree-holder" />
2121
<element name="expandRootCategory" type="text" selector="img.x-tree-elbow-end-plus"/>
22+
<element name="categoryByName" type="text" selector="//div[contains(@class, 'categories-side-col')]//a/span[contains(text(), '{{categoryName}}')]" parameterized="true" timeout="30"/>
2223
</section>
2324
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1010
<section name="AdminProductFormSection">
11+
<element name="datepickerNewAttribute" type="input" selector="[data-index='{{attrName}}'] input" timeout="30" parameterized="true"/>
1112
<element name="attributeSet" type="select" selector="div[data-index='attribute_set_id'] .admin__field-control"/>
1213
<element name="attributeSetFilter" type="input" selector="div[data-index='attribute_set_id'] .admin__field-control input" timeout="30"/>
1314
<element name="attributeSetFilterResult" type="input" selector="div[data-index='attribute_set_id'] .action-menu-item._last" timeout="30"/>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Ui\DataProvider\Product\Modifier;
9+
10+
use Magento\Framework\Escaper;
11+
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
12+
13+
/**
14+
* Modify product listing attributes
15+
*/
16+
class Attributes implements ModifierInterface
17+
{
18+
/**
19+
* @var Escaper
20+
*/
21+
private $escaper;
22+
23+
/**
24+
* @var array
25+
*/
26+
private $escapeAttributes;
27+
28+
/**
29+
* @param Escaper $escaper
30+
* @param array $escapeAttributes
31+
*/
32+
public function __construct(
33+
Escaper $escaper,
34+
array $escapeAttributes = []
35+
) {
36+
$this->escaper = $escaper;
37+
$this->escapeAttributes = $escapeAttributes;
38+
}
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
public function modifyData(array $data)
44+
{
45+
if (!empty($data) && !empty($this->escapeAttributes)) {
46+
foreach ($data['items'] as &$item) {
47+
foreach ($this->escapeAttributes as $escapeAttribute) {
48+
if (isset($item[$escapeAttribute])) {
49+
$item[$escapeAttribute] = $this->escaper->escapeHtml($item[$escapeAttribute]);
50+
}
51+
}
52+
}
53+
}
54+
return $data;
55+
}
56+
57+
/**
58+
* @inheritdoc
59+
*/
60+
public function modifyMeta(array $meta)
61+
{
62+
return $meta;
63+
}
64+
}

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,24 @@
166166
<argument name="pool" xsi:type="object">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool</argument>
167167
</arguments>
168168
</type>
169-
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Listing\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool"/>
169+
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Listing\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
170+
<arguments>
171+
<argument name="modifiers" xsi:type="array">
172+
<item name="attributes" xsi:type="array">
173+
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Modifier\Attributes</item>
174+
<item name="sortOrder" xsi:type="number">10</item>
175+
</item>
176+
</argument>
177+
</arguments>
178+
</virtualType>
179+
<type name="Magento\Catalog\Ui\DataProvider\Product\Modifier\Attributes">
180+
<arguments>
181+
<argument name="escapeAttributes" xsi:type="array">
182+
<item name="name" xsi:type="string">name</item>
183+
<item name="sku" xsi:type="string">sku</item>
184+
</argument>
185+
</arguments>
186+
</type>
170187
<type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions">
171188
<arguments>
172189
<argument name="scopeName" xsi:type="string">product_form.product_form</argument>

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
<arguments>
4949
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>
5050
</arguments>
51-
5251
<click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/>
5352
<fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}" stepKey="fillName" />
5453
<click stepKey="selectActive" selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}"/>
@@ -57,8 +56,27 @@
5756
<click stepKey="openActionDropdown" selector="{{AdminNewCatalogPriceRule.actionsTab}}"/>
5857
<fillField stepKey="fillDiscountValue" selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="{{catalogRule.discount_amount}}"/>
5958
<scrollToTopOfPage stepKey="scrollToTop"/>
59+
<click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/>
6060
<waitForPageLoad stepKey="waitForApplied"/>
6161
</actionGroup>
62+
63+
<actionGroup name="AdminCreateCatalogPriceRuleWithConditionActionGroup" extends="createCatalogPriceRule">
64+
<arguments>
65+
<argument name="catalogRuleType" type="entity" defaultValue="PriceRuleWithCondition"/>
66+
</arguments>
67+
<waitForPageLoad stepKey="waitForPageLoad" after="addNewRule"/>
68+
<click selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="expandConditions" before="openActionDropdown"/>
69+
<scrollTo selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="scrollToConditionsTab" after="expandConditions"/>
70+
<waitForElementVisible selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="waitForNewRule" after="scrollToConditionsTab"/>
71+
<click selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="clickNewRule" after="waitForNewRule"/>
72+
<selectOption selector="{{AdminNewCatalogPriceRuleConditions.conditionsDropdown}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="selectProductAttribute" after="clickNewRule"/>
73+
<waitForPageLoad stepKey="waitForAttributeLoad" after="selectProductAttribute"/>
74+
<!--Assert that attribute contains today date without time-->
75+
<comment userInput="Assert that attribute contains today date without time" stepKey="assertDate" after="waitForAttributeLoad"/>
76+
<generateDate date="now" format="Y-m-d" stepKey="today" after="assertDate"/>
77+
<grabTextFrom selector="{{PriceRuleConditionsSection.firstProductAttributeSelected}}" stepKey="grabTextFromSelectedAttribute" after="today"/>
78+
<assertEquals expected="$today" actual="$grabTextFromSelectedAttribute" stepKey="assertTodayDate" after="grabTextFromSelectedAttribute"/>
79+
</actionGroup>
6280
<actionGroup name="AdminCreateMultipleWebsiteCatalogPriceRule" extends="createCatalogPriceRule">
6381
<remove keyForRemoval="selectSite"/>
6482
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="['FirstWebsite', 'SecondWebsite']" stepKey="selectWebsite"/>

app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
<section name="AdminNewCatalogPriceRuleConditions">
4949
<element name="newCondition" type="button" selector=".rule-param.rule-param-new-child"/>
50+
<element name="conditionsDropdown" type="select" selector="select[data-form-part='catalog_rule_form'][data-ui-id='newchild-0-select-rule-conditions-1-new-child']"/>
5051
<element name="conditionSelect" type="select" selector="select#conditions__{{var}}__new_child" parameterized="true"/>
5152
<element name="targetEllipsis" type="button" selector="//li[{{var}}]//a[@class='label'][text() = '...']" parameterized="true"/>
5253
<element name="targetEllipsisValue" type="button" selector="//ul[@id='conditions__{{var}}__children']//a[contains(text(), '{{var1}}')]" parameterized="true" timeout="30"/>

app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php

Lines changed: 44 additions & 1 deletion
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\CatalogUrlRewrite\Observer;
79

810
use Magento\Catalog\Model\Category;
@@ -18,6 +20,14 @@
1820
*/
1921
class CategoryUrlPathAutogeneratorObserver implements ObserverInterface
2022
{
23+
24+
/**
25+
* Reserved endpoint names.
26+
*
27+
* @var string[]
28+
*/
29+
private $invalidValues = [];
30+
2131
/**
2232
* @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator
2333
*/
@@ -38,22 +48,34 @@ class CategoryUrlPathAutogeneratorObserver implements ObserverInterface
3848
*/
3949
private $categoryRepository;
4050

51+
/**
52+
* @var \Magento\Backend\App\Area\FrontNameResolver
53+
*/
54+
private $frontNameResolver;
55+
4156
/**
4257
* @param CategoryUrlPathGenerator $categoryUrlPathGenerator
4358
* @param ChildrenCategoriesProvider $childrenCategoriesProvider
4459
* @param \Magento\CatalogUrlRewrite\Service\V1\StoreViewService $storeViewService
4560
* @param CategoryRepositoryInterface $categoryRepository
61+
* @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver
62+
* @param string[] $invalidValues
4663
*/
4764
public function __construct(
4865
CategoryUrlPathGenerator $categoryUrlPathGenerator,
4966
ChildrenCategoriesProvider $childrenCategoriesProvider,
5067
StoreViewService $storeViewService,
51-
CategoryRepositoryInterface $categoryRepository
68+
CategoryRepositoryInterface $categoryRepository,
69+
\Magento\Backend\App\Area\FrontNameResolver $frontNameResolver = null,
70+
array $invalidValues = []
5271
) {
5372
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
5473
$this->childrenCategoriesProvider = $childrenCategoriesProvider;
5574
$this->storeViewService = $storeViewService;
5675
$this->categoryRepository = $categoryRepository;
76+
$this->frontNameResolver = $frontNameResolver ?: \Magento\Framework\App\ObjectManager::getInstance()
77+
->get(\Magento\Backend\App\Area\FrontNameResolver::class);
78+
$this->invalidValues = $invalidValues;
5779
}
5880

5981
/**
@@ -93,6 +115,17 @@ private function updateUrlKey($category, $urlKey)
93115
if (empty($urlKey)) {
94116
throw new \Magento\Framework\Exception\LocalizedException(__('Invalid URL key'));
95117
}
118+
119+
if (in_array($urlKey, $this->getInvalidValues())) {
120+
throw new \Magento\Framework\Exception\LocalizedException(
121+
__(
122+
'URL key "%1" matches a reserved endpoint name (%2). Use another URL key.',
123+
$urlKey,
124+
implode(', ', $this->getInvalidValues())
125+
)
126+
);
127+
}
128+
96129
$category->setUrlKey($urlKey)
97130
->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
98131
if (!$category->isObjectNew()) {
@@ -103,6 +136,16 @@ private function updateUrlKey($category, $urlKey)
103136
}
104137
}
105138

139+
/**
140+
* Get reserved endpoint names.
141+
*
142+
* @return array
143+
*/
144+
private function getInvalidValues()
145+
{
146+
return array_unique(array_merge($this->invalidValues, [$this->frontNameResolver->getFrontName()]));
147+
}
148+
106149
/**
107150
* Update url path for children category.
108151
*
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="AdminCategoryRestrictedUrlErrorMessage">
12+
<data key="urlAdmin">URL key "admin" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data>
13+
<data key="urlSoap">URL key "soap" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data>
14+
<data key="urlRest">URL key "rest" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data>
15+
<data key="urlGraphql">URL key "graphql" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data>
16+
</entity>
17+
</entities>

0 commit comments

Comments
 (0)