Skip to content

Commit 44d8a93

Browse files
authored
Merge pull request #7588 from magento-atwix-pyrrans/delivery-bunch-w17
[Pyrrans] Delivery bunch 2022`W17
2 parents 5b009cd + 406ba22 commit 44d8a93

File tree

19 files changed

+84
-44
lines changed

19 files changed

+84
-44
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ define(
2222
*/
2323
execute: function () {
2424
fullScreenLoader.startLoader();
25+
this.reloadPage();
26+
},
27+
28+
/**
29+
* Method to reload page
30+
*/
31+
reloadPage: function () {
2532
window.location.replace(url.build(this.redirectUrl));
2633
}
2734
};

app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
messageContainer = messageContainer || globalMessageList;
2525

2626
if (response.status == 401) { //eslint-disable-line eqeqeq
27-
window.location.replace(url.build('customer/account/login/'));
27+
this.reloadPage(url.build('customer/account/login/'));
2828
} else {
2929
try {
3030
error = JSON.parse(response.responseText);
@@ -35,6 +35,13 @@ define([
3535
}
3636
messageContainer.addErrorMessage(error);
3737
}
38+
},
39+
40+
/**
41+
* Method to reload page
42+
*/
43+
reloadPage: function (redirectUrl) {
44+
window.location.replace(redirectUrl);
3845
}
3946
};
4047
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
(function() {
7+
var env = jasmine.getEnv(),
8+
config = {random: false};
9+
10+
env.configure(config);
11+
})();

dev/tests/js/jasmine/spec_runner/tasks/jasmine.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ function init(config) {
6767
/**
6868
* @todo rename "helpers" to "specs" (implies overriding grunt-contrib-jasmine code)
6969
*/
70-
helpers: specs
70+
helpers: specs,
71+
sandboxArgs: {
72+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
73+
defaultViewport: {width: 400, height: 400, hasTouch: true},
74+
slowMo: 10000
75+
}
7176
}
7277
};
7378
});

dev/tests/js/jasmine/spec_runner/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</script>
2121
<% }); %>
2222
<% with (scripts) { %>
23-
<% [].concat(polyfills, jasmine, boot, vendor, src, reporters).forEach(function (script) { %>
23+
<% [].concat(polyfills, jasmine, '.grunt/grunt-contrib-jasmine/boot0.js', 'dev/tests/js/jasmine/spec_runner/jasmine-config.js', '.grunt/grunt-contrib-jasmine/boot1.js', vendor, src, reporters).forEach(function (script) { %>
2424
<script type="text/javascript" src="<%= script %>"></script>
2525
<% }); %>
2626
<% } %>

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/redirect-on-success.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ define([
3535
});
3636

3737
it('Checks if loader is called before redirect to success page.', function () {
38-
spyOn(window.location, 'replace').and.returnValue(false);
39-
38+
spyOn(RedirectOnSuccess, 'reloadPage').and.callFake(function () {});
4039
RedirectOnSuccess.execute();
4140

4241
expect(FullScreenLoader.startLoader).toHaveBeenCalled();

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/error-processor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ define([
6262
it('check on failed status', function () {
6363
var messageContainer = jasmine.createSpyObj('globalMessageList', ['addErrorMessage']);
6464

65-
spyOn(window.location, 'replace').and.callFake(function () {});
65+
spyOn(model, 'reloadPage').and.callFake(function () {});
6666
model.process({
6767
status: 401,
6868
responseText: ''

dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/new-customer-address.test.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ define([
2525
});
2626

2727
it('Check on empty object.', function () {
28-
var expected = {
29-
countryId: 'US',
30-
regionCode: null,
31-
region: null
32-
};
28+
var result = newCustomerAddress({}),
29+
expected = {
30+
countryId: 'US',
31+
regionCode: null,
32+
region: null
33+
};
3334

34-
expect(JSON.stringify(newCustomerAddress({}))).toEqual(JSON.stringify(expected));
35+
result.postcode = undefined;
36+
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
3537
});
3638

3739
it('Check on function call with empty address data.', function () {
@@ -57,6 +59,7 @@ define([
5759
regionId: 1
5860
};
5961

62+
result.postcode = undefined;
6063
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
6164
});
6265
it('Check on regionId with countryId in address data.', function () {
@@ -69,6 +72,7 @@ define([
6972
region: null
7073
};
7174

75+
result.postcode = undefined;
7276
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
7377
});
7478
it('Check that extensionAttributes property exists if defined', function () {
@@ -86,6 +90,7 @@ define([
8690
}
8791
};
8892

93+
result.postcode = undefined;
8994
expect(JSON.stringify(result)).toEqual(JSON.stringify(expected));
9095
});
9196
});

dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/qty-configurable.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@ define(['squire'], function (Squire) {
4242
it('Product is not configurable by default', function () {
4343
var component = new Component(params);
4444

45-
expect(component.disabled()).toBeFalsy();
45+
expect(component.disabled()).toBeFalse();
4646
expect(component.value()).toEqual(1000);
4747
});
4848

4949
it('State of component does not changed', function () {
5050
var component = new Component(params);
5151

52-
expect(component.disabled()).toBeFalsy();
52+
expect(component.disabled()).toBeFalse();
5353

5454
component.value(99);
5555
component.handleQtyValue(false);
5656

57-
expect(component.disabled()).toBeFalsy();
57+
expect(component.disabled()).toBeFalse();
5858
expect(component.value()).toEqual(99);
5959
});
6060

6161
it('Product changed to configurable', function () {
6262
var component = new Component(params);
6363

64-
expect(component.disabled()).toBeFalsy();
64+
expect(component.disabled()).toBeFalse();
6565
expect(component.value()).toEqual(1000);
6666

6767
component.handleQtyValue(true);
@@ -100,7 +100,7 @@ define(['squire'], function (Squire) {
100100
component.value(100);
101101
component.handleQtyValue(false);
102102

103-
expect(component.disabled()).toBeFalsy();
103+
expect(component.disabled()).toBeFalse();
104104
expect(component.value()).toEqual(100);
105105
});
106106
});

dev/tests/js/jasmine/tests/app/code/Magento/Customer/adminhtml/js/view/form/components/insert-listing.test.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
2323
};
2424

2525
beforeEach(function () {
26-
obj = new Constr({
27-
name: 'content_name',
28-
selections: function () {
29-
return selectionsProvider;
30-
}
31-
});
26+
obj = new Constr({ name: 'content_name' });
3227
});
3328

3429
describe('Check delete massaction process', function () {
@@ -45,6 +40,10 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
4540

4641
it('Check ids are retrieved from selections provider if they are NOT in data', function () {
4742
obj._delete = jasmine.createSpy();
43+
obj.selections = jasmine.createSpy().and.callFake(function () {
44+
return selectionsProvider;
45+
});
46+
4847
obj.onMassAction({
4948
action: 'delete',
5049
data: {}
@@ -60,6 +59,10 @@ define(['Magento_Customer/js/form/components/insert-listing'], function (Constr)
6059
get: jasmine.createSpy().and.returnValues(2, 3),
6160
set: jasmine.createSpy()
6261
};
62+
obj.selections = jasmine.createSpy().and.callFake(function () {
63+
return selectionsProvider;
64+
});
65+
6366
obj.onMassAction(data);
6467

6568
expect(selectionsProvider.selected).not.toHaveBeenCalled();

dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/customer-data.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ define([
201201
});
202202

203203
it('Check it requests sections from the server if there are expired sections', function () {
204+
clearLocalStorage();
204205
setupLocalStorage({
205206
'customer': {
206207
'data_id': Math.floor(Date.now() / 1000) + 60 // invalidated,
@@ -279,6 +280,7 @@ define([
279280
});
280281

281282
it('Check that result contains invalidated section names', function () {
283+
clearLocalStorage();
282284
setupLocalStorage({
283285
'cart': { // without storage content
284286
'data_id': Math.floor(Date.now() / 1000) + 60 // in 1 minute

dev/tests/js/jasmine/tests/app/code/Magento/MediaGalleryUi/adminhtml/js/grid/messages.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ define([
6868
var escapedMessage = 'escaped message';
6969

7070
// eslint-disable-next-line max-nested-callbacks
71-
spyOn(escaperInstance, 'escapeHtml').and.callFake(function () {
71+
escaperInstance.escapeHtml = jasmine.createSpy().and.callFake(function () {
7272
return escapedMessage;
7373
});
7474

dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/grid/tree-massactions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ define([
105105
result = obj.defaultCallback(action, data);
106106

107107
expect(typeof result).toBe('object');
108-
spyOn(utils, 'submit').and.callThrough();
108+
utils.submit = jasmine.createSpy().and.callThrough();
109109
utils.submit({
110110
url: action.url,
111111
data: data.selected

dev/tests/js/jasmine/tests/app/code/Magento/Theme/view/frontend/web/js/cookie-status.test.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,18 @@ define([
2222
$(document.body).append(htmlContainer);
2323
});
2424

25-
afterEach(function () {
26-
window.navigator = navigator;
27-
});
28-
2925
it('defines cookieStatus widget', function () {
3026
expect($.fn.cookieStatus).toBeDefined();
3127
});
3228

3329
it('does not show a modal when cookies are supported', function () {
34-
window.navigator = {
35-
cookieEnabled: true
36-
};
30+
Object.defineProperty(navigator,'cookieEnabled',{value: true, configurable: true});
3731
widget._init();
3832
expect($(document.body).html()).not.toContain('<aside role="dialog" class="modal-popup');
3933
});
4034

4135
it('shows the modal when cookies are not supported', function () {
42-
window.navigator = {
43-
cookieEnabled: false
44-
};
36+
Object.defineProperty(navigator,'cookieEnabled',{value: false, configurable: true});
4537
widget._init();
4638
expect($(document.body).html()).toContain('<aside role="dialog" class="modal-popup');
4739
});

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/client.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ define([
102102
});
103103
it('Check call "beforeSave" method without parameters', function () {
104104
$.ajax = jasmine.createSpy();
105+
utils.submit = jasmine.createSpy();
105106
obj.urls.beforeSave = null;
106107
obj.save();
107108

@@ -113,6 +114,7 @@ define([
113114
$.ajax = jasmine.createSpy().and.callFake(function (req) {
114115
request = req.success;
115116
});
117+
utils.submit = jasmine.createSpy();
116118
jQueryMethods.notification = $.fn.notification;
117119
$.fn.notification = jasmine.createSpy();
118120
obj.urls.beforeSave = 'requestPath';

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ define([
4242
id: 3
4343
});
4444

45-
expect(multiSelect.allSelected()).toBeFalsy();
45+
expect(multiSelect.allSelected()).toBeFalse();
4646
expect(multiSelect.excluded().toString()).toEqual('');
4747
expect(multiSelect.selected().toString()).toEqual('');
4848
});
@@ -51,7 +51,7 @@ define([
5151
multiSelect.selected.push(4);
5252
multiSelect.selected.push(5);
5353

54-
expect(multiSelect.allSelected()).toBeFalsy();
54+
expect(multiSelect.allSelected()).toBeUndefined();
5555
expect(multiSelect.excluded().toString()).toEqual('');
5656
expect(multiSelect.selected().toString()).toEqual('4,5');
5757
});
@@ -70,7 +70,7 @@ define([
7070
}]);
7171
multiSelect.selectPage();
7272

73-
expect(multiSelect.allSelected()).toBeFalsy();
73+
expect(multiSelect.allSelected()).toBeUndefined();
7474
expect(multiSelect.excluded().toString()).toEqual('');
7575
expect(multiSelect.selected().toString()).toEqual('1,2,3,4');
7676
});
@@ -93,7 +93,7 @@ define([
9393
id: 6
9494
}]);
9595
multiSelect.selected.push(6);
96-
expect(multiSelect.allSelected()).toBeFalsy();
96+
expect(multiSelect.allSelected()).toBeUndefined();
9797
expect(multiSelect.excluded().toString()).toEqual('5');
9898
expect(multiSelect.selected().toString()).toEqual('3,4,6');
9999
});
@@ -112,7 +112,7 @@ define([
112112
multiSelect.selectPage();
113113
multiSelect.selected.remove(4); // remove second
114114

115-
expect(multiSelect.allSelected()).toBeFalsy();
115+
expect(multiSelect.allSelected()).toBeUndefined();
116116
expect(multiSelect.excluded().toString()).toEqual('4');
117117
expect(multiSelect.selected().toString()).toEqual('3');
118118
});
@@ -130,7 +130,7 @@ define([
130130
id: 4
131131
}]);
132132

133-
expect(multiSelect.allSelected()).toBeFalsy();
133+
expect(multiSelect.allSelected()).toBeUndefined();
134134
expect(multiSelect.excluded().toString()).toEqual('');
135135
expect(multiSelect.selected().toString()).toEqual('3,4,1,2');
136136
});
@@ -168,7 +168,7 @@ define([
168168
id: 6
169169
}]);
170170

171-
expect(multiSelect.allSelected()).toBeFalsy();
171+
expect(multiSelect.allSelected()).toBeUndefined();
172172
expect(multiSelect.excluded().toString()).toEqual('3,4');
173173
expect(multiSelect.selected().toString()).toEqual('5,6');
174174
});

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/masonry.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ define([
4949
Component = new Masonry({
5050
defaults: {
5151
containerId: '#masonry_grid'
52-
}
52+
},
53+
container: {}
5354
});
5455
});
5556

@@ -62,6 +63,7 @@ define([
6263
it('verify setLayoutstyles called and grid iniztilized', function () {
6364
var setlayoutStyles = spyOn(Component, 'setLayoutStyles');
6465

66+
Object.defineProperty(Component.container, 'clientWidth', {value: '', configurable: true});
6567
expect(Component).toBeDefined();
6668
Component.containerId = 'masonry_grid';
6769
Component.initComponent(rows);
@@ -75,6 +77,8 @@ define([
7577
var setLayoutStyles = spyOn(Component, 'setLayoutStyles');
7678

7779
Component.initComponent(rows);
80+
Component.container = {};
81+
Object.defineProperty(Component.container, 'clientWidth', {value: '', configurable: true});
7882
window.dispatchEvent(new Event('resize'));
7983
expect(setLayoutStyles).toHaveBeenCalled();
8084
});

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/sticky/sticky.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
/* eslint-disable max-nested-callbacks */
67
define([
78
'underscore',
89
'Magento_Ui/js/grid/sticky/sticky'
@@ -46,6 +47,7 @@ define([
4647
expect(stickyObj.initListeners).toHaveBeenCalled();
4748
});
4849
it('has initOnScroll method', function () {
50+
spyOn(document, 'addEventListener').and.callFake(function () {});
4951
stickyObj.initOnScroll();
5052
expect(stickyObj.lastHorizontalScrollPos).toBeDefined();
5153
});

0 commit comments

Comments
 (0)