Skip to content

Commit a2db060

Browse files
committed
Merge branch 'MAGETWO-60982' of github.com:magento-troll/magento2ce into Troll_PR
2 parents 07f4e70 + f5b8ba8 commit a2db060

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
/* global jQuery */
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'jquery',
9+
'squire',
10+
'mage/backend/notification'
11+
], function ($, Squire) {
12+
'use strict';
13+
14+
var injector = new Squire();
15+
16+
describe('mage/backend/bootstrap', function () {
17+
beforeEach(function (done) {
18+
injector.require(['mage/backend/bootstrap'], function () {
19+
done();
20+
});
21+
});
22+
describe('"sendPostponeRequest" method', function () {
23+
it('should insert "Error" notification if request failed', function () {
24+
jQuery('<div class="page-main-actions"></div>').appendTo('body');
25+
jQuery('body').notification();
26+
27+
jQuery.ajax().abort();
28+
29+
expect(jQuery('.message-error').length).toBe(1);
30+
expect(jQuery('body:contains("A technical problem with the server created an error")').length).toBe(1);
31+
});
32+
});
33+
});
34+
});

lib/web/mage/backend/bootstrap.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
define([
88
'jquery',
99
'mage/apply/main',
10+
'mage/backend/notification',
1011
'Magento_Ui/js/lib/knockout/bootstrap',
11-
'mage/mage'
12-
], function ($, mage) {
12+
'mage/mage',
13+
'mage/translate'
14+
], function ($, mage, notification) {
1315
'use strict';
1416

1517
var bootstrap;
@@ -67,6 +69,29 @@ define([
6769
}
6870
} catch (e) {}
6971
}
72+
},
73+
74+
/**
75+
* Error callback.
76+
*/
77+
error: function () {
78+
$('body').notification('clear')
79+
.notification('add', {
80+
error: true,
81+
message: $.mage.__(
82+
'A technical problem with the server created an error. ' +
83+
'Try again to continue what you were doing. If the problem persists, try again later.'
84+
),
85+
86+
/**
87+
* @param {String} message
88+
*/
89+
insertMethod: function (message) {
90+
var $wrapper = $('<div/>').html(message);
91+
92+
$('.page-main-actions').after($wrapper);
93+
}
94+
});
7095
}
7196
});
7297

@@ -83,7 +108,7 @@ define([
83108
/*
84109
* Initialization of notification widget
85110
*/
86-
$('body').mage('notification');
111+
notification({}, $('body'));
87112
};
88113

89114
$(bootstrap);

0 commit comments

Comments
 (0)