Skip to content

Commit 840df25

Browse files
Merge remote-tracking branch 'origin/MAGETWO-60589' into MPI-PR-2704
2 parents 19186f1 + e2ef171 commit 840df25

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/redirect-on-success.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
*/
99
define(
1010
[
11-
'mage/url'
11+
'mage/url',
12+
'Magento_Checkout/js/model/full-screen-loader'
1213
],
13-
function (url) {
14+
function (url, fullScreenLoader) {
1415
'use strict';
1516

1617
return {
@@ -20,6 +21,7 @@ define(
2021
* Provide redirect to page
2122
*/
2223
execute: function () {
24+
fullScreenLoader.startLoader();
2325
window.location.replace(url.build(this.redirectUrl));
2426
}
2527
};

app/code/Magento/Payment/view/frontend/web/transparent.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ define([
99
'mage/template',
1010
'Magento_Ui/js/modal/alert',
1111
'jquery/ui',
12-
'Magento_Payment/js/model/credit-card-validation/validator'
13-
], function ($, mageTemplate, alert) {
12+
'Magento_Payment/js/model/credit-card-validation/validator',
13+
'Magento_Checkout/js/model/full-screen-loader'
14+
], function ($, mageTemplate, alert, ui, validator, fullScreenLoader) {
1415
'use strict';
1516

1617
$.widget('mage.transparent', {
@@ -107,8 +108,8 @@ define([
107108
* {Function}
108109
*/
109110
beforeSend: function () {
110-
this.element.trigger('showAjaxLoader');
111-
}.bind(this),
111+
fullScreenLoader.startLoader();
112+
},
112113

113114
/**
114115
* {Function}
@@ -131,6 +132,8 @@ define([
131132
);
132133
this._postPaymentToGateway(preparedData);
133134
} else {
135+
fullScreenLoader.stopLoader(true);
136+
134137
msg = response['error_messages'];
135138

136139
if (this.options.context) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'squire'
9+
], function (Squire) {
10+
'use strict';
11+
12+
describe('Magento_Checkout/js/action/redirect-on-success', function () {
13+
var injector = new Squire(),
14+
RedirectOnSuccess,
15+
FullScreenLoader;
16+
17+
beforeEach(function (done) {
18+
window.checkoutConfig = {
19+
defaultSuccessPageUrl: 'checkout/success'
20+
};
21+
injector.require(['Magento_Checkout/js/action/redirect-on-success',
22+
'Magento_Checkout/js/model/full-screen-loader'], function (action, loader) {
23+
RedirectOnSuccess = action;
24+
FullScreenLoader = loader;
25+
spyOn(FullScreenLoader, 'startLoader');
26+
done();
27+
});
28+
});
29+
30+
it('Checks if loader is called before redirect to success page.', function () {
31+
spyOn(window.location, 'replace').and.returnValue(false);
32+
33+
RedirectOnSuccess.execute();
34+
35+
expect(FullScreenLoader.startLoader).toHaveBeenCalled();
36+
});
37+
});
38+
});

0 commit comments

Comments
 (0)