File tree Expand file tree Collapse file tree 2 files changed +62
-3
lines changed
dev/tests/js/jasmine/tests/lib/mage/backend Expand file tree Collapse file tree 2 files changed +62
-3
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change 7
7
define ( [
8
8
'jquery' ,
9
9
'mage/apply/main' ,
10
+ 'mage/backend/notification' ,
10
11
'Magento_Ui/js/lib/knockout/bootstrap' ,
11
- 'mage/mage'
12
- ] , function ( $ , mage ) {
12
+ 'mage/mage' ,
13
+ 'mage/translate'
14
+ ] , function ( $ , mage , notification ) {
13
15
'use strict' ;
14
16
15
17
var bootstrap ;
@@ -67,6 +69,29 @@ define([
67
69
}
68
70
} catch ( e ) { }
69
71
}
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
+ } ) ;
70
95
}
71
96
} ) ;
72
97
@@ -83,7 +108,7 @@ define([
83
108
/*
84
109
* Initialization of notification widget
85
110
*/
86
- $ ( 'body' ) . mage ( 'notification' ) ;
111
+ notification ( { } , $ ( 'body' ) ) ;
87
112
} ;
88
113
89
114
$ ( bootstrap ) ;
You can’t perform that action at this time.
0 commit comments