Skip to content

Commit 64ed6e1

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-96850' into EPAM-PR-30
2 parents d03e3ff + 773aa0e commit 64ed6e1

File tree

3 files changed

+119
-12
lines changed

3 files changed

+119
-12
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
<element name="nthBundleOptionName" type="text" selector=".product-item-details .item-options:nth-of-type({{numOption}}) dt" parameterized="true"/>
3232
<element name="productSubtotalByName" type="input" selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'subtotal')]//span[@class='price']" parameterized="true"/>
3333
<element name="updateShoppingCartButton" type="button" selector="#form-validate button[type='submit'].update" timeout="30"/>
34+
<element name="qty" type="input" selector="//input[@data-cart-item-id='{{var}}'][@title='Qty']" parameterized="true"/>
3435
</section>
3536
</sections>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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="StorefrontOnePageCheckoutDataWhenChangeQtyTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<title value="One page Checkout Customer data when changing Product Qty"/>
15+
<description value="One page Checkout Customer data when changing Product Qty"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-96960"/>
18+
<useCaseId value="MAGETWO-96850"/>
19+
<group value="checkout"/>
20+
</annotations>
21+
<before>
22+
<!--Create a product-->
23+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
24+
</before>
25+
<after>
26+
<!--Delete created data-->
27+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
28+
</after>
29+
30+
<!--Add product to cart and checkout-->
31+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="amOnSimpleProductPage"/>
32+
<waitForPageLoad stepKey="waitForPageLoad"/>
33+
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage">
34+
<argument name="productName" value="$createProduct.name$$"/>
35+
</actionGroup>
36+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
37+
<fillField selector="{{CheckoutShippingSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/>
38+
<fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{CustomerEntityOne.firstname}}" stepKey="enterFirstName"/>
39+
<fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{CustomerEntityOne.lastname}}" stepKey="enterLastName"/>
40+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="enterStreet"/>
41+
<fillField selector="{{CheckoutShippingSection.city}}" userInput="{{CustomerAddressSimple.city}}" stepKey="enterCity"/>
42+
<selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{CustomerAddressSimple.state}}" stepKey="selectRegion"/>
43+
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{CustomerAddressSimple.postcode}}" stepKey="enterPostcode"/>
44+
<fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{CustomerAddressSimple.telephone}}" stepKey="enterTelephone"/>
45+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
46+
47+
<!--Grab customer data to check it-->
48+
<grabValueFrom selector="{{CheckoutShippingSection.email}}" stepKey="grabEmail"/>
49+
<grabValueFrom selector="{{CheckoutShippingSection.firstName}}" stepKey="grabFirstName"/>
50+
<grabValueFrom selector="{{CheckoutShippingSection.lastName}}" stepKey="grabLastName"/>
51+
<grabValueFrom selector="{{CheckoutShippingSection.street}}" stepKey="grabStreet"/>
52+
<grabValueFrom selector="{{CheckoutShippingSection.city}}" stepKey="grabCity"/>
53+
<grabTextFrom selector="{{CheckoutShippingSection.region}}" stepKey="grabRegion"/>
54+
<grabValueFrom selector="{{CheckoutShippingSection.postcode}}" stepKey="grabPostcode"/>
55+
<grabValueFrom selector="{{CheckoutShippingSection.telephone}}" stepKey="grabTelephone"/>
56+
57+
<!--Select shipping method and finalize checkout-->
58+
<click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
59+
<waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
60+
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
61+
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
62+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
63+
64+
<!--Go to cart page, update qty and proceed to checkout-->
65+
<amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/>
66+
<waitForPageLoad stepKey="waitForCartPageLoad"/>
67+
<see userInput="Shopping Cart" stepKey="seeCartPageIsOpened"/>
68+
<fillField selector="{{CheckoutCartProductSection.qty($$createProduct.name$$)}}" userInput="2" stepKey="updateProductQty"/>
69+
<click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="clickUpdateShoppingCart"/>
70+
<waitForAjaxLoad stepKey="waitForAjaxLoad"/>
71+
<grabValueFrom selector="{{CheckoutCartProductSection.qty($$createProduct.name$$)}}" stepKey="grabQty"/>
72+
<assertEquals expected="2" actual="$grabQty" stepKey="assertQty"/>
73+
<click selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="clickProceedToCheckout"/>
74+
75+
<!--Check that form is filled with customer data-->
76+
<grabValueFrom selector="{{CheckoutShippingSection.email}}" stepKey="grabEmail1"/>
77+
<grabValueFrom selector="{{CheckoutShippingSection.firstName}}" stepKey="grabFirstName1"/>
78+
<grabValueFrom selector="{{CheckoutShippingSection.lastName}}" stepKey="grabLastName1"/>
79+
<grabValueFrom selector="{{CheckoutShippingSection.street}}" stepKey="grabStreet1"/>
80+
<grabValueFrom selector="{{CheckoutShippingSection.city}}" stepKey="grabCity1"/>
81+
<grabTextFrom selector="{{CheckoutShippingSection.region}}" stepKey="grabRegion1"/>
82+
<grabValueFrom selector="{{CheckoutShippingSection.postcode}}" stepKey="grabPostcode1"/>
83+
<grabValueFrom selector="{{CheckoutShippingSection.telephone}}" stepKey="grabTelephone1"/>
84+
85+
<assertEquals expected="$grabEmail" actual="$grabEmail1" stepKey="assertEmail"/>
86+
<assertEquals expected="$grabFirstName" actual="$grabFirstName1" stepKey="assertFirstName"/>
87+
<assertEquals expected="$grabLastName" actual="$grabLastName1" stepKey="assertLastName"/>
88+
<assertEquals expected="$grabStreet" actual="$grabStreet1" stepKey="assertStreet"/>
89+
<assertEquals expected="$grabCity" actual="$grabCity1" stepKey="assertCity"/>
90+
<assertEquals expected="$grabRegion" actual="$grabRegion1" stepKey="assertRegion"/>
91+
<assertEquals expected="$grabPostcode" actual="$grabPostcode1" stepKey="assertPostcode"/>
92+
<assertEquals expected="$grabTelephone" actual="$grabTelephone1" stepKey="assertTelephone"/>
93+
</test>
94+
</tests>

