Skip to content

Commit 0235fbe

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-70996' into 2.3-develop-pr20
2 parents 68c4836 + 1f5e89b commit 0235fbe

File tree

12 files changed

+164
-36
lines changed

12 files changed

+164
-36
lines changed

app/code/Magento/Braintree/Test/Mftf/Test/BraintreeCreditCardOnCheckoutTest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@
8787
<waitForPageLoad stepKey="waitForPageLoad10"/>
8888
<click selector="{{BraintreeConfigurationPaymentSection.paymentMethod}}" stepKey="SelectBraintreePaymentMethod1"/>
8989
<waitForPageLoad stepKey="waitForPageLoad11"/>
90-
<click selector="{{CheckoutPaymentSection.shippingAndBillingAddressSame}}" stepKey="UncheckCheckBox"/>
91-
92-
<click selector="{{CheckoutShippingSection.updateAddress}}" stepKey="clickToUpdate"/>
93-
<waitForPageLoad stepKey="waitForPageLoad12"/>
9490
<!--Place order-->
9591
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="PlaceOrder1"/>
9692
<waitForPageLoad stepKey="waitForPageLoad13"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
<element name="addressBook" type="button" selector="//a[text()='Address Book']"/>
5555
<element name="noQuotes" type="text" selector=".no-quotes-block"/>
5656
<element name="paymentMethodByName" type="text" selector="//*[@id='checkout-payment-method-load']//*[contains(@class, 'payment-group')]//label[normalize-space(.)='{{var1}}']" parameterized="true"/>
57+
<element name="billingAddressSelectShared" type="select" selector=".checkout-billing-address select[name='billing_address_id']"/>
5758
</section>
5859
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<element name="billingAddress" type="text" selector=".checkout-billing-address"/>
1313
<element name="checkPaymentMethodByName" type="radio" selector="//div[@id='checkout-payment-method-load']//div[@class='payment-method']//label//span[contains(., '{{methodName}}')]/../..//input" parameterized="true"/>
1414
<element name="billingAddressSameAsShipping" type="checkbox" selector=".payment-method._active [name='billing-address-same-as-shipping']"/>
15+
<element name="billingAddressSameAsShippingShared" type="checkbox" selector="#billing-address-same-as-shipping-shared"/>
1516
</section>
1617
</sections>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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="DefaultBillingAddressShouldBeCheckedOnPaymentPageTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<stories value="Checkout via the Storefront"/>
15+
<title value="The default billing address should be used on checkout"/>
16+
<description value="Default billing address should be preselected on payments page on checkout if it exist"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MAGETWO-98892"/>
19+
<useCaseId value="MAGETWO-70996"/>
20+
<group value="checkout"/>
21+
</annotations>
22+
<before>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
28+
<!--Go to Storefront as Customer-->
29+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin">
30+
<argument name="Customer" value="$$createCustomer$$" />
31+
</actionGroup>
32+
</before>
33+
<after>
34+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
37+
<!--Logout from customer account-->
38+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
39+
</after>
40+
<!-- Add simple product to cart and go to checkout-->
41+
<actionGroup ref="AddSimpleProductToCart" stepKey="addProductToCart">
42+
<argument name="product" value="$$createProduct$$"/>
43+
</actionGroup>
44+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
45+
<!-- Click "+ New Address" and Fill new address-->
46+
<click selector="{{CheckoutShippingSection.newAddressButton}}" stepKey="addAddress"/>
47+
<actionGroup ref="LoggedInCheckoutWithOneAddressFieldWithoutStateField" stepKey="changeAddress">
48+
<argument name="Address" value="UK_Not_Default_Address"/>
49+
<argument name="classPrefix" value="._show"/>
50+
</actionGroup>
51+
<!--Click "Save Addresses" -->
52+
<click selector="{{CheckoutShippingSection.saveAddress}}" stepKey="saveAddress"/>
53+
<waitForPageLoad stepKey="waitForAddressSaved"/>
54+
<dontSeeElement selector="{{StorefrontCheckoutAddressPopupSection.newAddressModalPopup}}" stepKey="dontSeeModalPopup"/>
55+
<!--Select Shipping Rate "Flat Rate" and click "Next" button-->
56+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShipping"/>
57+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask2"/>
58+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
59+
<!--Verify that "My billing and shipping address are the same" is unchecked and billing address is preselected-->
60+
<dontSeeCheckboxIsChecked selector="{{CheckoutPaymentSection.billingAddressNotSameCheckbox}}" stepKey="shippingAndBillingAddressIsSameUnchecked"/>
61+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="assertBillingAddress"/>
62+
</test>
63+
</tests>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,20 @@
186186
<see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity2"/>
187187
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart2" />
188188

