Skip to content

Commit eb5f69f

Browse files
committed
Merge branch 'jquery-upgrade' of github.com:magento-lynx/magento2ce into MC-42049_fix_keydown_and_keyup
2 parents 86b6db8 + 979c0f7 commit eb5f69f

File tree

58 files changed

+874
-135
lines changed

Some content is hidden

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

58 files changed

+874
-135
lines changed

app/code/Magento/Bundle/view/frontend/web/js/slide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ define([
8585
$('html, body').animate({
8686
scrollTop: $(this.options.bundleOptionsContainer).offset().top
8787
}, 600);
88-
$('#product-options-wrapper > fieldset').focus();
88+
$('#product-options-wrapper > fieldset').trigger('focus');
8989
},
9090

9191
/**

app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ define([
4545
content: data.message
4646
});
4747
} else {
48-
$(this.options.categoryIdSelector).val(data.id).change();
49-
$(this.options.categoryPathSelector).val(data.path).change();
50-
$(this.options.categoryParentSelector).val(data.parentId).change();
51-
$(this.options.categoryLevelSelector).val(data.level).change();
48+
$(this.options.categoryIdSelector).val(data.id).trigger('change');
49+
$(this.options.categoryPathSelector).val(data.path).trigger('change');
50+
$(this.options.categoryParentSelector).val(data.parentId).trigger('change');
51+
$(this.options.categoryLevelSelector).val(data.level).trigger('change');
5252
}
5353
}
5454
};

app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ define([
437437
this.refreshSortableElements();
438438
this.options.selectionItemCount[data.id] = parseInt(this.options.selectionItemCount[data.id], 10) + 1;
439439

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

443443
/**

app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ define([
7575
$('#new_category_name').val(enteredName);
7676

7777
if (enteredName === '') {
78-
$('#new_category_name').focus();
78+
$('#new_category_name').trigger('focus');
7979
}
8080
$('#new_category_messages').html('');
8181
},
@@ -88,7 +88,7 @@ define([
8888
validationOptions.unhighlight($('#new_category_parent-suggest').get(0),
8989
validationOptions.errorClass, validationOptions.validClass || '');
9090
newCategoryForm.validation('clearError');
91-
$('#category_ids-suggest').focus();
91+
$('#category_ids-suggest').trigger('focus');
9292
},
9393
buttons: [{
9494
text: $.mage.__('Create Category'),

app/code/Magento/Catalog/view/frontend/web/js/zoom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ define([
9292
}, this));
9393

9494
// Window resize will change offset for draggable
95-
$(window).resize(this._draggableImage());
95+
$(window).on('resize', this._draggableImage);
9696
},
9797

9898
/**

app/code/Magento/Checkout/view/frontend/web/js/model/full-screen-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ define([
2727
*/
2828
stopLoader: function (forceStop) {
2929
var $elem = $(containerId),
30-
stop = $elem.trigger.bind($elem, 'processStop');
30+
stop = $elem.trigger.bind($elem, 'processStop'); //eslint-disable-line jquery-no-bind-unbind
3131

3232
forceStop ? stop() : resolver(stop);
3333
}

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ define([
354354
}
355355

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

359359
return false;
360360
}

app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function execute(array $cartItemData): array
9393
throw new GraphQlNoSuchEntityException(__('Could not find specified product.'));
9494
}
9595

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

