@@ -5,9 +5,9 @@ function addComponent(object_id, _input, to_table) {
5
5
var _name = _input . value ;
6
6
7
7
if ( _name . length > 0 ) {
8
- jsonRPC ( 'TestCase.add_component' , [ object_id , _name ] , function ( data ) {
8
+ jsonRPC ( 'TestCase.add_component' , [ object_id , _name ] , function ( data ) {
9
9
if ( data !== undefined ) {
10
- to_table . row . add ( { name : data . name , id : data . id } ) . draw ( ) ;
10
+ to_table . row . add ( { name : data . name , id : data . id } ) . draw ( ) ;
11
11
$ ( _input ) . val ( '' ) ;
12
12
} else {
13
13
$ ( _input ) . parents ( 'div.input-group' ) . addClass ( 'has-error' ) ;
@@ -21,7 +21,7 @@ function addTestPlanToTestCase(case_id, plans_table) {
21
21
const plan_name = $ ( '#input-add-plan' ) [ 0 ] . value ;
22
22
const plan = plan_cache [ plan_name ] ;
23
23
24
- jsonRPC ( 'TestPlan.add_case' , [ plan . id , case_id ] , function ( data ) {
24
+ jsonRPC ( 'TestPlan.add_case' , [ plan . id , case_id ] , function ( data ) {
25
25
plans_table . row . add ( {
26
26
id : plan . id ,
27
27
name : plan . name ,
@@ -36,12 +36,12 @@ function addTestPlanToTestCase(case_id, plans_table) {
36
36
37
37
function initAddPlan ( case_id , plans_table ) {
38
38
// + button
39
- $ ( '#btn-add-plan' ) . click ( function ( ) {
39
+ $ ( '#btn-add-plan' ) . click ( function ( ) {
40
40
addTestPlanToTestCase ( case_id , plans_table ) ;
41
41
} ) ;
42
42
43
43
// Enter key
44
- $ ( '#input-add-plan' ) . keyup ( function ( event ) {
44
+ $ ( '#input-add-plan' ) . keyup ( function ( event ) {
45
45
if ( event . keyCode === 13 ) {
46
46
addTestPlanToTestCase ( case_id , plans_table ) ;
47
47
} ;
@@ -51,43 +51,43 @@ function initAddPlan(case_id, plans_table) {
51
51
$ ( '#input-add-plan.typeahead' ) . typeahead ( {
52
52
minLength : 1 ,
53
53
highlight : true
54
- } , {
54
+ } , {
55
55
name : 'plans-autocomplete' ,
56
56
// will display up to X results even if more were returned
57
57
limit : 100 ,
58
58
async : true ,
59
- display : function ( element ) {
59
+ display : function ( element ) {
60
60
const display_name = 'TP-' + element . id + ': ' + element . name ;
61
61
plan_cache [ display_name ] = element ;
62
62
return display_name ;
63
63
} ,
64
- source : function ( query , processSync , processAsync ) {
64
+ source : function ( query , processSync , processAsync ) {
65
65
// accepts "TP-1234" or "tp-1234" or "1234"
66
66
query = query . toLowerCase ( ) . replace ( 'tp-' , '' ) ;
67
67
if ( query === '' ) {
68
68
return ;
69
69
}
70
70
71
- var rpc_query = { pk : query } ;
71
+ var rpc_query = { pk : query } ;
72
72
73
73
// or arbitrary string
74
74
if ( isNaN ( query ) ) {
75
- if ( query . length >= 3 ) {
76
- rpc_query = { name__icontains : query } ;
75
+ if ( query . length >= 3 ) {
76
+ rpc_query = { name__icontains : query } ;
77
77
} else {
78
78
return ;
79
79
}
80
80
}
81
81
82
- jsonRPC ( 'TestPlan.filter' , rpc_query , function ( data ) {
82
+ jsonRPC ( 'TestPlan.filter' , rpc_query , function ( data ) {
83
83
return processAsync ( data ) ;
84
84
} ) ;
85
85
}
86
86
} ) ;
87
87
}
88
88
89
89
90
- $ ( document ) . ready ( function ( ) {
90
+ $ ( document ) . ready ( function ( ) {
91
91
var case_id = $ ( '#test_case_pk' ) . data ( 'pk' ) ;
92
92
var product_id = $ ( '#product_pk' ) . data ( 'pk' ) ;
93
93
var perm_remove_tag = $ ( '#test_case_pk' ) . data ( 'perm-remove-tag' ) === 'True' ;
@@ -96,12 +96,12 @@ $(document).ready(function() {
96
96
var perm_remove_bug = $ ( '#test_case_pk' ) . data ( 'perm-remove-bug' ) === 'True' ;
97
97
98
98
// bind everything in tags table
99
- tagsCard ( 'TestCase' , case_id , { case : case_id } , perm_remove_tag ) ;
99
+ tagsCard ( 'TestCase' , case_id , { case : case_id } , perm_remove_tag ) ;
100
100
101
101
// components table
102
102
var components_table = $ ( '#components' ) . DataTable ( {
103
- ajax : function ( data , callback , settings ) {
104
- dataTableJsonRPC ( 'Component.filter' , [ { 'cases' : case_id } ] , callback ) ;
103
+ ajax : function ( data , callback , settings ) {
104
+ dataTableJsonRPC ( 'Component.filter' , [ { 'cases' : case_id } ] , callback ) ;
105
105
} ,
106
106
columns : [
107
107
{ data : "name" } ,
@@ -110,7 +110,7 @@ $(document).ready(function() {
110
110
sortable : false ,
111
111
render : function ( data , type , full , meta ) {
112
112
if ( perm_remove_component ) {
113
- return '<a href="#components" class="remove-component" data-pk="' + data + '"><span class="pficon-error-circle-o"></span></a>' ;
113
+ return '<a href="#components" class="remove-component" data-pk="' + data + '"><span class="pficon-error-circle-o"></span></a>' ;
114
114
}
115
115
return '' ;
116
116
}
@@ -122,26 +122,26 @@ $(document).ready(function() {
122
122
processing : '<div class="spinner spinner-lg"></div>' ,
123
123
zeroRecords : "No records found"
124
124
} ,
125
- order : [ [ 0 , 'asc' ] ] ,
125
+ order : [ [ 0 , 'asc' ] ] ,
126
126
} ) ;
127
127
128
128
// remove component button
129
- components_table . on ( 'draw' , function ( ) {
130
- $ ( '.remove-component' ) . click ( function ( ) {
129
+ components_table . on ( 'draw' , function ( ) {
130
+ $ ( '.remove-component' ) . click ( function ( ) {
131
131
var tr = $ ( this ) . parents ( 'tr' ) ;
132
132
133
- jsonRPC ( 'TestCase.remove_component' , [ case_id , $ ( this ) . data ( 'pk' ) ] , function ( data ) {
133
+ jsonRPC ( 'TestCase.remove_component' , [ case_id , $ ( this ) . data ( 'pk' ) ] , function ( data ) {
134
134
components_table . row ( $ ( tr ) ) . remove ( ) . draw ( ) ;
135
135
} ) ;
136
136
} ) ;
137
137
} ) ;
138
138
139
139
// add component button and Enter key
140
- $ ( '#add-component' ) . click ( function ( ) {
140
+ $ ( '#add-component' ) . click ( function ( ) {
141
141
addComponent ( case_id , $ ( '#id_components' ) [ 0 ] , components_table ) ;
142
142
} ) ;
143
143
144
- $ ( '#id_components' ) . keyup ( function ( event ) {
144
+ $ ( '#id_components' ) . keyup ( function ( event ) {
145
145
if ( event . keyCode === 13 ) {
146
146
addComponent ( case_id , $ ( '#id_components' ) [ 0 ] , components_table ) ;
147
147
} ;
@@ -151,16 +151,16 @@ $(document).ready(function() {
151
151
$ ( '#id_components.typeahead' ) . typeahead ( {
152
152
minLength : 3 ,
153
153
highlight : true
154
- } , {
154
+ } , {
155
155
name : 'components-autocomplete' ,
156
156
// will display up to X results even if more were returned
157
157
limit : 100 ,
158
158
async : true ,
159
- display : function ( element ) {
159
+ display : function ( element ) {
160
160
return element . name ;
161
161
} ,
162
- source : function ( query , processSync , processAsync ) {
163
- jsonRPC ( 'Component.filter' , { name__icontains : query , product : product_id } , function ( data ) {
162
+ source : function ( query , processSync , processAsync ) {
163
+ jsonRPC ( 'Component.filter' , { name__icontains : query , product : product_id } , function ( data ) {
164
164
data = arrayToDict ( data )
165
165
return processAsync ( Object . values ( data ) ) ;
166
166
} ) ;
@@ -169,15 +169,15 @@ $(document).ready(function() {
169
169
170
170
// testplans table
171
171
var plans_table = $ ( '#plans' ) . DataTable ( {
172
- ajax : function ( data , callback , settings ) {
173
- dataTableJsonRPC ( 'TestPlan.filter' , { cases : case_id } , callback ) ;
172
+ ajax : function ( data , callback , settings ) {
173
+ dataTableJsonRPC ( 'TestPlan.filter' , { cases : case_id } , callback ) ;
174
174
} ,
175
175
columns : [
176
176
{ data : "id" } ,
177
177
{
178
178
data : null ,
179
179
render : function ( data , type , full , meta ) {
180
- return '<a href="/plan/' + data . id + '/">' + escapeHTML ( data . name ) + '</a>' ;
180
+ return '<a href="/plan/' + data . id + '/">' + escapeHTML ( data . name ) + '</a>' ;
181
181
}
182
182
} ,
183
183
{ data : "author__username" } ,
@@ -188,7 +188,7 @@ $(document).ready(function() {
188
188
sortable : false ,
189
189
render : function ( data , type , full , meta ) {
190
190
if ( perm_remove_plan ) {
191
- return '<a href="#plans" class="remove-plan" data-pk="' + data . id + '"><span class="pficon-error-circle-o"></span></a>' ;
191
+ return '<a href="#plans" class="remove-plan" data-pk="' + data . id + '"><span class="pficon-error-circle-o"></span></a>' ;
192
192
}
193
193
return '' ;
194
194
}
@@ -200,20 +200,62 @@ $(document).ready(function() {
200
200
processing : '<div class="spinner spinner-lg"></div>' ,
201
201
zeroRecords : "No records found"
202
202
} ,
203
- order : [ [ 0 , 'asc' ] ] ,
203
+ order : [ [ 0 , 'asc' ] ] ,
204
204
} ) ;
205
205
206
206
// remove plan button
207
- plans_table . on ( 'draw' , function ( ) {
208
- $ ( '.remove-plan' ) . click ( function ( ) {
207
+ plans_table . on ( 'draw' , function ( ) {
208
+ $ ( '.remove-plan' ) . click ( function ( ) {
209
209
var tr = $ ( this ) . parents ( 'tr' ) ;
210
210
211
- jsonRPC ( 'TestPlan.remove_case' , [ $ ( this ) . data ( 'pk' ) , case_id ] , function ( data ) {
211
+ jsonRPC ( 'TestPlan.remove_case' , [ $ ( this ) . data ( 'pk' ) , case_id ] , function ( data ) {
212
212
plans_table . row ( $ ( tr ) ) . remove ( ) . draw ( ) ;
213
213
} ) ;
214
214
} ) ;
215
215
} ) ;
216
216
217
+ jsonRPC ( 'Testing.individual_test_case_health' , { case_id : case_id } , ress => {
218
+ console . log ( ress )
219
+
220
+ let res = { } ;
221
+ let planId = 0 ;
222
+ ress . forEach ( r => {
223
+ let positive = 0 ;
224
+ let negative = 0 ;
225
+ let allCount = 0 ;
226
+ if ( r . status__weight > 0 ) {
227
+ positive ++
228
+ } else if ( r . status__weight < 0 ) {
229
+ negative ++
230
+ }
231
+ allCount ++
232
+
233
+ if ( r . run__plan !== planId ) {
234
+ planId = r . run__plan ;
235
+ res [ planId ] = {
236
+ "completion_rate" : allCount > 0 ? ( ( positive + negative ) / allCount ) : 0 ,
237
+ "failure_rate" : allCount > 0 ? ( negative / allCount ) : 0 ,
238
+ }
239
+ positive = 0 ;
240
+ negative = 0 ;
241
+ allCount = 0 ;
242
+ }
243
+ } )
244
+
245
+ console . log ( res )
246
+
247
+ Object . entries ( res ) . forEach ( ( [ runId , data ] ) => {
248
+ const executionRow = $ ( `#execution-for-plan-${ runId } ` )
249
+ executionRow . find ( '.completion-rate' ) . html ( data . completion_rate )
250
+ executionRow . find ( '.completion-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( 1 - data . completion_rate ) * 100 } %` )
251
+ executionRow . find ( '.completion-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( data . completion_rate ) * 100 } %` )
252
+
253
+ executionRow . find ( '.failure-rate' ) . html ( data . failure_rate )
254
+ executionRow . find ( '.failure-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( data . failure_rate ) * 100 } %` )
255
+ executionRow . find ( '.failure-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( 1 - data . failure_rate ) * 100 } %` )
256
+ } )
257
+ } )
258
+
217
259
// bind add TP to TC widget
218
260
initAddPlan ( case_id , plans_table ) ;
219
261
0 commit comments