Skip to content

Commit

Permalink
wip: Add individual test case health UI
Browse files Browse the repository at this point in the history
to test run page
  • Loading branch information
asankov committed Aug 20, 2021
1 parent cec22e0 commit ec62206
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
54 changes: 50 additions & 4 deletions tcms/testruns/static/testruns/js/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const permissions = {
addComment: false,
removeComment: false
}
const testCaseIds = []
const autocomplete_cache = {}

$(document).ready(() => {
Expand Down Expand Up @@ -135,9 +136,45 @@ $(document).ready(() => {
}

jsonRPC('TestExecution.filter', rpcQuery, testExecutions => {
testExecutions.forEach(te => testCaseIds.push(te.case))

drawPercentBar(testExecutions)
renderTestExecutions(testExecutions)
renderAdditionalInformation(testRunId)

console.log(testCaseIds)

jsonRPC('Testing.individual_test_case_health', { case_id__in: testCaseIds }, result => {
console.log(result)

const testCaseHealth = {}
let caseId = 0
result.forEach(r => {
let positive = 0
let negative = 0
let allCount = 0
if (r.status__weight > 0) {
positive++
} else if (r.status__weight < 0) {
negative++
}
allCount++

if (r.case_id !== caseId) {
caseId = r.case_id
testCaseHealth[caseId] = {
completion_rate: allCount > 0 ? ((positive + negative) / allCount) : 0,
failure_rate: allCount > 0 ? (negative / allCount) : 0
}
positive = 0
negative = 0
allCount = 0
}
})

console.log(testCaseHealth)
renderTestExecutions(testExecutions, testCaseHealth)
})

})
})

Expand Down Expand Up @@ -343,15 +380,15 @@ function renderCountPerStatusList (statusCount) {
}
}

function renderTestExecutions (testExecutions) {
function renderTestExecutions (testExecutions, testCaseHealth) {
// sort executions by sortkey
testExecutions.sort(function (te1, te2) {
return te1.sortkey - te2.sortkey
})
const container = $('#test-executions-container')

testExecutions.forEach(testExecution => {
container.append(renderTestExecutionRow(testExecution))
container.append(renderTestExecutionRow(testExecution, testCaseHealth))
})

bindEvents()
Expand Down Expand Up @@ -615,7 +652,7 @@ function renderHistoryEntry (historyEntry) {
return template
}

function renderTestExecutionRow (testExecution) {
function renderTestExecutionRow (testExecution, testCaseHealth={}) {
// refresh the internal data structure b/c some fields are used
// to render the expand area and may have changed via bulk-update meanwhile
allExecutions[testExecution.id] = testExecution
Expand All @@ -632,6 +669,15 @@ function renderTestExecutionRow (testExecution) {
template.find('.test-execution-info-link').attr('href', `/case/${testExecution.case}/`)
template.find('.test-execution-tester').html(testExecution.tested_by__username || '-')
template.find('.test-execution-asignee').html(testExecution.assignee__username || '-')
// TODO: this is just for visualization of how we will be using the API
// this will probably be replaced by a visual icon
const testExecutionCaseHealth = testCaseHealth[testExecution.case]
// this may be empty if we are reloading the execution after an update
// in this case it's unlikely that the health of the test case has changed
if (testExecutionCaseHealth) {
template.find('.test-case-completion-rate').html(testExecutionCaseHealth.completion_rate)
template.find('.test-case-failure-rate').html(testExecutionCaseHealth.failure_rate)
}

const testExecutionStatus = allExecutionStatuses[testExecution.status]
template.find('.test-execution-status-icon').addClass(testExecutionStatus.icon).css('color', testExecutionStatus.color)
Expand Down
5 changes: 5 additions & 0 deletions tcms/testruns/templates/testruns/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ <h5><span class="test-executions-count"></span> {% trans 'records' %}</h5>
<div title="{% trans 'Bugs' %}" class="list-view-pf-additional-info-item js-bugs hidden">
<span class="fa fa-bug" style="color:#cc0000"></span>
</div>
<div title="{% trans 'Test Case Health' %}" class="list-view-pf-additional-info-item">
<!-- <span class="fa fa-bug" style="color:#cc0000"></span> -->
CR: <span class="test-case-completion-rate"></span>
FR: <span class="test-case-failure-rate"></span>
</div>
</div>
<div class="list-view-pf-additional-info" style="width: 30%;">
<div title="{% trans 'Status' %}" class="list-view-pf-additional-info-item">
Expand Down

0 comments on commit ec62206

Please sign in to comment.