189-
<click stepKey="changeShippingAddress" selector="{{CheckoutShippingMethodsSection.shipHereButton}}"/>
190-
<waitForElementNotVisible stepKey="waitForShippingMethodLoaderNotVisible" selector="{{CheckoutShippingMethodsSection.shippingMethodLoader}}" time="30"/>
191-
<waitForElementVisible stepKey="waitForShippingMethodRadioToBeVisible" selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" time="30"/>
189+
<click selector="{{CheckoutShippingMethodsSection.shipHereButton}}" stepKey="changeShippingAddress"/>
190+
<waitForElementNotVisible selector="{{CheckoutShippingMethodsSection.shippingMethodLoader}}" time="30" stepKey="waitForShippingMethodLoaderNotVisible"/>
191+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" time="30" stepKey="waitForShippingMethodRadioToBeVisible"/>
192192
<waitForPageLoad stepKey="waitForPageLoad23"/>
193-
<click stepKey="selectFirstShippingMethod2" selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}"/>
194-
<waitForElement stepKey="waitForShippingMethodSelect2" selector="{{CheckoutShippingMethodsSection.next}}" time="30"/>
195-
<click stepKey="clickNextOnShippingMethodLoad2" selector="{{CheckoutShippingMethodsSection.next}}" />
193+
<click selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod2"/>
194+
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForShippingMethodSelect2"/>
195+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNextOnShippingMethodLoad2"/>
196196
<!-- Checkout select Check/Money Order payment -->
197197
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment2"/>
198-
<waitForElement stepKey="waitForPlaceOrderButton2" selector="{{CheckoutPaymentSection.placeOrder}}" time="30" />
199-
<see stepKey="seeBillingAddressIsCorrect2" selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{UK_Not_Default_Address.street[0]}}" />
200-
<click stepKey="clickPlaceOrderButton2" selector="{{CheckoutPaymentSection.placeOrder}}" />
198+
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton2"/>
199+
<see selector="{{CheckoutPaymentSection.billingAddress}}" userInput="{{US_Address_NY.street[0]}}" stepKey="seeBillingAddressIsCorrect2" />
200+
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrderButton2"/>
201201
<waitForPageLoad stepKey="waitForOrderSuccessPage2"/>
202-
<see stepKey="seeSuccessMessage2" selector="{{CheckoutSuccessMainSection.success}}" userInput="Your order number is:" />
202+
<see selector="{{CheckoutSuccessMainSection.success}}" userInput="Your order number is:" stepKey="seeSuccessMessage2"/>
203203
</test>
204204
<test name="StorefrontCustomerCheckoutTestWithRestrictedCountriesForPayment">
205205
<annotations>
@@ -216,16 +216,18 @@
216216
<createData entity="ApiSimpleProduct" stepKey="createProduct">
217217
<requiredEntity createDataKey="createCategory"/>
218218
</createData>
219-
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 1" />
220-
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry GB" />
219+
<magentoCLI command="config:set checkout/options/display_billing_address_on 1" stepKey="setShowBillingAddressOnPaymentPage" />
220+
<magentoCLI command="config:set payment/checkmo/allowspecific 1" stepKey="allowSpecificValue" />
221+
<magentoCLI command="config:set payment/checkmo/specificcountry GB" stepKey="specificCountryValue" />
221222
<createData entity="Simple_US_Customer" stepKey="simpleuscustomer"/>
222223
</before>
223224
<after>
224-
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
225225
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
226226
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
227-
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 0" />
228-
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry ''" />
227+
<magentoCLI command="config:set payment/checkmo/allowspecific 0" stepKey="allowSpecificValue" />
228+
<magentoCLI command="config:set payment/checkmo/specificcountry ''" stepKey="specificCountryValue" />
229+
<magentoCLI command="config:set checkout/options/display_billing_address_on 0" stepKey="setDisplayBillingAddressOnPaymentMethod" />
230+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
229231
</after>
230232
<!-- Login as Customer -->
231233
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin">
@@ -253,16 +255,18 @@
253255
<dontsee selector="{{CheckoutPaymentSection.paymentMethodByName('Check / Money order')}}" stepKey="paymentMethodDoesNotAvailable"/>
254256

