Skip to content

Commit 06a9fb6

Browse files
Merge branch '2.4-develop' into patch-20
2 parents b5b0648 + 4b75b15 commit 06a9fb6

File tree

138 files changed

+3714
-1105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+3714
-1105
lines changed

app/code/Magento/Backend/Test/Mftf/Test/AdminAttributeTextSwatchesCanBeFiledTest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@
9494
</actionGroup>
9595

9696
<!--Navigate to Product attribute page-->
97-
<amOnPage url="{{ProductAttributePage.url}}" stepKey="navigateToNewProductAttributePage"/>
98-
<waitForPageLoad stepKey="waitForPageLoad"/>
97+
<actionGroup ref="AdminNavigateToNewProductAttributePageActionGroup" stepKey="navigateToNewProductAttributePage"/>
9998
<fillField userInput="test_label" selector="{{AttributePropertiesSection.DefaultLabel}}" stepKey="fillDefaultLabel"/>
10099
<selectOption selector="{{AttributePropertiesSection.InputType}}" userInput="Text Swatch" stepKey="selectInputType"/>
101100
<click selector="{{AttributePropertiesSection.addSwatch}}" stepKey="clickAddSwatch"/>

app/code/Magento/Catalog/Model/Layer/Filter/Price/Render.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public function renderRangeLabel($fromPrice, $toPrice)
7272
}
7373