9898
$configurableProductLinks = $parentProduct->getExtensionAttributes()->getConfigurableProductLinks();
9999
if (!in_array($product->getId(), $configurableProductLinks)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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\ConfigurableProductGraphQl\Test\Unit\Model\Cart\BuyRequest;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Product;
12+
use Magento\CatalogInventory\Api\StockStateInterface;
13+
use Magento\ConfigurableProductGraphQl\Model\Cart\BuyRequest\SuperAttributeDataProvider;
14+
use Magento\ConfigurableProductGraphQl\Model\Options\Collection as OptionCollection;
15+
use Magento\Framework\EntityManager\MetadataPool;
16+
use Magento\Framework\Stdlib\ArrayManager;
17+
use Magento\Quote\Model\Quote;
18+
use Magento\Store\Api\Data\StoreInterface;
19+
use PHPUnit\Framework\MockObject\MockObject;
20+
use PHPUnit\Framework\TestCase;
21+
22+
/**
23+
* Test for SuperAttributeDataProvider
24+
*/
25+
class SuperAttributeDataProviderTest extends TestCase
26+
{
27+
/**
28+
* @var ArrayManager|MockObject
29+
*/
30+
private $arrayManager;
31+
32+
/**
33+
* @var ProductRepositoryInterface|MockObject
34+
*/
35+
private $productRepository;
36+
37+
/**
38+
* @var OptionCollection|MockObject
39+
*/
40+
private $optionCollection;
41+
42+
/**
43+
* @var MetadataPool|MockObject
44+
*/
45+
private $metadataPool;
46+
47+
/**
48+
* @var StockStateInterface|MockObject
49+
*/
50+
private $stockState;
51+
52+
/**
53+
* @var SuperAttributeDataProvider|MockObject
54+
*/
55+
private $superAttributeDataProvider;
56+
57+
/**
58+
* @inheritDoc
59+
*/
60+
protected function setUp(): void
61+
{
62+
$this->arrayManager = $this->getMockBuilder(ArrayManager::class)
63+
->disableOriginalConstructor()
64+
->getMock();
65+
$this->productRepository = $this->getMockBuilder(ProductRepositoryInterface::class)
66+
->disableOriginalConstructor()
67+
->getMockForAbstractClass();
68+
$this->optionCollection = $this->createMock(OptionCollection::class);
69+
$this->metadataPool = $this->getMockBuilder(MetadataPool::class)
70+
->disableOriginalConstructor()
71+
->onlyMethods(['getMetadata'])
72+
->addMethods(['getLinkField'])
73+
->getMock();
74+
$this->stockState = $this->getMockBuilder(StockStateInterface::class)
75+
->disableOriginalConstructor()
76+
->addMethods(['getHasError'])
77+
->getMockForAbstractClass();
78+
79+
$this->superAttributeDataProvider = new SuperAttributeDataProvider(
80+
$this->arrayManager,
81+
$this->productRepository,
82+
$this->optionCollection,
83+
$this->metadataPool,
84+
$this->stockState
85+
);
86+
}
87+
88+
/**
89+
* Check that website id is correctly retrieved
90+
*/
91+
public function testExecute(): void
92+
{
93+
$quoteMock = $this->getMockBuilder(Quote::class)
94+
->disableOriginalConstructor()
95+
->getMock();
96+
$cartItemData = [
97+
'data' => [
98+
'quantity' => 2.0,
99+
'sku' => 'simple1',
100+
],
101+
'parent_sku' => 'configurable',
102+
'model' => $quoteMock,
103+
];
104+
105+
$this->arrayManager->method('get')
106+
->withConsecutive(
107+
['parent_sku', $cartItemData],
108+
['data/sku', $cartItemData],
109+
['data/quantity', $cartItemData],
110+
['model', $cartItemData],
111+
)
112+
->willReturnOnConsecutiveCalls(
113+
'configurable',
114+
'simple1',
115+
2.0,
116+
$quoteMock,
117+
);
118+
119+
$storeMock = $this->getMockBuilder(StoreInterface::class)
120+
->disableOriginalConstructor()
121+
->addMethods(['getWebsite'])
122+
->getMockForAbstractClass();
123+
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
124+
$storeMock->expects($this->never())->method('getWebsite');
125+
$quoteMock->expects($this->atLeastOnce())
126+
->method('getStore')
127+
->willReturn($storeMock);
128+
129+
$productMock = $this->getMockBuilder(Product::class)
130+
->disableOriginalConstructor()
131+
->onlyMethods(['getId', 'getExtensionAttributes', 'getData'])
132+
->addMethods(['getConfigurableProductLinks'])
133+
->getMock();
134+
$productMock->method('getId')
135+
->willReturn(1);
136+
$productMock->method('getExtensionAttributes')
137+
->willReturnSelf();
138+
$productMock->method('getConfigurableProductLinks')
139+
->willReturn([1]);
140+
$productMock->method('getData')
141+
->willReturn(1);
142+
$this->productRepository->method('get')
143+
->willReturn($productMock);
144+
$this->stockState->method('checkQuoteItemQty')
145+
->willReturnSelf();
146+
$this->stockState->method('getHasError')
147+
->willReturn(false);
148+
$this->metadataPool->method('getMetadata')
149+
->willReturnSelf();
150+
$this->metadataPool->method('getLinkField')
151+
->willReturnSelf();
152+
$this->optionCollection->method('getAttributesByProductId')
153+
->willReturn([
154+
[
155+
'attribute_code' => 'code',
156+
'attribute_id' => 1,
157+
'values' => [['value_index' => 1]],
158+
]
159+
]);
160+
161+
$this->assertEquals(['super_attribute' => [1 => 1]], $this->superAttributeDataProvider->execute($cartItemData));
162+
}
163+
}

app/code/Magento/Customer/Controller/Adminhtml/File/Customer/Upload.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Psr\Log\LoggerInterface;
1616

17+
/**
18+
* Class for upload customer file attribute
19+
*/
1720
class Upload extends Action
1821
{
1922
/**
@@ -38,6 +41,11 @@ class Upload extends Action
3841
*/
3942
private $logger;
4043

44+
/**
45+
* @var string
46+
*/
47+
private $scope;
48+
4149
/**
4250
* @param Context $context
4351
* @param FileUploaderFactory $fileUploaderFactory
@@ -65,15 +73,15 @@ public function execute()
6573
if (empty($_FILES)) {
6674
throw new \Exception('$_FILES array is empty.');
6775
}
68-
69-
$attributeCode = key($_FILES['customer']['name']);
76+
$scope = array_key_first($_FILES);
77+
$attributeCode = key($_FILES[$scope]['name']);
7078
$attributeMetadata = $this->customerMetadataService->getAttributeMetadata($attributeCode);
7179

7280
/** @var FileUploader $fileUploader */
7381
$fileUploader = $this->fileUploaderFactory->create([
7482
'attributeMetadata' => $attributeMetadata,
7583
'entityTypeCode' => CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
76-
'scope' => 'customer',
84+
'scope' => $scope,
7785
]);
7886

7987
$errors = $fileUploader->validate();

app/code/Magento/GiftMessage/view/frontend/web/js/gift-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ define([
4848
container.show()
4949
.find('.giftmessage-area:not(:visible)').each(function (x, element) {
5050
if ($(element).val().length > 0) {
51-
$(element).change();
51+
$(element).trigger('change');
5252
container.find('a').click();
5353
}
5454
});
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="CliIndexerSetRealtimeModeActionGroup">
11+
<annotations>
12+
<description>Set indexers to realtime mode.</description>
13+
</annotations>
14+
15+
<magentoCLI command="indexer:set-mode" arguments="realtime" stepKey="setRealtimeIndexerMode"/>
16+
</actionGroup>
17+
</actionGroups>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="CliIndexerSetScheduleModeActionGroup">
11+
<annotations>
12+
<description>Set indexers to schedule mode.</description>
13+
</annotations>
14+
15+
<magentoCLI command="indexer:set-mode" arguments="schedule" stepKey="setScheduleIndexerMode"/>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/grid/columns/image/insertImageAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define([
4949
if (targetElement.is('textarea')) {
5050
this.insertAtCursor(targetElement.get(0), data.content);
5151
targetElement.focus();
52-
$(targetElement).change();
52+
$(targetElement).trigger('change');
5353
} else {
5454
targetElement.val(data.content)
5555
.data('size', data.size)

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ define([
812812

813813
if (self.isFullscreen && !self.fotoramaItem.data('fotorama').options.fullscreen.arrows) {
814814
if ($('.' + self.FTAR + '--prev').is(':focus') || $('.' + self.FTAR + '--next').is(':focus')) {
815-
$(self.FTCF).focus();
815+
$(self.FTCF).trigger('focus');
816816
}
817817
}
818818
});

0 commit comments

Comments
 (0)