Skip to content

Commit cfb1d29

Browse files
committed
Merge remote-tracking branch 'origin/MC-21926' into 2.3-develop-pr36
2 parents 054d284 + 5042312 commit cfb1d29

13 files changed

+319
-14
lines changed

app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ private function limitShippingCarrier(Quote $quote) : void
193193
$shippingAddress = $quote->getShippingAddress();
194194
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
195195
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
196-
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
196+
if ($shippingRate) {
197+
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
198+
}
197199
}
198200
}
199201
}

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ public function savePaymentInformation(
124124
$shippingAddress = $quote->getShippingAddress();
125125
if ($shippingAddress && $shippingAddress->getShippingMethod()) {
126126
$shippingRate = $shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod());
127-
$shippingAddress->setLimitCarrier(
128-
$shippingRate ? $shippingRate->getCarrier() : $shippingAddress->getShippingMethod()
129-
);
127+
if ($shippingRate) {
128+
$shippingAddress->setLimitCarrier($shippingRate->getCarrier());
129+
}
130130
}
131131
}
132132
$this->paymentMethodManagement->set($cartId, $paymentMethod);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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="AssertStorefrontNotCalculatedValueInShippingTotalInOrderSummaryActionGroup">
12+
<annotations>
13+
<description>Validates value of the Shipping total is not calculated.</description>
14+
</annotations>
15+
16+
<arguments>
17+
<argument name="value" defaultValue="Not yet calculated" type="string"/>
18+
</arguments>
19+
<waitForElementVisible selector="{{CheckoutOrderSummarySection.shippingTotalNotYetCalculated}}" time="30" stepKey="waitForShippingTotalToBeVisible"/>
20+
<see selector="{{CheckoutOrderSummarySection.shippingTotalNotYetCalculated}}" userInput="{{value}}" stepKey="assertShippingTotalIsNotYetCalculated"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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="AssertStorefrontOrderCannotBePlacedActionGroup">
12+
<annotations>
13+
<description>Validates order cannot be placed and checks error message.</description>
14+
</annotations>
15+
16+
<arguments>
17+
<argument name="error" type="string"/>
18+
</arguments>
19+
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton"/>
20+
<click selector="{{CheckoutPaymentSection.placeOrderWithoutTimeout}}" stepKey="clickPlaceOrder"/>
21+
<waitForElement selector="{{CheckoutCartMessageSection.errorMessage}}" time="30" stepKey="waitForErrorMessage"/>
22+
<see selector="{{CheckoutCartMessageSection.errorMessage}}" userInput="{{error}}" stepKey="assertErrorMessage"/>
23+
</actionGroup>
24+
</actionGroups>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
<element name="miniCartTabClosed" type="button" selector=".title[aria-expanded='false']" timeout="30"/>
2121
<element name="itemsQtyInCart" type="text" selector=".items-in-cart > .title > strong > span"/>
2222
<element name="orderSummaryShippingTotalLabelDescription" type="text" selector=".shipping.totals .label.description"/>
23+
<element name="shippingTotalNotYetCalculated" type="text" selector=".shipping.totals .not-calculated"/>
2324
</section>
2425
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<element name="cartItemsAreaActive" type="textarea" selector="div.block.items-in-cart.active" timeout="30"/>
3232
<element name="checkMoneyOrderPayment" type="radio" selector="input#checkmo.radio" timeout="30"/>
3333
<element name="placeOrder" type="button" selector=".payment-method._active button.action.primary.checkout" timeout="30"/>
34+
<element name="placeOrderWithoutTimeout" type="button" selector=".payment-method._active button.action.primary.checkout"/>
3435
<element name="paymentSectionTitle" type="text" selector="//*[@id='checkout-payment-method-load']//div[@data-role='title']" />
3536
<element name="orderSummarySubtotal" type="text" selector="//tr[@class='totals sub']//span[@class='price']" />
3637
<element name="orderSummaryShippingTotal" type="text" selector="//tr[@class='totals shipping excl']//span[@class='price']" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontNotApplicableShippingMethodInReviewAndPaymentStepTest">
11+
<annotations>
12+
<title value="Not applicable Shipping Method In Review and Payment Step"/>
13+
<stories value="Checkout Shipping Method Recalculation after Coupon Code Added"/>
14+
<description value="User should not be able to place order when free shipping declined after applying coupon code"/>
15+
<features value="Checkout"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-22625"/>
18+
<useCaseId value="MC-21926"/>
19+
<group value="Checkout"/>
20+
</annotations>
21+
22+
<before>
23+
<!-- Enable Free Shipping Method and set Minimum Order Amount to 100-->
24+
<magentoCLI command="config:set {{AdminFreeshippingActiveConfigData.path}} {{AdminFreeshippingActiveConfigData.enabled}}" stepKey="enableFreeShippingMethod" />
25+
<magentoCLI command="config:set {{AdminFreeshippingMinimumOrderAmountConfigData.path}} {{AdminFreeshippingMinimumOrderAmountConfigData.hundred}}" stepKey="setFreeShippingMethodMinimumOrderAmountToBe100" />
26+
27+
<!--Set Fedex configs data-->
28+
<magentoCLI command="config:set {{AdminFedexEnableForCheckoutConfigData.path}} {{AdminFedexEnableForCheckoutConfigData.value}}" stepKey="enableCheckout"/>
29+
<magentoCLI command="config:set {{AdminFedexEnableSandboxModeConfigData.path}} {{AdminFedexEnableSandboxModeConfigData.value}}" stepKey="enableSandbox"/>
30+
<magentoCLI command="config:set {{AdminFedexEnableDebugConfigData.path}} {{AdminFedexEnableDebugConfigData.value}}" stepKey="enableDebug"/>
31+
<magentoCLI command="config:set {{AdminFedexEnableShowMethodConfigData.path}} {{AdminFedexEnableShowMethodConfigData.value}}" stepKey="enableShowMethod"/>
32+
33+
<!--Set StoreInformation configs data-->
34+
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} '{{AdminGeneralSetStoreNameConfigData.value}}'" stepKey="setStoreInformationName"/>
35+
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.telephone}}" stepKey="setStoreInformationPhone"/>
36+
<magentoCLI command="config:set {{AdminGeneralSetCountryConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.country_id}}" stepKey="setStoreInformationCountry"/>
37+
<magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.city}}" stepKey="setStoreInformationCity"/>
38+
<magentoCLI command="config:set {{AdminGeneralSetPostcodeConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.postcode}}" stepKey="setStoreInformationPostcode"/>
39+
<magentoCLI command="config:set {{AdminGeneralSetStreetAddressConfigData.path}} '{{DE_Address_Berlin_Not_Default_Address.street[0]}}'" stepKey="setStoreInformationStreetAddress"/>
40+
<magentoCLI command="config:set {{AdminGeneralSetStreetAddress2ConfigData.path}} '{{US_Address_California.street[0]}}'" stepKey="setStoreInformationStreetAddress2"/>
41+
<magentoCLI command="config:set {{AdminGeneralSetVatNumberConfigData.path}} {{AdminGeneralSetVatNumberConfigData.value}}" stepKey="setStoreInformationVatNumber"/>
42+
43+
<!--Set Shipping settings origin data-->
44+
<magentoCLI command="config:set {{AdminShippingSettingsOriginCountryConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.country_id}}" stepKey="setOriginCountry"/>
45+
<magentoCLI command="config:set {{AdminShippingSettingsOriginCityConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.city}}" stepKey="setOriginCity"/>
46+
<magentoCLI command="config:set {{AdminShippingSettingsOriginZipCodeConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.postcode}}" stepKey="setOriginZipCode"/>
47+
<magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddressConfigData.path}} '{{DE_Address_Berlin_Not_Default_Address.street[0]}}'" stepKey="setOriginStreetAddress"/>
48+
<magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddress2ConfigData.path}} '{{US_Address_California.street[0]}}'" stepKey="setOriginStreetAddress2"/>
49+
50+
<!-- Create Simple Product -->
51+
<createData entity="defaultSimpleProduct" stepKey="createSimpleProduct">
52+
<field key="price">100</field>
53+
</createData>
54+
<!-- Create Cart Price Rule with 10% discount -->
55+
<createData entity="ApiSalesRule" stepKey="createCartPriceRule"/>
56+
<!-- Create Coupon code for the Cart Price Rule -->
57+
<createData entity="ApiSalesRuleCoupon" stepKey="createCartPriceRuleCoupon">
58+
<requiredEntity createDataKey="createCartPriceRule"/>
59+
</createData>
60+
<!-- Create Customer with filled Shipping & Billing Address -->
61+
<createData entity="CustomerEntityOne" stepKey="createCustomer"/>
62+
63+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
64+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
65+
</before>
66+
67+
<after>
68+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutFromStorefront"/>
69+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
70+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
71+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
72+
<magentoCLI command="config:set {{AdminFreeshippingMinimumOrderAmountConfigData.path}} {{AdminFreeshippingMinimumOrderAmountConfigData.default}}" stepKey="setFreeShippingMethodMinimumOrderAmountAsDefault" />
73+
<magentoCLI command="config:set {{AdminFreeshippingActiveConfigData.path}} {{AdminFreeshippingActiveConfigData.disabled}}" stepKey="disableFreeShippingMethod" />
74+
<!--Reset configs-->
75+
<magentoCLI command="config:set {{AdminFedexDisableForCheckoutConfigData.path}} {{AdminFedexDisableForCheckoutConfigData.value}}" stepKey="disableCheckout"/>
76+
<magentoCLI command="config:set {{AdminFedexDisableSandboxModeConfigData.path}} {{AdminFedexDisableSandboxModeConfigData.value}}" stepKey="disableSandbox"/>
77+
<magentoCLI command="config:set {{AdminFedexDisableDebugConfigData.path}} {{AdminFedexDisableDebugConfigData.value}}" stepKey="disableDebug"/>
78+
<magentoCLI command="config:set {{AdminFedexDisableShowMethodConfigData.path}} {{AdminFedexDisableShowMethodConfigData.value}}" stepKey="disableShowMethod"/>
79+
<magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} ''" stepKey="setStoreInformationName"/>
80+
<magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} ''" stepKey="setStoreInformationPhone"/>
81+
<magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} ''" stepKey="setStoreInformationCity"/>
82+
<magentoCLI command="config:set {{AdminGeneralSetPostcodeConfigData.path}} ''" stepKey="setStoreInformationPostcode"/>
83+
<magentoCLI command="config:set {{AdminGeneralSetStreetAddressConfigData.path}} ''" stepKey="setStoreInformationStreetAddress"/>
84+
<magentoCLI command="config:set {{AdminGeneralSetStreetAddress2ConfigData.path}} ''" stepKey="setStoreInformationStreetAddress2"/>
85+
<magentoCLI command="config:set {{AdminGeneralSetVatNumberConfigData.path}} ''" stepKey="setStoreInformationVatNumber"/>
86+
<magentoCLI command="config:set {{AdminShippingSettingsOriginCityConfigData.path}} ''" stepKey="setOriginCity"/>
87+
<magentoCLI command="config:set {{AdminShippingSettingsOriginZipCodeConfigData.path}} ''" stepKey="setOriginZipCode"/>
88+
<magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddressConfigData.path}} ''" stepKey="setOriginStreetAddress"/>
89+
<magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddress2ConfigData.path}} ''" stepKey="setOriginStreetAddress2"/>
90+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
91+
<magentoCLI command="cache:flush" stepKey="flushCache"/>
92+
</after>
93+
94+
<!-- Guest Customer Test Scenario -->
95+
<!-- Add Simple Product to Cart -->
96+
<actionGroup ref="StorefrontAddSimpleProductToShoppingCartActionGroup" stepKey="addProductToCart">
97+
<argument name="product" value="$$createSimpleProduct$$"/>
98+
</actionGroup>
99+
100+
<!-- Go to Checkout -->
101+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckout"/>
102+
103+
<!-- Fill all required fields -->
104+
<actionGroup ref="GuestCheckoutFillNewShippingAddressActionGroup" stepKey="fillNewShippingAddress">
105+
<argument name="customer" value="Simple_Customer_Without_Address" />
106+
<argument name="address" value="US_Address_TX"/>
107+
</actionGroup>
108+
109+
<!-- Select Free Shipping -->
110+
<actionGroup ref="StorefrontSetShippingMethodActionGroup" stepKey="setShippingMethodFreeShipping">
111+
<argument name="shippingMethodName" value="Free Shipping"/>
112+
</actionGroup>
113+
114+
<!-- Go to Order review -->
115+
<actionGroup ref="StorefrontCheckoutForwardFromShippingStep" stepKey="goToCheckoutReview"/>
116+
117+
<!-- Checkout select Check/Money Order payment -->
118+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/>
119+
<!-- Select payment solution -->
120+
<checkOption selector="{{CheckoutPaymentSection.billingAddressNotSameCheckbox}}" stepKey="selectPaymentSolution" />
121+
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton"/>
122+
123+
<!-- Apply Discount Coupon to the Order -->
124+
<actionGroup ref="StorefrontApplyDiscountCodeActionGroup" stepKey="applyDiscountCoupon">
125+
<argument name="discountCode" value="$createCartPriceRuleCoupon.code$"/>
126+
</actionGroup>
127+
128+
<!-- Assert Shipping total is not yet calculated -->
129+
<actionGroup ref="AssertStorefrontNotCalculatedValueInShippingTotalInOrderSummaryActionGroup" stepKey="assertNotYetCalculated"/>
130+
131+
<!-- Assert order cannot be placed and error message will shown. -->
132+
<actionGroup ref="AssertStorefrontOrderCannotBePlacedActionGroup" stepKey="assertOrderCannotBePlaced">
133+
<argument name="error" value="The shipping method is missing. Select the shipping method and try again."/>
134+
</actionGroup>
135+
136+
<!-- Go to checkout page -->
137+
<actionGroup ref="OpenStoreFrontCheckoutShippingPageActionGroup" stepKey="openCheckoutShippingPage"/>
138+
139+
<!-- Chose flat rate -->
140+
<actionGroup ref="StorefrontSetShippingMethodActionGroup" stepKey="setShippingMethodFlatRate">
141+
<argument name="shippingMethodName" value="Flat Rate"/>
142+
</actionGroup>
143+
144+
<!-- Go to Order review -->
145+
<actionGroup ref="StorefrontCheckoutForwardFromShippingStep" stepKey="goToCheckoutReview2"/>
146+
147+
<!-- Place order assert succeed -->
148+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="checkoutPlaceOrder"/>
149+
150+
<!-- Loged in Customer Test Scenario -->
151+
<!-- Login with created Customer -->
152+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
153+
<argument name="Customer" value="$$createCustomer$$"/>
154+
</actionGroup>
155+
156+
<!-- Add Simple Product to Cart -->
157+
<actionGroup ref="StorefrontAddSimpleProductToShoppingCartActionGroup" stepKey="addProductToCart2">
158+
<argument name="product" value="$$createSimpleProduct$$"/>
159+
</actionGroup>
160+
161+
<!-- Go to Checkout -->
162+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckout2"/>
163+
164+
<!-- Select Free Shipping -->
165+
<actionGroup ref="StorefrontSetShippingMethodActionGroup" stepKey="setShippingMethodFreeShipping2">
166+
<argument name="shippingMethodName" value="Free Shipping"/>
167+
</actionGroup>
168+
169+
<!-- Go to Order review -->
170+
<actionGroup ref="StorefrontCheckoutForwardFromShippingStep" stepKey="goToCheckoutReview3"/>
171+
172+
<!-- Checkout select Check/Money Order payment -->
173+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment2"/>
174+
175+
<!-- Select payment solution -->
176+
<checkOption selector="{{CheckoutPaymentSection.billingAddressNotSameCheckbox}}" stepKey="selectPaymentSolution2" />
177+
<waitForElement selector="{{CheckoutPaymentSection.placeOrder}}" time="30" stepKey="waitForPlaceOrderButton2"/>
178+
179+
<!-- Apply Discount Coupon to the Order -->
180+
<actionGroup ref="StorefrontApplyDiscountCodeActionGroup" stepKey="applyDiscountCoupon2">
181+
<argument name="discountCode" value="$createCartPriceRuleCoupon.code$"/>
182+
</actionGroup>
183+
184+
<!-- Assert Shipping total is not yet calculated -->
185+
<actionGroup ref="AssertStorefrontNotCalculatedValueInShippingTotalInOrderSummaryActionGroup" stepKey="assertNotYetCalculated2"/>
186+
187+
<!-- Assert order cannot be placed and error message will shown. -->
188+
<actionGroup ref="AssertStorefrontOrderCannotBePlacedActionGroup" stepKey="assertOrderCannotBePlaced2">
189+
<argument name="error" value="The shipping method is missing. Select the shipping method and try again."/>
190+
</actionGroup>
191+
192+
<!-- Go to checkout page -->
193+
<actionGroup ref="OpenStoreFrontCheckoutShippingPageActionGroup" stepKey="openCheckoutShippingPage2"/>
194+
195+
<!-- Chose flat rate -->
196+
<actionGroup ref="StorefrontSetShippingMethodActionGroup" stepKey="setShippingMethodFlatRate2">
197+
<argument name="shippingMethodName" value="Flat Rate"/>
198+
</actionGroup>
199+
200+
<!-- Go to Order review -->
201+
<actionGroup ref="StorefrontCheckoutForwardFromShippingStep" stepKey="goToCheckoutReview4"/>
202+
203+
<!-- Place order assert succeed -->
204+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="checkoutPlaceOrder2"/>
205+
</test>
206+
</tests>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/**
7+
* @api
8+
*/
9+
define([
10+
'Magento_Checkout/js/model/quote',
11+
'Magento_Checkout/js/action/select-shipping-address',
12+
'Magento_Checkout/js/model/shipping-rate-registry'
13+
], function (quote, selectShippingAddress, rateRegistry) {
14+
'use strict';
15+
16+
return function () {
17+
var shippingAddress = null;
18+
19+
if (!quote.isVirtual()) {
20+
shippingAddress = quote.shippingAddress();
21+
22+
rateRegistry.set(shippingAddress.getCacheKey(), null);
23+
selectShippingAddress(shippingAddress);
24+
}
25+
};
26+
});

0 commit comments

Comments
 (0)