Skip to content

Commit 3f3599e

Browse files
committed
Merge remote-tracking branch 'upstream/2.4-develop' into AC-3224-fix-composer-lock-2-4-develop
2 parents df5e8f1 + a8543fe commit 3f3599e

File tree

6 files changed

+154
-14
lines changed

6 files changed

+154
-14
lines changed

app/code/Magento/AdminAdobeIms/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"registration.php"
3434
],
3535
"psr-4": {
36-
"Magento\\Backend\\": ""
36+
"Magento\\AdminAdobeIms\\": ""
3737
}
3838
}
3939
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontChangeNextPageShoppingCartActionGroup">
12+
<annotations>
13+
<description>Clicks next page after changing the item quantity.</description>
14+
</annotations>
15+
16+
<click selector="{{StorefrontCartToolbarSection.toolbarNextPage}}" stepKey="clickNextPage"/>
17+
<waitForElementVisible selector="{{CheckoutCartProductSection.modalMessage}}" stepKey="waitForModalMessage"/>
18+
<waitForText selector="{{CheckoutCartProductSection.modalMessage}}" userInput="Changes you made to the cart will not be saved." stepKey="waitForTextModalMessage"/>
19+
<waitForElementVisible selector="{{CheckoutCartProductSection.modalConfirmButton}}" stepKey="waitForModalConfirmButton"/>
20+
<click selector="{{CheckoutCartProductSection.modalConfirmButton}}" stepKey="clickModalConfirmButton"/>
21+
<waitForPageLoad stepKey="waitForPageLoad"/>
22+
<seeCurrentUrlEquals url="{{_ENV.MAGENTO_BASE_URL}}checkout/cart/index/?p=2" stepKey="seeCurrentUrlEqualsCartPage"/>
23+
24+
</actionGroup>
25+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCartToolbarSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<section name="StorefrontCartToolbarSection">
1212
<element name="toolbarNumber" type="text" selector="div.toolbar > .pager > .toolbar-amount > .toolbar-number" />
1313
<element name="toolbarPager" type="text" selector="div.toolbar > .pager > .pages" />
14-
<element name="toolbarNextPage" type="text" selector="div.toolbar > .pager > .pages > .pages-item-next" />
14+
<element name="toolbarNextPage" type="text" selector="div.toolbar > .pager > .pages > .pages-items > .pages-item-next" />
1515
<element name="toolbarPreviousPage" type="text" selector="div.toolbar > .pager > .pages > .pages-item-previous" />
1616
</section>
1717
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontShowConfirmPopupBeforeSwitchingPageIfItemQuantityChangedTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<stories value="Check if the confirm popup is visible when quantity of items changed and try to change the page on cart."/>
15+
<title value="Check if the confirm popup is visible when quantity of items changed and try to change the page on cart."/>
16+
<description value="Check if the confirm popup is visible when quantity of items changed and try to change the page on cart."/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="ACP2E-479"/>
19+
<group value="shoppingCart"/>
20+
<group value="checkout"/>
21+
</annotations>
22+
<before>
23+
<!--Set the default number of items on cart which is 20-->
24+
<magentoCLI stepKey="allowSpecificValue" command="config:set checkout/cart/number_items_to_display_pager 5" />
25+
26+
<createData entity="SimpleTwo" stepKey="simpleProduct1"/>
27+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="CartItem1">
28+
<argument name="product" value="$$simpleProduct1$$"/>
29+
</actionGroup>
30+
<createData entity="SimpleTwo" stepKey="simpleProduct2"/>
31+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="CartItem2">
32+
<argument name="product" value="$simpleProduct2$$"/>
33+
</actionGroup>
34+
<createData entity="SimpleTwo" stepKey="simpleProduct3"/>
35+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="CartItem3">
36+
<argument name="product" value="$simpleProduct3$$"/>
37+
</actionGroup>
38+
<createData entity="SimpleTwo" stepKey="simpleProduct4"/>
39+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="CartItem4">
40+
<argument name="product" value="$simpleProduct4$$"/>
41+
</actionGroup>
42+
<createData entity="SimpleTwo" stepKey="simpleProduct5"/>
43+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="CartItem5">
44+
<argument name="product" value="$simpleProduct5$$"/>
45+
</actionGroup>
46+
<createData entity="SimpleTwo" stepKey="simpleProduct6"/>
47+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="CartItem6">
48+
<argument name="product" value="$simpleProduct6$$"/>
49+
</actionGroup>
50+
</before>
51+
<after>
52+
<deleteData createDataKey="simpleProduct1" stepKey="deleteCartItem1"/>
53+
<deleteData createDataKey="simpleProduct2" stepKey="deleteCartItem2"/>
54+
<deleteData createDataKey="simpleProduct3" stepKey="deleteCartItem3"/>
55+
<deleteData createDataKey="simpleProduct4" stepKey="deleteCartItem4"/>
56+
<deleteData createDataKey="simpleProduct5" stepKey="deleteCartItem5"/>
57+
<deleteData createDataKey="simpleProduct6" stepKey="deleteCartItem6"/>
58+
</after>
59+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage" />
60+
<actionGroup ref="AssertToolbarTextIsVisibleInCartActionGroup" stepKey="VerifyPagerText">
61+
<argument name="text" value="Items 1 to 5 of 6 total"/>
62+
</actionGroup>
63+
<fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$simpleProduct1.name$$)}}" userInput="10" stepKey="changeCartQty"/>
64+
<actionGroup ref="StorefrontChangeNextPageShoppingCartActionGroup" stepKey="changeNextPage" />
65+
</test>
66+
</tests>

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,7 @@ Payment,Payment
186186
"Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart"
187187
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."
188188
"The shipping method is missing. Select the shipping method and try again.","The shipping method is missing. Select the shipping method and try again."
189+
Are you sure you want to leave the page?,Are you sure you want to leave the page?
190+
Changes you made to the cart will not be saved.,Changes you made to the cart will not be saved.
191+
Leave,Leave
192+
Cancel,Cancel

