Skip to content

Commit 9b1d263

Browse files
committed
MC-13921: Reverted fixes branch stabilization
1 parent f8bfac1 commit 9b1d263

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

app/code/Magento/Wishlist/Test/Mftf/Test/ConfProdAddToCartWishListWithUnselectedAttrTest.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@
5959
<!--Click Add to Wish List link-->
6060
<click selector="{{StorefrontProductPageSection.addToWishlist}}" stepKey="addFirstPnroductToWishlist"/>
6161

62+
<waitForPageLoad stepKey="waitForLoading"/>
63+
64+
<!--Click "Add All to Cart" button-->
65+
<click selector="{{StorefrontCustomerWishlistProductSection.ProductAddAllToCart}}" stepKey="addAllToCart"/>
66+
<waitForElementVisible stepKey="waitForErrorAppears" selector="{{StorefrontMessagesSection.error}}"/>
67+
6268
<!--Assert Correct Error Message-->
63-
<see userInput="This is a required field" selector="{{StorefrontProductInfoMainSection.productAttributeOptionsError}}" stepKey="seeError"/>
69+
<see userInput="You need to choose options for your item for" stepKey="assertCorrectErrorMessage"/>
70+
<dontSee userInput="1 product(s) have been added to shopping cart" stepKey="dontSeeSuccessMessage"/>
6471
</test>
6572
</tests>

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

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ define([
2222
/** @inheritdoc */
2323
_create: function () {
2424
this._bind();
25-
this.bindFormSubmit(false);
2625
},
2726

2827
/**
@@ -64,6 +63,12 @@ define([
6463
isFileUploaded = false,
6564
self = this;
6665

66+
if (event.handleObj.selector == this.options.qtyInfo) { //eslint-disable-line eqeqeq
67+
this._updateAddToWishlistButton({});
68+
event.stopPropagation();
69+
70+
return;
71+
}
6772
$(event.handleObj.selector).each(function (index, element) {
6873
if ($(element).is('input[type=text]') ||
6974
$(element).is('input[type=email]') ||
@@ -84,7 +89,9 @@ define([
8489
}
8590
});
8691

87-
this.bindFormSubmit(isFileUploaded);
92+
if (isFileUploaded) {
93+
this.bindFormSubmit();
94+
}
8895
this._updateAddToWishlistButton(dataToAdd);
8996
event.stopPropagation();
9097
},
@@ -183,41 +190,33 @@ define([
183190
/**
184191
* Bind form submit.
185192
*/
186-
bindFormSubmit: function (isFileUploaded) {
193+
bindFormSubmit: function () {
187194
var self = this;
188195

189-
$('[data-action="add-to-wishlist"]').off('click').on('click', function (event) {
196+
$('[data-action="add-to-wishlist"]').on('click', function (event) {
190197
var element, params, form, action;
191198

192-
if (!$($(self.options.qtyInfo).closest('form')).valid()) {
193-
event.stopPropagation();
194-
event.preventDefault();
199+
event.stopPropagation();
200+
event.preventDefault();
195201

196-
return;
202+
element = $('input[type=file]' + self.options.customOptionsInfo);
203+
params = $(event.currentTarget).data('post');
204+
form = $(element).closest('form');
205+
action = params.action;
206+
207+
if (params.data.id) {
208+
$('<input>', {
209+
type: 'hidden',
210+
name: 'id',
211+
value: params.data.id
212+
}).appendTo(form);
197213
}
198214

199-
if (isFileUploaded) {
200-
element = $('input[type=file]' + self.options.customOptionsInfo);
201-
params = $(event.currentTarget).data('post');
202-
form = $(element).closest('form');
203-
action = params.action;
204-
205-
if (params.data.id) {
206-
$('<input>', {
207-
type: 'hidden',
208-
name: 'id',
209-
value: params.data.id
210-
}).appendTo(form);
211-
}
212-
213-
if (params.data.uenc) {
214-
action += 'uenc/' + params.data.uenc;
215-
}
216-
217-
$(form).attr('action', action).submit();
218-
event.stopPropagation();
219-
event.preventDefault();
215+
if (params.data.uenc) {
216+
action += 'uenc/' + params.data.uenc;
220217
}
218+
219+
$(form).attr('action', action).submit();
221220
});
222221
}
223222
});

0 commit comments

Comments
 (0)