Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #26251: [Customer] Removing the delete buttons for default customer groups (by @eduard13)
 - #26270: Fix #22964 (by @marcoaacoliveira)
 - #26290: [Fixed Jump Datepicker issue in Catalog Price Rule] (by @hitesh-wagento)
 - #26263: Fix #14913 - bookmark views become uneditable after deleting the first bookmark view (by @Bartlomiejsz)
 - #26048: Fixed spelling and adjusted white spaces (by @pawankparmar)
 - #25985: Fixed ability to save configuration in field without label (by @AndreyChorniy)
 - #25337: #14971 Improper Handling of Pagination SEO (by @chickenland)
 - #22990: [Catalog|Sales] Fix wrong behavior of grid row click event (by @Den4ik)
 - #26218: FIX issue#26217 - Wrong fields selection while using fragments on GraphQL (by @phoenix128)
 - #26281: HOTFIX: Invalid use of OpenOrderById (by @lbajsarowicz)


Fixed GitHub Issues:
 - #22964: Unable to save any dates if the user interface locale is not english (US) in 2.3.1 (reported by @ioweb-gr) has been fixed in #26270 by @marcoaacoliveira in 2.4-develop branch
   Related commits:
     1. bb16e33
     2. d12ac21
     3. 32be472
     4. 6a19b12
     5. 6e80158
     6. 8ee89af
     7. c85410d

 - #26289: Jump Datepicker in  Catalog Price Rule (reported by @hitesh-wagento) has been fixed in #26290 by @hitesh-wagento in 2.4-develop branch
   Related commits:
     1. 557247f

 - #14913: bookmark views become uneditable after deleting the first bookmark view. (reported by @Jakhotiya) has been fixed in #26263 by @Bartlomiejsz in 2.4-develop branch
   Related commits:
     1. fe98438

 - #23899: system.xml file validation issue (reported by @Gurdit) has been fixed in #25985 by @AndreyChorniy in 2.4-develop branch
   Related commits:
     1. c273067
     2. eb40893
     3. cfd7771
     4. 1308074
     5. 5e6c595
     6. f30a06a

 - #14971: Improper Handling of Pagination SEO (reported by @winterk80) has been fixed in #25337 by @chickenland in 2.4-develop branch
   Related commits:
     1. c57d98c
     2. 3f4642e
     3. 2860283
     4. 94e8685
     5. 9c4991a

 - #22988: Wrong behavior of grid row and checkbox click (reported by @Den4ik) has been fixed in #22990 by @Den4ik in 2.4-develop branch
   Related commits:
     1. 0105e4c
     2. 22aa250
     3. 2b19c93
     4. 0988b6e
     5. 69447cb
     6. 021b5d8
     7. 27a57de
     8. d2af286
     9. 8b7458e

 - #26217: Wrong fields selection while using fragments on GraphQL products query (reported by @phoenix128) has been fixed in #26218 by @phoenix128 in 2.4-develop branch
   Related commits:
     1. 2b5720c
     2. 631282e
  • Loading branch information
VladimirZaets authored Jan 9, 2020
2 parents 7ccd640 + 47e4b4e commit dbb159a
Show file tree
Hide file tree
Showing 20 changed files with 1,021 additions and 385 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function getFinalPrice();

