Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render Individual test case health on test case page #2277

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tcms/templates/include/tc_executions.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ <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="failure-rate-container">
<span class="failure-rate"></span>
<div class="progress" style="height: 5px">
<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
50 changes: 50 additions & 0 deletions tcms/testcases/static/testcases/js/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ $(document).ready(function () {
const perm_remove_component = $('#test_case_pk').data('perm-remove-component') === 'True'
const perm_remove_plan = $('#test_case_pk').data('perm-remove-plan') === 'True'
const perm_remove_bug = $('#test_case_pk').data('perm-remove-bug') === 'True'
const testCaseHealthMessageTemplate = $('#test_case_pk').data('individual-test-case-health-msg')


// bind everything in tags table
tagsCard('TestCase', case_id, { case: case_id }, perm_remove_tag)
Expand Down Expand Up @@ -210,6 +212,54 @@ $(document).ready(function () {
})
})

jsonRPC('Testing.individual_test_case_health', { case_id: case_id }, ress => {
const res = {}
let planId = 0
let negative = 0
let allCount = 0
ress.forEach(r => {
if (planId === 0) {
planId = r.run__plan
}

if (r.status__weight < 0) {
negative++
}
allCount++

if (r.run__plan !== planId) {
planId = r.run__plan
const failureRate = allCount > 0 ? (negative / allCount) : 0
res[planId] = {
negativeCount: negative,
allCount: allCount,
failureRate: failureRate
}
negative = 0
allCount = 0
}
})
// add the last entry
const failureRate = allCount > 0 ? (negative / allCount) : 0
res[planId] = {
negativeCount: negative,
allCount: allCount,
failureRate: failureRate
}

Object.entries(res).forEach(([runId, data]) => {
const stabilityPercent = (1-data.failureRate)*100
const msg = testCaseHealthMessageTemplate.replace("%s", data.negativeCount)
.replace("%s", data.allCount)
.replace("%s", stabilityPercent.toFixed(2))

const executionRow = $(`#execution-for-plan-${runId}`)
executionRow.find('.failure-rate').html(msg)
executionRow.find('.failure-rate-container .progress-bar-danger').css('width', `${(data.failureRate) * 100}%`)
executionRow.find('.failure-rate-container .progress-bar-success').css('width', `${(1 - data.failureRate) * 100}%`)
})
})

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

Expand Down
1 change: 1 addition & 0 deletions tcms/testcases/templates/testcases/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h1 class="col-md-12" style="margin-top: 0">
data-perm-remove-component="{{ perms.testcases.delete_testcasecomponent }}"
data-perm-remove-plan="{{ perms.testcases.delete_testcaseplan }}"
data-perm-remove-bug="{{ perms.testcases.delete_bug }}"
data-individual-test-case-health-msg="{% trans 'Failed %s times in the last %s run. Stability: %s %' %}"
>TC-{{ object.pk }}:</span> {{ object.summary }}
</h1>

Expand Down