7474
/**
75+
* Prepare range data
76+
*
7577
* @param int $range
7678
* @param int[] $dbRanges
7779
* @return array
@@ -81,12 +83,10 @@ public function renderRangeData($range, $dbRanges)
8183
if (empty($dbRanges)) {
8284
return [];
8385
}
84-
$lastIndex = array_keys($dbRanges);
85-
$lastIndex = $lastIndex[count($lastIndex) - 1];
8686

8787
foreach ($dbRanges as $index => $count) {
88-
$fromPrice = $index == 1 ? '' : ($index - 1) * $range;
89-
$toPrice = $index == $lastIndex ? '' : $index * $range;
88+
$fromPrice = $index == 1 ? 0 : ($index - 1) * $range;
89+
$toPrice = $index * $range;
9090
$this->itemDataBuilder->addItemData(
9191
$this->renderRangeLabel($fromPrice, $toPrice),
9292
$fromPrice . '-' . $toPrice,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminCreateCategoryWithInactiveIncludeInMenuActionGroup" extends="CreateCategoryActionGroup">
12+
<annotations>
13+
<description>EXTENDS: CreateCategory. Add "disableIncludeInMenuOption" step.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="categoryEntity" defaultValue="_defaultCategory"/>
17+
</arguments>
18+
19+
<click selector="{{AdminCategoryBasicFieldSection.includeInMenuLabel}}" stepKey="disableIncludeInMenuOption"
20+
after="seeCategoryPageTitle"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminCreateInactiveCategoryActionGroup" extends="CreateCategoryActionGroup">
12+
<annotations>
13+
<description>EXTENDS: CreateCategory. Add "disableCategory" step.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="categoryEntity" defaultValue="_defaultCategory"/>
17+
</arguments>
18+
19+
<click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="disableCategory"
20+
after="seeCategoryPageTitle"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminCategoryIsInactiveActionGroup">
12+
<annotations>
13+
<description>Verify the category is disabled</description>
14+
</annotations>
15+
16+
<dontSeeCheckboxIsChecked selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="seeCategoryIsDisabled"/>
17+
</actionGroup>
18+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,12 @@
2626
</after>
2727
<!-- Create In active Category -->
2828
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/>
29-
<click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/>
30-
<click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="disableCategory"/>
31-
<checkOption selector="{{AdminCategoryBasicFieldSection.IncludeInMenu}}" stepKey="enableIncludeInMenu"/>
32-
<fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/>
33-
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/>
34-
<waitForPageLoad stepKey="waitForCategorySaved"/>
35-
<actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/>
36-
<see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" />
37-
<dontSeeCheckboxIsChecked selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="dontCategoryIsChecked"/>
38-
<!--Verify InActive Category is created-->
39-
<seeElement selector="{{AdminCategoryContentSection.categoryInTree(_defaultCategory.name)}}" stepKey="seeCategoryInTree" />
29+
<actionGroup ref="AdminCreateInactiveCategoryActionGroup" stepKey="createInactiveCategory"/>
30+
<actionGroup ref="AssertAdminCategoryIsInactiveActionGroup" stepKey="seeDisabledCategory"/>
4031
<!--Verify Category is not listed store front page-->
41-
<amOnPage url="{{StorefrontCategoryPage.url(_defaultCategory.name)}}" stepKey="amOnCategoryPage"/>
42-
<waitForPageLoad stepKey="waitForPageToBeLoaded"/>
43-
<dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(_defaultCategory.name)}}" stepKey="dontSeeCategoryOnStoreFrontPage"/>
32+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToStoreFront"/>
33+
<actionGroup ref="StorefrontAssertCategoryNameIsNotShownInMenuActionGroup" stepKey="doNotSeeCategoryNameInMenu">
34+
<argument name="categoryName" value="{{_defaultCategory.name}}"/>
35+
</actionGroup>
4436
</test>
4537
</tests>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,11 @@
2626
</after>
2727
<!--Create Category with not included in menu Subcategory -->
2828
<actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/>
29-
<click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/>
30-
<checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/>
31-
<click selector="{{AdminCategoryBasicFieldSection.includeInMenuLabel}}" stepKey="disableIncludeInMenu"/>
32-
<fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/>
33-
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/>
34-
<waitForPageLoad stepKey="waitForCategorySaved"/>
35-
<actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/>
36-
<waitForPageLoad stepKey="waitForPageSaved"/>
37-
<see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" />
38-
<!--Verify Category is created/>-->
39-
<seeElement selector="{{AdminCategoryContentSection.activeCategoryInTree(_defaultCategory.name)}}" stepKey="seeCategoryInTree" />
29+
<actionGroup ref="AdminCreateCategoryWithInactiveIncludeInMenuActionGroup" stepKey="createNotIncludedInMenuCategory"/>
4030
<!--Verify Category in store front page menu/>-->
41-
<amOnPage url="{{StorefrontCategoryPage.url(_defaultCategory.name)}}" stepKey="amOnCategoryPage"/>
42-
<waitForPageLoad stepKey="waitForPageToBeLoaded"/>
43-
<see selector="{{StorefrontCategoryMainSection.CategoryTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seeCategoryPageTitle"/>
44-
<dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(_defaultCategory.name)}}" stepKey="dontSeeCategoryOnNavigation"/>
31+
<actionGroup ref="CheckCategoryOnStorefrontActionGroup" stepKey="CheckCategoryOnStorefront"/>
32+
<actionGroup ref="StorefrontAssertCategoryNameIsNotShownInMenuActionGroup" stepKey="doNotSeeCategoryOnNavigation">
33+
<argument name="categoryName" value="{{_defaultCategory.name}}"/>
34+
</actionGroup>
4535
</test>
4636
</tests>

app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDropdownProductAttributeTest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
2828
</after>
2929

30-
<amOnPage url="{{ProductAttributePage.url}}" stepKey="navigateToNewProductAttributePage"/>
31-
<waitForPageLoad stepKey="waitForPageLoad"/>
30+
<actionGroup ref="AdminNavigateToNewProductAttributePageActionGroup" stepKey="navigateToNewProductAttributePage"/>
3231

3332
<!-- Set attribute properties -->
3433
<fillField selector="{{AttributePropertiesSection.DefaultLabel}}"

app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
namespace Magento\CatalogGraphQl\Model;
99

1010
use GraphQL\Language\AST\FieldNode;
11+
use GraphQL\Language\AST\InlineFragmentNode;
12+
use GraphQL\Language\AST\NodeKind;
1113
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
14+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1215

1316
/**
1417
* Joins attributes for provided field node field names.
@@ -43,11 +46,12 @@ public function __construct(array $fieldToAttributeMap = [])
4346
*
4447
* @param FieldNode $fieldNode
4548
* @param AbstractCollection $collection
49+
* @param ResolveInfo $resolveInfo
4650
* @return void
4751
*/
48-
public function join(FieldNode $fieldNode, AbstractCollection $collection): void
52+
public function join(FieldNode $fieldNode, AbstractCollection $collection, ResolveInfo $resolveInfo): void
4953
{
50-
foreach ($this->getQueryFields($fieldNode) as $field) {
54+
foreach ($this->getQueryFields($fieldNode, $resolveInfo) as $field) {
5155
$this->addFieldToCollection($collection, $field);
5256
}
5357
}
@@ -56,26 +60,70 @@ public function join(FieldNode $fieldNode, AbstractCollection $collection): void
5660
* Get an array of queried fields.
5761
*
5862
* @param FieldNode $fieldNode
63+
* @param ResolveInfo $resolveInfo
5964
* @return string[]
6065
*/
61-
public function getQueryFields(FieldNode $fieldNode): array
66+
public function getQueryFields(FieldNode $fieldNode, ResolveInfo $resolveInfo): array
6267
{
6368
if (null === $this->getFieldNodeSelections($fieldNode)) {
6469
$query = $fieldNode->selectionSet->selections;
6570
$selectedFields = [];
71+
$fragmentFields = [];
6672
/** @var FieldNode $field */
6773
foreach ($query as $field) {
68-
if ($field->kind === 'InlineFragment') {
69-
continue;
74+
if ($field->kind === NodeKind::INLINE_FRAGMENT) {
75+
$fragmentFields[] = $this->addInlineFragmentFields($resolveInfo, $field);
76+
} elseif ($field->kind === NodeKind::FRAGMENT_SPREAD &&
77+
($spreadFragmentNode = $resolveInfo->fragments[$field->name->value])) {
78+
79+
foreach ($spreadFragmentNode->selectionSet->selections as $spreadNode) {
80+
if (isset($spreadNode->selectionSet->selections)) {
81+
$fragmentFields[] = $this->getQueryFields($spreadNode, $resolveInfo);
82+
} else {
83+
$selectedFields[] = $spreadNode->name->value;
84+
}
85+
}
86+
} else {
87+
$selectedFields[] = $field->name->value;
7088
}
71-
$selectedFields[] = $field->name->value;
7289
}
73-
$this->setSelectionsForFieldNode($fieldNode, $selectedFields);
90+
if ($fragmentFields) {
91+
$selectedFields = array_merge($selectedFields, array_merge(...$fragmentFields));
92+
}
93+
$this->setSelectionsForFieldNode($fieldNode, array_unique($selectedFields));
7494
}
7595

7696
return $this->getFieldNodeSelections($fieldNode);
7797
}
7898

99+
/**
100+
* Add fields from inline fragment nodes
101+
*
102+
* @param ResolveInfo $resolveInfo
103+
* @param InlineFragmentNode $inlineFragmentField
104+
* @param array $inlineFragmentFields
105+
* @return string[]
106+
*/
107+
private function addInlineFragmentFields(
108+
ResolveInfo $resolveInfo,
109+
InlineFragmentNode $inlineFragmentField,
110+
$inlineFragmentFields = []
111+
): array {
112+
$query = $inlineFragmentField->selectionSet->selections;
113+
/** @var FieldNode $field */
114+
foreach ($query as $field) {
115+
if ($field->kind === NodeKind::INLINE_FRAGMENT) {
116+
$this->addInlineFragmentFields($resolveInfo, $field, $inlineFragmentFields);
117+
} elseif (isset($field->selectionSet->selections)) {
118+
continue;
119+
} else {
120+
$inlineFragmentFields[] = $field->name->value;
121+
}
122+
}
123+
124+
return array_unique($inlineFragmentFields);
125+
}
126+
79127
/**
80128
* Add field to collection select
81129
*

app/code/Magento/CatalogGraphQl/Model/Category/DepthCalculator.php

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
namespace Magento\CatalogGraphQl\Model\Category;
99

1010
use GraphQL\Language\AST\FieldNode;
11+
use GraphQL\Language\AST\InlineFragmentNode;
12+
use GraphQL\Language\AST\NodeKind;
13+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1114

1215
/**
1316
* Used for determining the depth information for a requested category tree in a GraphQL request
@@ -17,22 +20,57 @@ class DepthCalculator
1720
/**
1821
* Calculate the total depth of a category tree inside a GraphQL request
1922
*
23+
* @param ResolveInfo $resolveInfo
2024
* @param FieldNode $fieldNode
2125
* @return int
2226
*/
23-
public function calculate(FieldNode $fieldNode) : int
27+
public function calculate(ResolveInfo $resolveInfo, FieldNode $fieldNode) : int
2428
{
2529
$selections = $fieldNode->selectionSet->selections ?? [];
2630
$depth = count($selections) ? 1 : 0;
2731
$childrenDepth = [0];
2832
foreach ($selections as $node) {
29-
if ($node->kind === 'InlineFragment' || null !== $node->alias) {
33+
if (isset($node->alias) && null !== $node->alias) {
3034
continue;
3135
}
3236

33-
$childrenDepth[] = $this->calculate($node);
37+
if ($node->kind === NodeKind::INLINE_FRAGMENT) {
38+
$childrenDepth[] = $this->addInlineFragmentDepth($resolveInfo, $node);
39+
} elseif ($node->kind === NodeKind::FRAGMENT_SPREAD && isset($resolveInfo->fragments[$node->name->value])) {
40+
foreach ($resolveInfo->fragments[$node->name->value]->selectionSet->selections as $spreadNode) {
41+
$childrenDepth[] = $this->calculate($resolveInfo, $spreadNode);
42+
}
43+
} else {
44+
$childrenDepth[] = $this->calculate($resolveInfo, $node);
45+
}
3446
}
3547

3648
return $depth + max($childrenDepth);
3749
}
50+
51+
/**
52+
* Add inline fragment fields into calculating of category depth
53+
*
54+
* @param ResolveInfo $resolveInfo
55+
* @param InlineFragmentNode $inlineFragmentField
56+
* @param array $depth
57+
* @return int
58+
*/
59+
private function addInlineFragmentDepth(
60+
ResolveInfo $resolveInfo,
61+
InlineFragmentNode $inlineFragmentField,
62+
$depth = []
63+
): int {
64+
$selections = $inlineFragmentField->selectionSet->selections;
65+
/** @var FieldNode $field */
66+
foreach ($selections as $field) {
67+
if ($field->kind === NodeKind::INLINE_FRAGMENT) {
68+
$depth[] = $this->addInlineFragmentDepth($resolveInfo, $field, $depth);
69+
} elseif ($field->selectionSet && $field->selectionSet->selections) {
70+
$depth[] = $this->calculate($resolveInfo, $field);
71+
}
72+
}
73+
74+
return $depth ? max($depth) : 0;
75+
}
3876
}

0 commit comments

Comments
 (0)