Skip to content

Commit c7dd8ca

Browse files
committed
ACP2E-1143: trigger tax / subtotal estimates refresh on shipping address updates; jasmine unit test update
1 parent 97af970 commit c7dd8ca

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ define([
3535
// check if user data not changed -> load rates from cache
3636
if (!cartCache.isChanged('address', quote.shippingAddress()) &&
3737
!cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
38-
cartCache.get('rates')
38+
cartCache.get('rates') && cartCache.get('totals')
3939
) {
4040
shippingService.setShippingRates(cartCache.get('rates'));
41-
quote.setTotals(cartCache.get('cart-data').totals);
41+
quote.setTotals(cartCache.get('totals'));
4242
return;
4343
}
4444

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/estimate-service.test.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ define([
2424
tax: 0.1,
2525
totals: 10
2626
},
27-
cartData = {
28-
totals: totals,
29-
rates: null
30-
},
3127
mocks = {
3228
'Magento_Checkout/js/model/quote': {
3329
shippingAddress: ko.observable(),
@@ -50,7 +46,7 @@ define([
5046
},
5147
'Magento_Checkout/js/model/cart/cache': {
5248
isChanged: function () {},
53-
get: jasmine.createSpy().and.returnValues(rates, cartData),
49+
get: jasmine.createSpy().and.returnValues(rates, totals, rates, totals),
5450
set: jasmine.createSpy()
5551
},
5652
'Magento_Customer/js/customer-data': {
@@ -105,13 +101,12 @@ define([
105101
return 'address_type_test';
106102
}
107103
});
108-
expect(mocks['Magento_Checkout/js/model/cart/cache'].get('cart-data')).toBe(cartData);
109104
expect(mocks['Magento_Checkout/js/model/shipping-service'].setShippingRates).toHaveBeenCalledWith(rates);
110-
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(cartData.totals);
105+
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(totals);
111106
expect(mocks['Magento_Checkout/js/model/cart/totals-processor/default'].estimateTotals)
112-
.not.toHaveBeenCalled();
107+
.toHaveBeenCalled();
113108
expect(mocks['Magento_Checkout/js/model/shipping-rate-processor/new-address'].getRates)
114-
.not.toHaveBeenCalled();
109+
.toHaveBeenCalled();
115110
});
116111

117112
it('test subscribe when shipping address was changed for virtual quote', function () {
@@ -125,7 +120,7 @@ define([
125120
expect(mocks['Magento_Checkout/js/model/cart/totals-processor/default'].estimateTotals)
126121
.toHaveBeenCalled();
127122
expect(mocks['Magento_Checkout/js/model/shipping-rate-processor/new-address'].getRates)
128-
.not.toHaveBeenCalled();
123+
.toHaveBeenCalled();
129124
});
130125

131126
it('test subscribe when shipping address was changed for not virtual quote', function () {

0 commit comments

Comments
 (0)