@@ -6,6 +6,7 @@ const permissions = {
6
6
addComment : false ,
7
7
removeComment : false
8
8
}
9
+ const testCaseIds = [ ]
9
10
const autocomplete_cache = { }
10
11
11
12
$ ( document ) . ready ( ( ) => {
@@ -135,9 +136,45 @@ $(document).ready(() => {
135
136
}
136
137
137
138
jsonRPC ( 'TestExecution.filter' , rpcQuery , testExecutions => {
139
+ testExecutions . forEach ( te => testCaseIds . push ( te . case ) )
140
+
138
141
drawPercentBar ( testExecutions )
139
- renderTestExecutions ( testExecutions )
140
142
renderAdditionalInformation ( testRunId )
143
+
144
+ console . log ( testCaseIds )
145
+
146
+ jsonRPC ( 'Testing.individual_test_case_health' , { case_id__in : testCaseIds } , result => {
147
+ console . log ( result )
148
+
149
+ const testCaseHealth = { }
150
+ let caseId = 0
151
+ result . forEach ( r => {
152
+ let positive = 0
153
+ let negative = 0
154
+ let allCount = 0
155
+ if ( r . status__weight > 0 ) {
156
+ positive ++
157
+ } else if ( r . status__weight < 0 ) {
158
+ negative ++
159
+ }
160
+ allCount ++
161
+
162
+ if ( r . case_id !== caseId ) {
163
+ caseId = r . case_id
164
+ testCaseHealth [ caseId ] = {
165
+ completion_rate : allCount > 0 ? ( ( positive + negative ) / allCount ) : 0 ,
166
+ failure_rate : allCount > 0 ? ( negative / allCount ) : 0
167
+ }
168
+ positive = 0
169
+ negative = 0
170
+ allCount = 0
171
+ }
172
+ } )
173
+
174
+ console . log ( testCaseHealth )
175
+ renderTestExecutions ( testExecutions , testCaseHealth )
176
+ } )
177
+
141
178
} )
142
179
} )
143
180
@@ -343,15 +380,15 @@ function renderCountPerStatusList (statusCount) {
343
380
}
344
381
}
345
382
346
- function renderTestExecutions ( testExecutions ) {
383
+ function renderTestExecutions ( testExecutions , testCaseHealth ) {
347
384
// sort executions by sortkey
348
385
testExecutions . sort ( function ( te1 , te2 ) {
349
386
return te1 . sortkey - te2 . sortkey
350
387
} )
351
388
const container = $ ( '#test-executions-container' )
352
389
353
390
testExecutions . forEach ( testExecution => {
354
- container . append ( renderTestExecutionRow ( testExecution ) )
391
+ container . append ( renderTestExecutionRow ( testExecution , testCaseHealth ) )
355
392
} )
356
393
357
394
bindEvents ( )
@@ -615,7 +652,7 @@ function renderHistoryEntry (historyEntry) {
615
652
return template
616
653
}
617
654
618
- function renderTestExecutionRow ( testExecution ) {
655
+ function renderTestExecutionRow ( testExecution , testCaseHealth = { } ) {
619
656
// refresh the internal data structure b/c some fields are used
620
657
// to render the expand area and may have changed via bulk-update meanwhile
621
658
allExecutions [ testExecution . id ] = testExecution
@@ -632,6 +669,15 @@ function renderTestExecutionRow (testExecution) {
632
669
template . find ( '.test-execution-info-link' ) . attr ( 'href' , `/case/${ testExecution . case } /` )
633
670
template . find ( '.test-execution-tester' ) . html ( testExecution . tested_by__username || '-' )
634
671
template . find ( '.test-execution-asignee' ) . html ( testExecution . assignee__username || '-' )
672
+ // TODO: this is just for visualization of how we will be using the API
673
+ // this will probably be replaced by a visual icon
674
+ const testExecutionCaseHealth = testCaseHealth [ testExecution . case ]
675
+ // this may be empty if we are reloading the execution after an update
676
+ // in this case it's unlikely that the health of the test case has changed
677
+ if ( testExecutionCaseHealth ) {
678
+ template . find ( '.test-case-completion-rate' ) . html ( testExecutionCaseHealth . completion_rate )
679
+ template . find ( '.test-case-failure-rate' ) . html ( testExecutionCaseHealth . failure_rate )
680
+ }
635
681
636
682
const testExecutionStatus = allExecutionStatuses [ testExecution . status ]
637
683
template . find ( '.test-execution-status-icon' ) . addClass ( testExecutionStatus . icon ) . css ( 'color' , testExecutionStatus . color )
0 commit comments