Skip to content

Commit 6df825a

Browse files
authored
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop daily delivery
Accepted Community Pull Requests: - #26378: 26375 braintree payment address issue (by @chris-pook) - #25641: M2C-21768 Validate product quantity on Wishlist update (by @ptylek) - #25285: Add lib wrapper for UUID validation. (by @nikolaevas) Fixed GitHub Issues: - #26375: Switching billing address causes Javascript function text to render in front-end checkout payment section (reported by @chris-pook) has been fixed in #26378 by @chris-pook in 2.4-develop branch Related commits: 1. 4ea41d0 2. ee3f8e3 3. 5427099 - #25032: Display some error "We can't update your Wish List right now." at wish list (reported by @renard123) has been fixed in #25641 by @ptylek in 2.4-develop branch Related commits: 1. a5a2cbc 2. 5415e99 3. b2fc304 4. b398206
2 parents c61a2c6 + 5877e54 commit 6df825a

File tree

8 files changed

+133
-5
lines changed

8 files changed

+133
-5
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ define(
1818
'Magento_Vault/js/view/payment/vault-enabler',
1919
'Magento_Braintree/js/view/payment/kount',
2020
'mage/translate',
21-
'prototype',
2221
'domReady!'
2322
],
2423
function (

app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ define([
1616
groupedInfo: '#super-product-table input',
1717
downloadableInfo: '#downloadable-links-list input',
1818
customOptionsInfo: '.product-custom-option',
19-
qtyInfo: '#qty'
19+
qtyInfo: '#qty',
20+
actionElement: '[data-action="add-to-wishlist"]'
2021
},
2122

2223
/** @inheritdoc */
@@ -30,8 +31,10 @@ define([
3031
_bind: function () {
3132
var options = this.options,
3233
dataUpdateFunc = '_updateWishlistData',
34+
validateProductQty = '_validateWishlistQty',
3335
changeCustomOption = 'change ' + options.customOptionsInfo,
3436
changeQty = 'change ' + options.qtyInfo,
37+
updateWishlist = 'click ' + options.actionElement,
3538
events = {},
3639
key;
3740

@@ -45,6 +48,7 @@ define([
4548

4649
events[changeCustomOption] = dataUpdateFunc;
4750
events[changeQty] = dataUpdateFunc;
51+
events[updateWishlist] = validateProductQty;
4852

4953
for (key in options.productType) {
5054
if (options.productType.hasOwnProperty(key) && options.productType[key] + 'Info' in options) {
@@ -220,6 +224,23 @@ define([
220224

221225
$(form).attr('action', action).submit();
222226
});
227+
},
228+
229+
/**
230+
* Validate product quantity before updating Wish List
231+
*
232+
* @param {jQuery.Event} event
233+
* @private
234+
*/
235+
_validateWishlistQty: function (event) {
236+
var element = $(this.options.qtyInfo);
237+
238+
if (!(element.validation() && element.validation('isValid'))) {
239+
event.preventDefault();
240+
event.stopPropagation();
241+
242+
return;
243+
}
223244
}
224245
});
225246

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
<preference for="Magento\Framework\EntityManager\MapperInterface" type="Magento\Framework\EntityManager\CompositeMapper"/>
168168
<preference for="Magento\Framework\Console\CommandListInterface" type="Magento\Framework\Console\CommandList"/>
169169
<preference for="Magento\Framework\DataObject\IdentityGeneratorInterface" type="Magento\Framework\DataObject\IdentityService" />
170+
<preference for="Magento\Framework\DataObject\IdentityValidatorInterface" type="Magento\Framework\DataObject\IdentityValidator" />
170171
<preference for="Magento\Framework\Serialize\SerializerInterface" type="Magento\Framework\Serialize\Serializer\Json" />
171172
<preference for="Magento\Framework\App\Scope\ValidatorInterface" type="Magento\Framework\App\Scope\Validator"/>
172173
<preference for="Magento\Framework\App\ScopeResolverInterface" type="Magento\Framework\App\ScopeResolver" />
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DataObject;
7+
8+
class IdentityValidatorTest extends \PHPUnit\Framework\TestCase
9+
{
10+
const VALID_UUID = 'fe563e12-cf9d-4faf-82cd-96e011b557b7';
11+
const INVALID_UUID = 'abcdef';
12+
13+
/**
14+
* @var IdentityValidator
15+
*/
16+
protected $identityValidator;
17+
18+
protected function setUp()
19+
{
20+
$this->identityValidator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
21+
->get(IdentityValidator::class);
22+
}
23+
24+
public function testIsValid()
25+
{
26+
$isValid = $this->identityValidator->isValid(self::VALID_UUID);
27+
$this->assertEquals(true, $isValid);
28+
}
29+
30+
public function testIsNotValid()
31+
{
32+
$isValid = $this->identityValidator->isValid(self::INVALID_UUID);
33+
$this->assertEquals(false, $isValid);
34+
}
35+
36+
public function testEmptyValue()
37+
{
38+
$isValid = $this->identityValidator->isValid('');
39+
$this->assertEquals(false, $isValid);
40+
}
41+
}

dev/tests/js/jasmine/tests/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.test.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@
66
define([
77
'jquery',
88
'Magento_Wishlist/js/add-to-wishlist'
9-
], function ($) {
9+
], function ($, Widget) {
1010
'use strict';
1111

1212
describe('Testing addToWishlist widget', function () {
13-
var wdContainer;
13+
var wdContainer,
14+
wishlistWidget,
15+
eventMock = {
16+
preventDefault: jasmine.createSpy(),
17+
stopPropagation: jasmine.createSpy()
18+
};
1419

1520
beforeEach(function () {
1621
wdContainer = $('<input type="hidden" class="bundle-option-11 product bundle option" \n' +
1722
'name="bundle_option[11]" value="15" aria-required="true"/>');
23+
wishlistWidget = new Widget();
24+
$.fn.validation = {};
1825
});
1926

2027
afterEach(function () {
@@ -31,5 +38,15 @@ define([
3138
});
3239
expect(wdContainer.addToWishlist('option', 'bundleInfo')).toBe('test');
3340
});
41+
42+
it('verify update wichlist with validate product qty, valid qty', function () {
43+
var validation = spyOn($.fn, 'validation').and.returnValue(false);
44+
45+
wishlistWidget._validateWishlistQty(eventMock);
46+
expect(validation).toHaveBeenCalled();
47+
expect(eventMock.preventDefault).toHaveBeenCalled();
48+
expect(eventMock.stopPropagation).toHaveBeenCalled();
49+
});
50+
3451
});
3552
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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\Framework\DataObject;
9+
10+
use Ramsey\Uuid\Uuid;
11+
12+
/**
13+
* Class IdentityValidator
14+
*
15+
* Class for validating Uuid's
16+
*/
17+
class IdentityValidator implements IdentityValidatorInterface
18+
{
19+
/**
20+
* @inheritDoc
21+
*/
22+
public function isValid(string $value): bool
23+
{
24+
$isValid = Uuid::isValid($value);
25+
return $isValid;
26+
}
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DataObject;
7+
8+
/**
9+
* Interface IdentityValidatorInterface
10+
*/
11+
interface IdentityValidatorInterface
12+
{
13+
/**
14+
* Checks if uuid is valid
15+
*
16+
* @param string $value
17+
*
18+
* @return bool
19+
*/
20+
public function isValid(string $value): bool;
21+
}

lib/internal/Magento/Framework/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"zendframework/zend-validator": "^2.6.0",
4040
"zendframework/zend-mail": "^2.9.0",
4141
"zendframework/zend-mime": "^2.5.0",
42-
"guzzlehttp/guzzle": "^6.3.3"
42+
"guzzlehttp/guzzle": "^6.3.3",
43+
"ramsey/uuid": "~3.8.0"
4344
},
4445
"archive": {
4546
"exclude": [

0 commit comments

Comments
 (0)