app/code/Magento/Checkout/view/frontend/web/js/action/update-shopping-cart.js

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,69 @@
55

66
define([
77
'Magento_Ui/js/modal/alert',
8+
'Magento_Ui/js/modal/confirm',
89
'jquery',
10+
'mage/translate',
911
'jquery-ui-modules/widget',
1012
'mage/validation'
11-
], function (alert, $) {
13+
], function (alert, confirm, $, $t) {
1214
'use strict';
1315

1416
$.widget('mage.updateShoppingCart', {
1517
options: {
1618
validationURL: '',
1719
eventName: 'updateCartItemQty',
18-
updateCartActionContainer: ''
20+
updateCartActionContainer: '',
21+
isCartHasUpdatedContent: false
1922
},
2023

2124
/** @inheritdoc */
2225
_create: function () {
2326
this._on(this.element, {
2427
'submit': this.onSubmit
2528
});
29+
this._on('[data-role=cart-item-qty]', {
30+
'change': function () {
31+
this.isCartHasUpdatedContent = true;
32+
}
33+
});
34+
this._on('ul.pages-items', {
35+
'click a': function (event) {
36+
if (this.isCartHasUpdatedContent) {
37+
event.preventDefault();
38+
this.changePageConfirm($(event.currentTarget).attr('href'));
39+
}
40+
}
41+
});
42+
},
43+
44+
/**
45+
* Show the confirmation popup
46+
* @param nextPageUrl
47+
*/
48+
changePageConfirm: function (nextPageUrl) {
49+
confirm({
50+
title: $t('Are you sure you want to leave the page?'),
51+
content: $t('Changes you made to the cart will not be saved.'),
52+
actions: {
53+
confirm: function () {
54+
window.location.href = nextPageUrl;
55+
}
56+
},
57+
buttons: [{
58+
text: $t('Cancel'),
59+
class: 'action-secondary action-dismiss',
60+
click: function (event) {
61+
this.closeModal(event);
62+
}
63+
}, {
64+
text: $t('Leave'),
65+
class: 'action-primary action-accept',
66+
click: function (event) {
67+
this.closeModal(event, true);
68+
}
69+
}]
70+
});
2671
},
2772

2873
/**
@@ -83,16 +128,16 @@ define([
83128
$(document.body).trigger('processStop');
84129
}
85130
})
86-
.done(function (response) {
87-
if (response.success) {
88-
this.onSuccess();
89-
} else {
90-
this.onError(response);
91-
}
92-
})
93-
.fail(function () {
94-
this.submitForm();
95-
});
131+
.done(function (response) {
132+
if (response.success) {
133+
this.onSuccess();
134+
} else {
135+
this.onError(response);
136+
}
137+
})
138+
.fail(function () {
139+
this.submitForm();
140+
});
96141
},
97142

98143
/**

0 commit comments

Comments
 (0)