255257
<!-- Fill UK Address and verify that payment available and checkout successful -->
256-
<click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" />
257-
<click selector="{{CheckoutShippingSection.newAddressButton}}" stepKey="fillNewAddress" />
258-
<actionGroup ref="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup" stepKey="customerCheckoutFillingShippingSectionUK">
259-
<argument name="customerVar" value="CustomerEntityOne" />
260-
<argument name="customerAddressVar" value="UK_Not_Default_Address" />
258+
<uncheckOption selector="{{StorefrontCheckoutPaymentMethodSection.billingAddressSameAsShippingShared}}" stepKey="uncheckBillingAddressSameAsShippingCheckCheckBox"/>
259+
<selectOption selector="{{CheckoutPaymentSection.billingAddressSelectShared}}" userInput="New Address" stepKey="clickOnNewAddress"/>
260+
<waitForPageLoad stepKey="waitNewAddressBillingForm"/>
261+
<actionGroup ref="LoggedInCheckoutFillNewBillingAddressActionGroup" stepKey="changeAddress">
262+
<argument name="Address" value="updateCustomerUKAddress"/>
263+
<argument name="classPrefix" value="[aria-hidden=false]"/>
261264
</actionGroup>
265+
<click selector="{{CheckoutPaymentSection.addressAction('Update')}}" stepKey="clickUpdateBillingAddressButton" />
262266
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="customerSelectCheckMoneyOrderPayment" />
263267
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="customerPlaceorder">
264268
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage" />
265269
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
266270
</actionGroup>
267271
</test>
268-
</tests>
272+
</tests>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerPlaceOrderWithNewAddressesThatWasEditedTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
7272

