@@ -41,18 +41,20 @@ define([
41
41
dash . templating . list . push ( {
42
42
name : 'apps' ,
43
43
current : {
44
- text : 'se1, se2' ,
45
- value : [ 'se1' , 'se2' ]
44
+ text : 'se1, se2, se3 ' ,
45
+ value : [ 'se1' , 'se2' , 'se3' ]
46
46
} ,
47
47
options : [
48
48
{ text : 'se1' , value : 'se1' , selected : true } ,
49
49
{ text : 'se2' , value : 'se2' , selected : true } ,
50
+ { text : 'se3' , value : 'se3' , selected : true } ,
51
+ { text : 'se4' , value : 'se4' , selected : false }
50
52
]
51
53
} ) ;
52
54
} ) ;
53
55
54
56
it ( 'should repeat panel one time' , function ( ) {
55
- expect ( ctx . rows [ 0 ] . panels . length ) . to . be ( 2 ) ;
57
+ expect ( ctx . rows [ 0 ] . panels . length ) . to . be ( 3 ) ;
56
58
} ) ;
57
59
58
60
it ( 'should mark panel repeated' , function ( ) {
@@ -63,6 +65,7 @@ define([
63
65
it ( 'should set scopedVars on panels' , function ( ) {
64
66
expect ( ctx . rows [ 0 ] . panels [ 0 ] . scopedVars . apps . value ) . to . be ( 'se1' ) ;
65
67
expect ( ctx . rows [ 0 ] . panels [ 1 ] . scopedVars . apps . value ) . to . be ( 'se2' ) ;
68
+ expect ( ctx . rows [ 0 ] . panels [ 2 ] . scopedVars . apps . value ) . to . be ( 'se3' ) ;
66
69
} ) ;
67
70
68
71
describe ( 'After a second iteration' , function ( ) {
@@ -83,19 +86,35 @@ define([
83
86
} ) ;
84
87
85
88
it ( 'should have same panel count' , function ( ) {
86
- expect ( ctx . rows [ 0 ] . panels . length ) . to . be ( 2 ) ;
89
+ expect ( ctx . rows [ 0 ] . panels . length ) . to . be ( 3 ) ;
87
90
} ) ;
88
91
} ) ;
89
92
90
93
describe ( 'After a second iteration and selected values reduced' , function ( ) {
91
94
beforeEach ( function ( ) {
92
95
ctx . dash . templating . list [ 0 ] . options [ 1 ] . selected = false ;
96
+
97
+ ctx . dynamicDashboardSrv . update ( ctx . dash ) ;
98
+ } ) ;
99
+
100
+ it ( 'should clean up repeated panel' , function ( ) {
101
+ expect ( ctx . rows [ 0 ] . panels . length ) . to . be ( 2 ) ;
102
+ } ) ;
103
+ } ) ;
104
+
105
+ describe ( 'After a second iteration and panel repeat is turned off' , function ( ) {
106
+ beforeEach ( function ( ) {
107
+ ctx . rows [ 0 ] . panels [ 0 ] . repeat = null ;
93
108
ctx . dynamicDashboardSrv . update ( ctx . dash ) ;
94
109
} ) ;
95
110
96
111
it ( 'should clean up repeated panel' , function ( ) {
97
112
expect ( ctx . rows [ 0 ] . panels . length ) . to . be ( 1 ) ;
98
113
} ) ;
114
+
115
+ it ( 'should remove scoped vars from reused panel' , function ( ) {
116
+ expect ( ctx . rows [ 0 ] . panels [ 0 ] . scopedVars ) . to . be . empty ( ) ;
117
+ } ) ;
99
118
} ) ;
100
119
101
120
} ) ;
0 commit comments