Skip to content

Commit

Permalink
TestRun page - TE row - update how we calculate & check for bugs
Browse files Browse the repository at this point in the history
- this is only used for visual cues on the page aka showing the
  bug icon for every TE row which has bugs reported.

- show bug icon if URL is a defect

- remove legacy section that displays bugs in TE container. Refs #475

- update filter field
  • Loading branch information
atodorov committed Aug 27, 2019
1 parent 6c381c7 commit afd979d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 93 deletions.
30 changes: 0 additions & 30 deletions tcms/static/js/bugs.js

This file was deleted.

4 changes: 0 additions & 4 deletions tcms/static/js/testrun_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ Nitrate.TestRuns.Details.on_load = function() {
var params = jQ(this).data('params');
addCaseRunBug(params[0], c[0], c_container[0], params[1], params[2]);
});
c_container.find('.js-remove-caserun-bug').bind('click', function(){
var params = jQ(this).data('params');
removeCaseBug(params[1], params[2], params[3]);
});
c_container.find('.js-add-testlog').bind('click', function(){
var params = jQ(this).data('params');
addLinkToTestExecution(this, params[0], [params[1]]);
Expand Down
30 changes: 1 addition & 29 deletions tcms/templates/case/get_details_case_run.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,34 +83,6 @@ <h4 class="borderB">{% trans "bug" %}
{% endif %} ]
</span>
</h4>
<ul class="ul-no-format">
{% for bug_id, bugs in grouped_case_bugs %}
<li id="bug_item">
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td><a href="{{ bugs.0.get_full_url }}">{{ bug_id }}</a></td>
<td>
{% for bug in bugs %}
{% if bug.case_run_id %}
<span class="grey">{% trans "From Run" %}</span><a href="{% url "testruns-get" bug.case_run.run_id %}">{{ bug.case_run.run_id }}</a>
{% if bug.case_run_id == execution.pk and perms.testcases.delete_bug %}
<a id="bug_{{ bug_id }}_{{ bug.case_id }}_{{ bug.case_run_id }}" href="javascript:void(0);" title="Remove This Bug" class="js-remove-caserun-bug" data-params='[{{ execution.run.pk }}, "{{ bug.bug_id }}", {{ bug.case_id }}, {{ bug.case_run_id }}]'>
<img width="9" height="9" title="remove this bug" src="{% static 'images/remove_small.png' %}">
</a>
{% endif %}
{% else %}
<span class="grey">{% trans "From Case" %}</span>
<a href="{% url "testcases-get" bug.case_id %}">{{ bug.case_id }}</a>
{% endif %}
{% endfor %}
</td>
</tr>
</table>
</li>
{% empty %}
<li class="grey">{% trans "No bug found" %}</li>
{% endfor %}
</ul>
</div>
<div class="container" style="min-height:50px;">
{% if execution_logs %}
Expand Down Expand Up @@ -193,7 +165,7 @@ <h4 class="borderB">{% trans "Links" %} <span>[<a href="javascript:void(0);" cla
<ul class="ul-format">
{% for link in execution.links %}
<li>
<a href="{{ link.url }}" target="_blank" title="{{ link.url }}">{{ link.name|escape|default:link.url }}</a>
<a {% if link.is_defect %}class="have_bug"{% endif %} href="{{ link.url }}" target="_blank" title="{{ link.url }}">{{ link.name|escape|default:link.url }}</a>
<span class="grey">{{ link.created_on|date:"N d, Y" }}</span>
<a href="javascript:void(0);" class="js-remove-testlog" data-param="{{ link.pk }}">
<img title="Remove this log" src="{% static 'images/remove_small.png' %}" />
Expand Down
1 change: 0 additions & 1 deletion tcms/templates/run/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link rel="stylesheet" href="{% static 'font-awesome/css/font-awesome.min.css' %}">
<script src="{% static 'jquery/dist/jquery.min.js' %}"></script>
<script src="{% static 'js/jsonrpc.js' %}"></script>
<script src="{% static 'js/bugs.js' %}"></script>

<script type="text/javascript" src="{% static 'js/testrun_actions.js' %}"></script>
<script type="text/javascript" src="{% static 'js/testcase_actions.js' %}"></script>
Expand Down
3 changes: 1 addition & 2 deletions tcms/templates/run/get_case_runs.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@
<div class="rightlistinfo">
<div class="listinfo">
<span class="title"><label for="id_bug">{% trans "Bug" %}&nbsp;:</label></span>
<input id="id_bug" type="text" name="case_run_bug__bug_id__in" value="{{ REQUEST_CONTENTS.case_run_bug__bug_id__in }}" />
<span class='grey'>{% trans "You can type multiple bugs by comma." %}</span>
<input id="id_bug" type="text" name="linkreference__url__icontains" value="{{ REQUEST_CONTENTS.case_run_bug__bug_id__in }}" />
</div>
<div class="listinfo">
<span class="title"><label for="id_status">{% trans "Status" %}&nbsp;:</label></span>
Expand Down
4 changes: 2 additions & 2 deletions tcms/templates/run/table_executions.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</tr>
</thead>
<tbody>
{% for execution, tester, assignee, priority_value, status_name, comments_count in executions %}
{% for execution, tester, assignee, priority_value, status_name, comments_count, bugs_count in executions %}
<tr class="{% cycle 'odd' 'even' %} {% ifequal execution.assignee_id user.pk %} mine {% endifequal %}">
<td>
<input type="checkbox" name="case_run" value="{{ execution.pk }}" class="caserun_selector" title="Select/Unselect" />
Expand Down Expand Up @@ -61,7 +61,7 @@
<td class="expandable">{{ execution.case.is_automated }}</td>
<td class="expandable">{{ execution.case.category }}</td>
<td class="expandable">{{ priority_value }}</td>
<td class="expandable"><span id="{{ execution.pk }}_case_bug_count" {% if execution.num_bug %}class="have_bug"{% endif %}>{{ execution.num_bug }}</span></td>
<td class="expandable"><span id="{{ execution.pk }}_case_bug_count" {% if bugs_count %}class="have_bug"{% endif %}>{{ bugs_count }}</span></td>
<td class="expandable center">
<img border="0" alt="" class="icon_status btn_{{ status_name|lower }}" />
</td>
Expand Down
14 changes: 0 additions & 14 deletions tcms/testcases/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

import itertools

from django.conf import settings
from django.contrib import messages
from django.test import modify_settings
Expand Down Expand Up @@ -85,16 +83,6 @@ def update_case_email_settings(test_case, n_form):
test_case.emailing.save()


def group_case_bugs(bugs):
"""Group bugs using bug_id."""
grouped_bugs = []

for _pk, _bugs in itertools.groupby(bugs, lambda b: b.bug_id):
grouped_bugs.append((_pk, list(_bugs)))

return grouped_bugs


@method_decorator(permission_required('testcases.add_testcase'), name='dispatch')
class NewCaseView(TemplateView):

Expand Down Expand Up @@ -519,7 +507,6 @@ def get_context_data(self, **kwargs):
execution_comments = get_comments(execution)

execution_status = TestExecutionStatus.objects.values('pk', 'name').order_by('pk')
bugs = group_case_bugs(execution.case.get_bugs().order_by('bug_id'))

data.update({
'test_case': case,
Expand All @@ -530,7 +517,6 @@ def get_context_data(self, **kwargs):
'execution_comments': execution_comments,
'execution_logs': execution.history.all(),
'execution_status': execution_status,
'grouped_case_bugs': bugs,
})

return data
Expand Down
21 changes: 10 additions & 11 deletions tcms/testruns/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from tcms.testruns.forms import NewRunForm, SearchRunForm, BaseRunForm
from tcms.testruns.models import TestRun, TestExecution, TestExecutionStatus
from tcms.issuetracker.types import IssueTrackerType
from tcms.core.contrib.linkreference.models import LinkReference


User = get_user_model() # pylint: disable=invalid-name
Expand Down Expand Up @@ -154,10 +155,6 @@ def _open_run_get_executions(request, run): # pylint: disable=missing-permissio
'case__category__name'
)

# Get the bug count for each execution
# 5. have to show the number of bugs of each execution
executions = executions.annotate(num_bug=Count('case_run_bug', distinct=True))

# todo: is this last distinct necessary
executions = executions.distinct()

Expand Down Expand Up @@ -247,13 +244,15 @@ def walk_executions():
comments_subtotal = open_run_get_comments_subtotal(execution_pks)
status = TestExecutionStatus.get_names()

for case_run in test_executions:
yield (case_run,
testers.get(case_run.tested_by_id, None),
assignees.get(case_run.assignee_id, None),
priorities.get(case_run.case.priority_id),
status[case_run.status_id],
comments_subtotal.get(case_run.pk, 0))
for execution in test_executions:
yield (execution,
testers.get(execution.tested_by_id, None),
assignees.get(execution.assignee_id, None),
priorities.get(execution.case.priority_id),
status[execution.status_id],
comments_subtotal.get(execution.pk, 0),
LinkReference.objects.filter(is_defect=True,
execution=execution.pk).count())

context_data = {
'test_run': test_run,
Expand Down

0 comments on commit afd979d

Please sign in to comment.