7373
<!--Refresh Page and Place Order-->
74+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/>
7475
<reloadPage stepKey="reloadPage"/>
7576
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="waitForPlaceOrderButton"/>
7677
<click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder"/>
@@ -89,7 +90,7 @@
8990
<amOnPage url="{{StorefrontCustomerOrderViewPage.url({$grabOrderNumber})}}" stepKey="goToOrderReviewPage"/>
9091
<see userInput="{{UK_Not_Default_Address.street[0]}} {{UK_Not_Default_Address.city}}, {{UK_Not_Default_Address.postcode}}"
9192
selector="{{StorefrontCustomerOrderViewSection.shippingAddress}}" stepKey="checkShippingAddress"/>
92-
<see userInput="{{UK_Not_Default_Address.street[0]}} {{UK_Not_Default_Address.city}}, {{UK_Not_Default_Address.postcode}}"
93+
<see userInput="{{US_Address_TX_Default_Billing.street[0]}}"
9394
selector="{{StorefrontCustomerOrderViewSection.billingAddress}}" stepKey="checkBillingAddress"/>
9495
</test>
9596
</tests>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ define([
243243
return;
244244
}
245245

246-
if (quote.isVirtual()) {
246+
if (quote.isVirtual() || !quote.billingAddress()) {
247247
isBillingAddressInitialized = addressList.some(function (addrs) {
248248
if (addrs.isDefaultBilling()) {
249249
selectBillingAddress(addrs);

dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
<data name="shippingAddressCustomer" xsi:type="array">
1616
<item name="added" xsi:type="number">1</item>
1717
</data>
18-
<data name="billingAddressCustomer" xsi:type="array">
19-
<item name="added" xsi:type="number">1</item>
20-
</data>
2118
<data name="prices" xsi:type="array">
2219
<item name="grandTotal" xsi:type="string">565.00</item>
2320
</data>
2421
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
22+
<data name="editBillingInformation" xsi:type="boolean">false</data>
2523
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
2624
<data name="payment/method" xsi:type="string">checkmo</data>
2725
<data name="configData" xsi:type="string">checkmo</data>
@@ -43,6 +41,7 @@
4341
<item name="grandTotal" xsi:type="string">565.00</item>
4442
</data>
4543
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
44+
<data name="editBillingInformation" xsi:type="boolean">false</data>
4645
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
4746
<data name="payment/method" xsi:type="string">checkmo</data>
4847
<data name="configData" xsi:type="string">checkmo</data>
@@ -61,7 +60,7 @@
6160
<data name="shippingAddress/dataset" xsi:type="string">UK_address_without_email</data>
6261
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
6362
<data name="shipping/shipping_method" xsi:type="string">Fixed</data>
64-
<data name="billingCheckboxState" xsi:type="string">Yes</data>
63+
<data name="editBillingInformation" xsi:type="boolean">false</data>
6564
<data name="billingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
6665
<data name="payment/method" xsi:type="string">checkmo</data>
6766
<data name="configData" xsi:type="string">checkmo</data>

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,15 @@ public function run()
126126
if ($this->billingCheckboxState) {
127127
$this->assertBillingAddressCheckbox->processAssert($this->checkoutOnepage, $this->billingCheckboxState);
128128
}
129-
if ($this->billingCheckboxState === 'Yes' && !$this->editBillingInformation) {
130-
return [
131-
'billingAddress' => $this->shippingAddress
132-
];
129+
130+
if (!$this->editBillingInformation) {
131+
$billingAddress = $this->billingCheckboxState === 'Yes'
132+
? $this->shippingAddress
133+
: $this->getDefaultBillingAddress();
134+
135+
return ['billingAddress' => $billingAddress];
133136
}
137+
134138
if ($this->billingAddress) {
135139
$selectedPaymentMethod = $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock();
136140
if ($this->shippingAddress) {
@@ -139,9 +143,11 @@ public function run()
139143
$selectedPaymentMethod->getBillingBlock()->fillBilling($this->billingAddress);
140144
$billingAddress = $this->billingAddress;
141145
}
146+
142147
if (isset($this->billingAddressCustomer['added'])) {
143148
$addressIndex = $this->billingAddressCustomer['added'];
144-
$billingAddress = $this->customer->getDataFieldConfig('address')['source']->getAddresses()[$addressIndex];
149+
$billingAddress = $this->customer->getDataFieldConfig('address')['source']
150+
->getAddresses()[$addressIndex];
145151
$address = $this->objectManager->create(
146152
\Magento\Customer\Test\Block\Address\Renderer::class,
147153
['address' => $billingAddress, 'type' => 'html_for_select_element']
@@ -156,4 +162,25 @@ public function run()
156162
'billingAddress' => $billingAddress
157163
];
158164
}
165+
166+
/**
167+
* Get default billing address
168+
*
169+
* @return Address|null
170+
*/
171+
private function getDefaultBillingAddress()
172+
{
173+
$addresses = $this->customer->hasData('address')
174+
? $this->customer->getDataFieldConfig('address')['source']->getAddresses()
175+
: [];
176+
$defaultAddress = null;
177+
foreach ($addresses as $address) {
178+
if ($address->getDefaultBilling() === 'Yes') {
179+
$defaultAddress = $address;
180+
break;
181+
}
182+
}
183+
184+
return $defaultAddress;
185+
}
159186
}

dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer/cc-form.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ define([
1515
describe('Magento_Braintree/js/view/payment/method-renderer/cc-form', function () {
1616
var injector = new Squire(),
1717
mocks = {
18+
'Magento_Checkout/js/model/checkout-data-resolver': {
19+
20+
/** Stub */
21+
applyBillingAddress: function () {
22+
return true;
23+
},
24+
25+
/** Stub */
26+
resolveBillingAddress: function () {
27+
return true;
28+
}
29+
},
1830
'Magento_Checkout/js/model/quote': {
1931
billingAddress: ko.observable(),
2032
shippingAddress: ko.observable(),

0 commit comments

Comments
 (0)