app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
*/
1111
define([
1212
'jquery',
13-
'Magento_Customer/js/customer-data'
13+
'Magento_Customer/js/customer-data',
14+
'jquery/jquery-storageapi'
1415
], function ($, storage) {
1516
'use strict';
1617

@@ -23,24 +24,35 @@ define([
2324
storage.set(cacheKey, data);
2425
},
2526

27+
/**
28+
* @return {*}
29+
*/
30+
initData = function () {
31+
return {
32+
'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage
33+
'shippingAddressFromData': null, //Shipping address pulled from persistence storage
34+
'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for customer
35+
'selectedShippingRate': null, //Shipping rate pulled from persistence storage
36+
'selectedPaymentMethod': null, //Payment method pulled from persistence storage
37+
'selectedBillingAddress': null, //Selected billing address pulled from persistence storage
38+
'billingAddressFromData': null, //Billing address pulled from persistence storage
39+
'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer
40+
};
41+
},
42+
2643
/**
2744
* @return {*}
2845
*/
2946
getData = function () {
3047
var data = storage.get(cacheKey)();
3148

3249
if ($.isEmptyObject(data)) {
33-
data = {
34-
'selectedShippingAddress': null, //Selected shipping address pulled from persistence storage
35-
'shippingAddressFromData': null, //Shipping address pulled from persistence storage
36-
'newCustomerShippingAddress': null, //Shipping address pulled from persistence storage for customer
37-
'selectedShippingRate': null, //Shipping rate pulled from persistence storage
38-
'selectedPaymentMethod': null, //Payment method pulled from persistence storage
39-
'selectedBillingAddress': null, //Selected billing address pulled from persistence storage
40-
'billingAddressFromData': null, //Billing address pulled from persistence storage
41-
'newCustomerBillingAddress': null //Billing address pulled from persistence storage for new customer
42-
};
43-
saveData(data);
50+
data = $.initNamespaceStorage('mage-cache-storage').localStorage.get(cacheKey);
51+
52+
if ($.isEmptyObject(data)) {
53+
data = initData();
54+
saveData(data);
55+
}
4456
}
4557

4658
return data;

0 commit comments

Comments
 (0)