Skip to content

Commit

Permalink
Merge branch 'jquery-upgrade' of github.com:magento-lynx/magento2ce i…
Browse files Browse the repository at this point in the history
…nto MC-42049_fix_keydown_and_keyup
  • Loading branch information
eliseacornejo committed May 26, 2021
2 parents 86b6db8 + 979c0f7 commit eb5f69f
Show file tree
Hide file tree
Showing 58 changed files with 874 additions and 135 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Bundle/view/frontend/web/js/slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ define([
$('html, body').animate({
scrollTop: $(this.options.bundleOptionsContainer).offset().top
}, 600);
$('#product-options-wrapper > fieldset').focus();
$('#product-options-wrapper > fieldset').trigger('focus');
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ define([
content: data.message
});
} else {
$(this.options.categoryIdSelector).val(data.id).change();
$(this.options.categoryPathSelector).val(data.path).change();
$(this.options.categoryParentSelector).val(data.parentId).change();
$(this.options.categoryLevelSelector).val(data.level).change();
$(this.options.categoryIdSelector).val(data.id).trigger('change');
$(this.options.categoryPathSelector).val(data.path).trigger('change');
$(this.options.categoryParentSelector).val(data.parentId).trigger('change');
$(this.options.categoryLevelSelector).val(data.level).trigger('change');
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ define([
this.refreshSortableElements();
this.options.selectionItemCount[data.id] = parseInt(this.options.selectionItemCount[data.id], 10) + 1;

$('#' + this.options.fieldId + '_' + data.id + '_select_' + data['select_id'] + '_title').focus();
$('#' + this.options.fieldId + '_' + data.id + '_select_' + data['select_id'] + '_title').trigger('focus');
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ define([
$('#new_category_name').val(enteredName);

if (enteredName === '') {
$('#new_category_name').focus();
$('#new_category_name').trigger('focus');
}
$('#new_category_messages').html('');
},
Expand All @@ -88,7 +88,7 @@ define([
validationOptions.unhighlight($('#new_category_parent-suggest').get(0),
validationOptions.errorClass, validationOptions.validClass || '');
newCategoryForm.validation('clearError');
$('#category_ids-suggest').focus();
$('#category_ids-suggest').trigger('focus');
},
buttons: [{
text: $.mage.__('Create Category'),
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/view/frontend/web/js/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ define([
}, this));

// Window resize will change offset for draggable
$(window).resize(this._draggableImage());
$(window).on('resize', this._draggableImage);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define([
*/
stopLoader: function (forceStop) {
var $elem = $(containerId),
stop = $elem.trigger.bind($elem, 'processStop');
stop = $elem.trigger.bind($elem, 'processStop'); //eslint-disable-line jquery-no-bind-unbind

forceStop ? stop() : resolver(stop);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ define([
}

if (!emailValidationResult) {
$(loginFormSelector + ' input[name=username]').focus();
$(loginFormSelector + ' input[name=username]').trigger('focus');

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function execute(array $cartItemData): array
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
}

$this->checkProductStock($sku, (float) $qty, (int) $cart->getStore()->getWebsite()->getId());
$this->checkProductStock($sku, (float) $qty, (int) $cart->getStore()->getWebsiteId());

$configurableProductLinks = $parentProduct->getExtensionAttributes()->getConfigurableProductLinks();
if (!in_array($product->getId(), $configurableProductLinks)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\ConfigurableProductGraphQl\Test\Unit\Model\Cart\BuyRequest;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\CatalogInventory\Api\StockStateInterface;
use Magento\ConfigurableProductGraphQl\Model\Cart\BuyRequest\SuperAttributeDataProvider;
use Magento\ConfigurableProductGraphQl\Model\Options\Collection as OptionCollection;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Quote\Model\Quote;
use Magento\Store\Api\Data\StoreInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Test for SuperAttributeDataProvider
*/
class SuperAttributeDataProviderTest extends TestCase
{
/**
* @var ArrayManager|MockObject
*/
private $arrayManager;

/**
* @var ProductRepositoryInterface|MockObject
*/
private $productRepository;

/**
* @var OptionCollection|MockObject
*/
private $optionCollection;

/**
* @var MetadataPool|MockObject
*/
private $metadataPool;

/**
* @var StockStateInterface|MockObject
*/
private $stockState;

/**
* @var SuperAttributeDataProvider|MockObject
*/
private $superAttributeDataProvider;

/**
* @inheritDoc
*/
protected function setUp(): void
{
$this->arrayManager = $this->getMockBuilder(ArrayManager::class)
->disableOriginalConstructor()
->getMock();
$this->productRepository = $this->getMockBuilder(ProductRepositoryInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
$this->optionCollection = $this->createMock(OptionCollection::class);
$this->metadataPool = $this->getMockBuilder(MetadataPool::class)
->disableOriginalConstructor()
->onlyMethods(['getMetadata'])
->addMethods(['getLinkField'])
->getMock();
$this->stockState = $this->getMockBuilder(StockStateInterface::class)
->disableOriginalConstructor()
->addMethods(['getHasError'])
->getMockForAbstractClass();

$this->superAttributeDataProvider = new SuperAttributeDataProvider(
$this->arrayManager,
$this->productRepository,
$this->optionCollection,
$this->metadataPool,
$this->stockState
);
}

/**
* Check that website id is correctly retrieved
*/
public function testExecute(): void
{
$quoteMock = $this->getMockBuilder(Quote::class)
->disableOriginalConstructor()
->getMock();
$cartItemData = [
'data' => [
'quantity' => 2.0,
'sku' => 'simple1',
],
'parent_sku' => 'configurable',
'model' => $quoteMock,
];

$this->arrayManager->method('get')
->withConsecutive(
['parent_sku', $cartItemData],
['data/sku', $cartItemData],
['data/quantity', $cartItemData],
['model', $cartItemData],
)
->willReturnOnConsecutiveCalls(
'configurable',
'simple1',
2.0,
$quoteMock,
);

$storeMock = $this->getMockBuilder(StoreInterface::class)
->disableOriginalConstructor()
->addMethods(['getWebsite'])
->getMockForAbstractClass();
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
$storeMock->expects($this->never())->method('getWebsite');
$quoteMock->expects($this->atLeastOnce())
->method('getStore')
->willReturn($storeMock);

$productMock = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->onlyMethods(['getId', 'getExtensionAttributes', 'getData'])
->addMethods(['getConfigurableProductLinks'])
->getMock();
$productMock->method('getId')
->willReturn(1);
$productMock->method('getExtensionAttributes')
->willReturnSelf();
$productMock->method('getConfigurableProductLinks')
->willReturn([1]);
$productMock->method('getData')
->willReturn(1);
$this->productRepository->method('get')
->willReturn($productMock);
$this->stockState->method('checkQuoteItemQty')
->willReturnSelf();
$this->stockState->method('getHasError')
->willReturn(false);
$this->metadataPool->method('getMetadata')
->willReturnSelf();
$this->metadataPool->method('getLinkField')
->willReturnSelf();
$this->optionCollection->method('getAttributesByProductId')
->willReturn([
[
'attribute_code' => 'code',
'attribute_id' => 1,
'values' => [['value_index' => 1]],
]
]);

$this->assertEquals(['super_attribute' => [1 => 1]], $this->superAttributeDataProvider->execute($cartItemData));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use Magento\Framework\Exception\LocalizedException;
use Psr\Log\LoggerInterface;

/**
* Class for upload customer file attribute
*/
class Upload extends Action
{
/**
Expand All @@ -38,6 +41,11 @@ class Upload extends Action
*/
private $logger;

/**
* @var string
*/
private $scope;

/**
* @param Context $context
* @param FileUploaderFactory $fileUploaderFactory
Expand Down Expand Up @@ -65,15 +73,15 @@ public function execute()
if (empty($_FILES)) {
throw new \Exception('$_FILES array is empty.');
}

$attributeCode = key($_FILES['customer']['name']);
$scope = array_key_first($_FILES);
$attributeCode = key($_FILES[$scope]['name']);
$attributeMetadata = $this->customerMetadataService->getAttributeMetadata($attributeCode);

/** @var FileUploader $fileUploader */
$fileUploader = $this->fileUploaderFactory->create([
'attributeMetadata' => $attributeMetadata,
'entityTypeCode' => CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
'scope' => 'customer',
'scope' => $scope,
]);

$errors = $fileUploader->validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define([
container.show()
.find('.giftmessage-area:not(:visible)').each(function (x, element) {
if ($(element).val().length > 0) {
$(element).change();
$(element).trigger('change');
container.find('a').click();
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CliIndexerSetRealtimeModeActionGroup">
<annotations>
<description>Set indexers to realtime mode.</description>
</annotations>

<magentoCLI command="indexer:set-mode" arguments="realtime" stepKey="setRealtimeIndexerMode"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="CliIndexerSetScheduleModeActionGroup">
<annotations>
<description>Set indexers to schedule mode.</description>
</annotations>

<magentoCLI command="indexer:set-mode" arguments="schedule" stepKey="setScheduleIndexerMode"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
if (targetElement.is('textarea')) {
this.insertAtCursor(targetElement.get(0), data.content);
targetElement.focus();
$(targetElement).change();
$(targetElement).trigger('change');
} else {
targetElement.val(data.content)
.data('size', data.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ define([

if (self.isFullscreen && !self.fotoramaItem.data('fotorama').options.fullscreen.arrows) {
if ($('.' + self.FTAR + '--prev').is(':focus') || $('.' + self.FTAR + '--next').is(':focus')) {
$(self.FTCF).focus();
$(self.FTCF).trigger('focus');
}
}
});
Expand Down
Loading

0 comments on commit eb5f69f

Please sign in to comment.