11const plan_cache = { }
22
3- function addComponent ( object_id , _input , to_table ) {
3+ function addComponent ( object_id , _input , to_table ) {
44 const _name = _input . value
55
66 if ( _name . length > 0 ) {
@@ -15,7 +15,7 @@ function addComponent (object_id, _input, to_table) {
1515 }
1616}
1717
18- function addTestPlanToTestCase ( case_id , plans_table ) {
18+ function addTestPlanToTestCase ( case_id , plans_table ) {
1919 const plan_name = $ ( '#input-add-plan' ) [ 0 ] . value
2020 const plan = plan_cache [ plan_name ]
2121
@@ -31,7 +31,7 @@ function addTestPlanToTestCase (case_id, plans_table) {
3131 } )
3232}
3333
34- function initAddPlan ( case_id , plans_table ) {
34+ function initAddPlan ( case_id , plans_table ) {
3535 // + button
3636 $ ( '#btn-add-plan' ) . click ( function ( ) {
3737 addTestPlanToTestCase ( case_id , plans_table )
@@ -210,6 +210,45 @@ $(document).ready(function () {
210210 } )
211211 } )
212212
213+ jsonRPC ( 'Testing.individual_test_case_health' , { case_id : case_id } , ress => {
214+
215+ let res = { } ;
216+ let planId = 0 ;
217+ ress . forEach ( r => {
218+ let positive = 0 ;
219+ let negative = 0 ;
220+ let allCount = 0 ;
221+ if ( r . status__weight > 0 ) {
222+ positive ++
223+ } else if ( r . status__weight < 0 ) {
224+ negative ++
225+ }
226+ allCount ++
227+
228+ if ( r . run__plan !== planId ) {
229+ planId = r . run__plan ;
230+ res [ planId ] = {
231+ "completion_rate" : allCount > 0 ? ( ( positive + negative ) / allCount ) : 0 ,
232+ "failure_rate" : allCount > 0 ? ( negative / allCount ) : 0 ,
233+ }
234+ positive = 0 ;
235+ negative = 0 ;
236+ allCount = 0 ;
237+ }
238+ } )
239+
240+ Object . entries ( res ) . forEach ( ( [ runId , data ] ) => {
241+ const executionRow = $ ( `#execution-for-plan-${ runId } ` )
242+ executionRow . find ( '.completion-rate' ) . html ( data . completion_rate )
243+ executionRow . find ( '.completion-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( 1 - data . completion_rate ) * 100 } %` )
244+ executionRow . find ( '.completion-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( data . completion_rate ) * 100 } %` )
245+
246+ executionRow . find ( '.failure-rate' ) . html ( data . failure_rate )
247+ executionRow . find ( '.failure-rate-container .progress-bar-danger' ) . css ( 'width' , `${ ( data . failure_rate ) * 100 } %` )
248+ executionRow . find ( '.failure-rate-container .progress-bar-success' ) . css ( 'width' , `${ ( 1 - data . failure_rate ) * 100 } %` )
249+ } )
250+ } )
251+
213252 // bind add TP to TC widget
214253 initAddPlan ( case_id , plans_table )
215254
0 commit comments