diff --git a/tcms/templates/include/tc_executions.html b/tcms/templates/include/tc_executions.html index 6c82856e5b..39902f24f4 100644 --- a/tcms/templates/include/tc_executions.html +++ b/tcms/templates/include/tc_executions.html @@ -23,10 +23,19 @@

-
diff --git a/tcms/testcases/static/testcases/js/get.js b/tcms/testcases/static/testcases/js/get.js index 5dbee3187b..258754e71a 100644 --- a/tcms/testcases/static/testcases/js/get.js +++ b/tcms/testcases/static/testcases/js/get.js @@ -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) @@ -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) diff --git a/tcms/testcases/templates/testcases/get.html b/tcms/testcases/templates/testcases/get.html index 968ad29986..5653c770c0 100644 --- a/tcms/testcases/templates/testcases/get.html +++ b/tcms/testcases/templates/testcases/get.html @@ -17,6 +17,7 @@

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 }}: {{ object.summary }}