Skip to content

Commit

Permalink
Render Individual test case health on test case page
Browse files Browse the repository at this point in the history
  • Loading branch information
asankov committed Sep 20, 2021
1 parent 2f05a1d commit 9def326
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tcms/templates/include/tc_executions.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,24 @@ <h2 class="card-pf-title">
</div>

<div class="list-view-pf-body">
<div class="list-view-pf-description">
<div class="list-view-pf-description" style="display: flex; justify-content: space-between;">
<div class="list-group-item-text">
<a href="{% url 'test_plan_url_short' execution.run.plan.pk %}">TP-{{ execution.run.plan.pk }}: {{ execution.run.plan.name }}</a>
</div>
<div class="list-group-item-text">
<div class="completion-rate-container">{% trans 'Completion rate' %}: <span class="completion-rate"></span>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar"></div>
<div class="progress-bar progress-bar-success" role="progressbar"></div>
</div>
</div>
<div class="failure-rate-container">{% trans 'Failure rate' %}:<span class="failure-rate"></span>
<div class="progress">
<div class="progress-bar progress-bar-danger" role="progressbar"></div>
<div class="progress-bar progress-bar-success" role="progressbar"></div>
</div>
</div>
</div>
</div>
</div>
</div> <!-- /main info -->
Expand Down
38 changes: 38 additions & 0 deletions tcms/testcases/static/testcases/js/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,44 @@ $(document).ready(function () {
})
})

jsonRPC('Testing.individual_test_case_health', { case_id: case_id }, ress => {
const res = {}
let planId = 0
ress.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.run__plan !== planId) {
planId = r.run__plan
res[planId] = {
completion_rate: allCount > 0 ? ((positive + negative) / allCount) : 0,
failure_rate: allCount > 0 ? (negative / allCount) : 0
}
positive = 0
negative = 0
allCount = 0
}
})

Object.entries(res).forEach(([runId, data]) => {
const executionRow = $(`#execution-for-plan-${runId}`)
executionRow.find('.completion-rate').html(data.completion_rate)
executionRow.find('.completion-rate-container .progress-bar-danger').css('width', `${(1 - data.completion_rate) * 100}%`)
executionRow.find('.completion-rate-container .progress-bar-success').css('width', `${(data.completion_rate) * 100}%`)

executionRow.find('.failure-rate').html(data.failure_rate)
executionRow.find('.failure-rate-container .progress-bar-danger').css('width', `${(data.failure_rate) * 100}%`)
executionRow.find('.failure-rate-container .progress-bar-success').css('width', `${(1 - data.failure_rate) * 100}%`)
})
})

// bind add TP to TC widget
initAddPlan(case_id, plans_table)

Expand Down

0 comments on commit 9def326

Please sign in to comment.