Skip to content

Commit ec62206

Browse files
committed
wip: Add individual test case health UI
to test run page
1 parent cec22e0 commit ec62206

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

tcms/testruns/static/testruns/js/get.js

+50-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const permissions = {
66
addComment: false,
77
removeComment: false
88
}
9+
const testCaseIds = []
910
const autocomplete_cache = {}
1011

1112
$(document).ready(() => {
@@ -135,9 +136,45 @@ $(document).ready(() => {
135136
}
136137

137138
jsonRPC('TestExecution.filter', rpcQuery, testExecutions => {
139+
testExecutions.forEach(te => testCaseIds.push(te.case))
140+
138141
drawPercentBar(testExecutions)
139-
renderTestExecutions(testExecutions)
140142
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+
141178
})
142179
})
143180

@@ -343,15 +380,15 @@ function renderCountPerStatusList (statusCount) {
343380
}
344381
}
345382

346-
function renderTestExecutions (testExecutions) {
383+
function renderTestExecutions (testExecutions, testCaseHealth) {
347384
// sort executions by sortkey
348385
testExecutions.sort(function (te1, te2) {
349386
return te1.sortkey - te2.sortkey
350387
})
351388
const container = $('#test-executions-container')
352389

353390
testExecutions.forEach(testExecution => {
354-
container.append(renderTestExecutionRow(testExecution))
391+
container.append(renderTestExecutionRow(testExecution, testCaseHealth))
355392
})
356393

357394
bindEvents()
@@ -615,7 +652,7 @@ function renderHistoryEntry (historyEntry) {
615652
return template
616653
}
617654

618-
function renderTestExecutionRow (testExecution) {
655+
function renderTestExecutionRow (testExecution, testCaseHealth={}) {
619656
// refresh the internal data structure b/c some fields are used
620657
// to render the expand area and may have changed via bulk-update meanwhile
621658
allExecutions[testExecution.id] = testExecution
@@ -632,6 +669,15 @@ function renderTestExecutionRow (testExecution) {
632669
template.find('.test-execution-info-link').attr('href', `/case/${testExecution.case}/`)
633670
template.find('.test-execution-tester').html(testExecution.tested_by__username || '-')
634671
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+
}
635681

636682
const testExecutionStatus = allExecutionStatuses[testExecution.status]
637683
template.find('.test-execution-status-icon').addClass(testExecutionStatus.icon).css('color', testExecutionStatus.color)

tcms/testruns/templates/testruns/get.html

+5
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ <h5><span class="test-executions-count"></span> {% trans 'records' %}</h5>
394394
<div title="{% trans 'Bugs' %}" class="list-view-pf-additional-info-item js-bugs hidden">
395395
<span class="fa fa-bug" style="color:#cc0000"></span>
396396
</div>
397+
<div title="{% trans 'Test Case Health' %}" class="list-view-pf-additional-info-item">
398+
<!-- <span class="fa fa-bug" style="color:#cc0000"></span> -->
399+
CR: <span class="test-case-completion-rate"></span>
400+
FR: <span class="test-case-failure-rate"></span>
401+
</div>
397402
</div>
398403
<div class="list-view-pf-additional-info" style="width: 30%;">
399404
<div title="{% trans 'Status' %}" class="list-view-pf-additional-info-item">

0 commit comments

Comments
 (0)