/**
* Set the final price: usually it calculated as minimal price of the product
*
* Can be different depends on type of product
*
* @param string $finalPrice
Expand All @@ -39,6 +40,7 @@ public function setFinalPrice($finalPrice);

/**
* Retrieve max price of a product
*
* E.g. for product with custom options is price with the most expensive custom option
*
* @return string
Expand All @@ -57,6 +59,7 @@ public function setMaxPrice($maxPrice);

/**
* Retrieve the minimal price of the product or variation
*
* The minimal price is for example, the lowest price of all variations for complex product
*
* @return string
Expand All @@ -66,7 +69,7 @@ public function getMinimalPrice();

/**
* Set max regular price
* Max regular price is the same, as maximum price, except of excluding calculating special price and catalogules
* Max regular price is the same, as maximum price, except of excluding calculating special price and catalog rules
* in it
*
* @param string $maxRegularPrice
Expand Down Expand Up @@ -130,6 +133,7 @@ public function setMinimalPrice($minimalPrice);

/**
* Regular price - is price of product without discounts and special price with taxes and fixed product tax
*
* Usually this price is corresponding to price in admin panel of product
*
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,29 @@ define([
*/
function categoryProductRowClick(grid, event) {
var trElement = Event.findElement(event, 'tr'),
isInput = Event.element(event).tagName === 'INPUT',
eventElement = Event.element(event),
isInputCheckbox = eventElement.tagName === 'INPUT' && eventElement.type === 'checkbox',
isInputPosition = grid.targetElement &&
grid.targetElement.tagName === 'INPUT' &&
grid.targetElement.name === 'position',
checked = false,
checkbox = null;

if (trElement) {
if (eventElement.tagName === 'LABEL' &&
trElement.querySelector('#' + eventElement.htmlFor) &&
trElement.querySelector('#' + eventElement.htmlFor).type === 'checkbox'
) {
event.stopPropagation();
trElement.querySelector('#' + eventElement.htmlFor).trigger('click');

return;
}

if (trElement && !isInputPosition) {
checkbox = Element.getElementsBySelector(trElement, 'input');

if (checkbox[0]) {
checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
checked = isInputCheckbox ? checkbox[0].checked : !checkbox[0].checked;
gridJsObject.setCheckboxChecked(checkbox[0], checked);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Magento\CatalogGraphQl\Model\Resolver\Products\Query;

use GraphQL\Language\AST\SelectionNode;
use Magento\Framework\GraphQl\Query\FieldTranslator;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

Expand Down Expand Up @@ -37,57 +36,18 @@ public function __construct(FieldTranslator $fieldTranslator)
*/
public function getProductsFieldSelection(ResolveInfo $resolveInfo): array
{
return $this->getProductFields($resolveInfo);
}
$productFields = $resolveInfo->getFieldSelection(1);
$sectionNames = ['items', 'product'];

/**
* Return field names for all requested product fields.
*
* @param ResolveInfo $info
* @return string[]
*/
private function getProductFields(ResolveInfo $info): array
{
$fieldNames = [];
foreach ($info->fieldNodes as $node) {
if ($node->name->value !== 'products' && $node->name->value !== 'variants') {
continue;
}
foreach ($node->selectionSet->selections as $selection) {
if ($selection->name->value !== 'items' && $selection->name->value !== 'product') {
continue;
}
$fieldNames[] = $this->collectProductFieldNames($selection, $fieldNames);
}
}
if (!empty($fieldNames)) {
$fieldNames = array_merge(...$fieldNames);
}
return $fieldNames;
}

/**
* Collect field names for each node in selection
*
* @param SelectionNode $selection
* @param array $fieldNames
* @return array
*/
private function collectProductFieldNames(SelectionNode $selection, array $fieldNames = []): array
{
foreach ($selection->selectionSet->selections as $itemSelection) {
if ($itemSelection->kind === 'InlineFragment') {
foreach ($itemSelection->selectionSet->selections as $inlineSelection) {
if ($inlineSelection->kind === 'InlineFragment') {
continue;
}
$fieldNames[] = $this->fieldTranslator->translate($inlineSelection->name->value);
foreach ($sectionNames as $sectionName) {
if (isset($productFields[$sectionName])) {
foreach (array_keys($productFields[$sectionName]) as $fieldName) {
$fieldNames[] = $this->fieldTranslator->translate($fieldName);
}
continue;
}
$fieldNames[] = $this->fieldTranslator->translate($itemSelection->name->value);
}

return $fieldNames;
return array_unique($fieldNames);
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/Config/Model/Config/Structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ public function getFieldPathsByAttribute($attributeName, $attributeValue)
foreach ($section['children'] as $group) {
if (isset($group['children'])) {
$path = $section['id'] . '/' . $group['id'];
// phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge
$result = array_merge(
$result,
$this->_getGroupFieldPathsByAttribute(
Expand Down Expand Up @@ -398,7 +399,7 @@ private function getFieldsRecursively(array $elements = [])
$this->getFieldsRecursively($element['children'])
);
} else {
if ($element['_elementType'] === 'field' && isset($element['label'])) {
if ($element['_elementType'] === 'field') {
$structurePath = (isset($element['path']) ? $element['path'] . '/' : '') . $element['id'];
$configPath = isset($element['config_path']) ? $element['config_path'] : $structurePath;

Expand Down
128 changes: 98 additions & 30 deletions app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class StructureTest extends \PHPUnit\Framework\TestCase
*/
protected $_structureData;

/**
* @inheritdoc
*/
protected function setUp()
{
$this->_flyweightFactory = $this->getMockBuilder(FlyweightFactory::class)
Expand Down Expand Up @@ -82,7 +85,12 @@ protected function setUp()
);
}

public function testGetTabsBuildsSectionTree()
/**
* Verify tabs build section tree
*
* @return void
*/
public function testGetTabsBuildsSectionTree(): void
{
$expected = ['tab1' => ['children' => ['section1' => ['tab' => 'tab1']]]];

Expand All @@ -108,7 +116,12 @@ public function testGetTabsBuildsSectionTree()
$this->assertEquals($this->_tabIteratorMock, $model->getTabs());
}

public function testGetSectionList()
/**
* Verify get section list method
*
* @return void
*/
public function testGetSectionList(): void
{
$expected = [
'section1_child_id_1' => true,
Expand Down Expand Up @@ -152,6 +165,8 @@ public function testGetSectionList()
}

/**
* Verify Get Element return empty element if element is requested
*
* @param string $path
* @param string $expectedType
* @param string $expectedId
Expand All @@ -174,6 +189,8 @@ public function testGetElementReturnsEmptyElementIfNotExistingElementIsRequested
}

/**
* Verify get Element return empty by path element if not exist
*
* @param string $path
* @param string $expectedType
* @param string $expectedId
Expand All @@ -196,6 +213,8 @@ public function testGetElementReturnsEmptyByConfigPathElementIfNotExistingElemen
}

/**
* Verify Element return e,pty element if not exists
*
* @param string $expectedType
* @param string $expectedId
* @param string $expectedPath
Expand Down Expand Up @@ -234,21 +253,33 @@ public function emptyElementDataProvider()
];
}

public function testGetElementReturnsProperElementByPath()
/**
* Verify get element returns proper element by path
*
* @return void
*/
public function testGetElementReturnsProperElementByPath(): void
{
$elementMock = $this->getElementPathReturnsProperElementByPath();

$this->assertEquals($elementMock, $this->_model->getElement('section_1/group_level_1/field_3'));
}

public function testGetElementByConfigPathReturnsProperElementByPath()
/**
* Verify get element by config path return proper path
*
* @return void
*/
public function testGetElementByConfigPathReturnsProperElementByPath(): void
{
$elementMock = $this->getElementPathReturnsProperElementByPath();

$this->assertEquals($elementMock, $this->_model->getElementByConfigPath('section_1/group_level_1/field_3'));
}

/**
* Build mock element
*
* @return Mock
*/
private function getElementPathReturnsProperElementByPath()
Expand All @@ -271,7 +302,12 @@ private function getElementPathReturnsProperElementByPath()
return $elementMock;
}

public function testGetElementByPathPartsIfSectionDataIsEmpty()
/**
* Verefy get element by path part
*
* @return void
*/
public function testGetElementByPathPartsIfSectionDataIsEmpty(): void
{
$fieldData = [
'id' => 'field_3',
Expand Down Expand Up @@ -342,15 +378,25 @@ public function testGetFirstSectionReturnsFirstAllowedSection()
$this->assertEquals('currentSection', $this->_model->getFirstSection()->getData());
}

public function testGetElementReturnsProperElementByPathCachesObject()
/**
* Verify get element return element by path caches object
*
* @return void
*/
public function testGetElementReturnsProperElementByPathCachesObject(): void
{
$elementMock = $this->getElementReturnsProperElementByPathCachesObject();

$this->assertEquals($elementMock, $this->_model->getElement('section_1/group_level_1/field_3'));
$this->assertEquals($elementMock, $this->_model->getElement('section_1/group_level_1/field_3'));
}

public function testGetElementByConfigPathReturnsProperElementByPathCachesObject()
/**
* Verify Get Element by id returns proper element
*
* @return void
*/
public function testGetElementByConfigPathReturnsProperElementByPathCachesObject(): void
{
$elementMock = $this->getElementReturnsProperElementByPathCachesObject();

Expand Down Expand Up @@ -393,6 +439,8 @@ public function testGetFieldPathsByAttribute($attributeName, $attributeValue, $p
}

/**
* DataProvider
*
* @return array
*/
public function getFieldPathsByAttributeDataProvider()
Expand All @@ -411,33 +459,53 @@ public function getFieldPathsByAttributeDataProvider()
];
}

public function testGetFieldPaths()
/**
* Verify get Fields paths method
*
* @dataProvider getFieldPaths
* @param array $expected
* @return void
*/
public function testGetFieldPaths(array $expected): void
{
$expected = [
'section/group/field2' => [
'field_2'
],
'field_3' => [
'field_3',
'field_3'
],
'field_3_1' => [
'field_3_1'
],
'field_3_1_1' => [
'field_3_1_1'
],
'section/group/field4' => [
'field_4',
],
'field_5' => [
'field_5',
],
];

$this->assertSame(
$expected,
$this->_model->getFieldPaths()
);
}

/**
* dataprovider for Field Paths
*
* @return array
*/
public function getFieldPaths(): array
{
return [
[
[
'section/group/field2' => [
'field_2'
],
'field_3' => [
'field_3',
'field_3'
],
'field_3_1' => [
'field_3_1'
],
'field_3_1_1' => [
'field_3_1_1'
],
'section/group/field4' => [
'field_4',
],
'field_5' => [
'field_5',
'field_5'
]
]
]
];
}
}
Loading

0 comments on commit dbb159a

Please sign in to comment.