Skip to content

Commit

Permalink
Clone TC: remove 'Filter another plan' option. Refs #838
Browse files Browse the repository at this point in the history
- this simplifies the forms and cloning operation
- will be replaced by 'Add TP to TC', see
  #1021

Note: the functionality 'Clone TC into another TP + copy', e.g.
create a new TC record (with new ID) which is part of a different
TP will not be supported. Instead the user can either:

1) Add existing TC into new TP + clone to duplicate the ID + remove
   the older TC or;
2) Manually create a new TC which will be part of the new TP
  • Loading branch information
atodorov committed Jul 25, 2019
1 parent 03e59ac commit 38bea09
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 174 deletions.
40 changes: 0 additions & 40 deletions tcms/static/js/testcase_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,6 @@ Nitrate.TestCases.Clone = {};


Nitrate.TestCases.Clone.on_load = function() {
$('#id_product').change(update_version_select_from_product);
if (!$('#id_version').val().length) {
update_version_select_from_product();
}

jQ('#id_form_search_plan').bind('submit', function(e) {
e.stopPropagation();
e.preventDefault();

var url = '/plans/';
var container = jQ('#id_plan_container');
container.show();

jQ.ajax({
'url': url,
'type': 'GET',
'data': jQ(this).serialize(),
'success': function (data, textStatus, jqXHR) {
container.html(data);
}
});
});

jQ('#id_use_filterplan').bind('click', function(e) {
jQ('#id_form_search_plan :input').attr('disabled', false);
jQ('#id_plan_id').val('');
jQ('#id_plan_id').attr('name', '');
jQ('#id_copy_case').attr('checked', true);
});

jQ('#id_use_sameplan').bind('click', function(e) {
jQ('#id_form_search_plan :input').attr('disabled', true);
jQ('#id_plan_id').val(jQ('#value_plan_id').val());
jQ('#id_plan_id').attr('name', 'plan');
jQ('#id_plan_container').html('<div class="ajax_loading"></div>').hide();
jQ('#id_copy_case').attr('checked', false);
});

$('#id_use_sameplan').click();

jQ('.js-cancel-button').bind('click', function() {
window.history.go('-1');
});
Expand Down
67 changes: 2 additions & 65 deletions tcms/templates/case/clone.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,14 @@
{% endblock %}
{% block contents %}
<div id="content">
<div id="hidden">
<input id="value_plan_id" type="hidden" name="plan_id" value="{{ test_plan.plan_id }}" />
</div>

<h2>{% trans "Clone TestCase(s)" %}</h2>
<h2>{% trans "Clone TestCase(s) into" %} TP-{{ test_plan.pk }}: {{ test_plan.name }}</h2>
<div class="Detailform border-1">
<div class="editor" cellspacing="0" cellspan="0">
<div class="listinfo">
<label class="strong title">{% trans "Select Plan" %}</label>
{% if test_plan %}
<div>
<input type="radio" id="id_use_sameplan" name="selectplan" value="{{ test_plan.plan_id }}" checked="checked"/>
<label for="id_use_sameplan" class="strong">{% trans "Use the same Plan" %} -- {{ test_plan.plan_id }} : {{ test_plan.name }}</label>
</div>
{% endif %}
<div>
<input type="radio" id="id_use_filterplan" name="selectplan"/>
<label for="id_use_filterplan" class="strong">{% trans "Filter another plan" %}</label>
<div id="id_filterPlan">
<form id="id_form_search_plan" action="{% url "plans-all" %}" method="get">
<input type="hidden" name="action" value="clone_case" />
<div class="cell">
<label class="sd" for="id_pk__in">{% trans "ID" %}</label>
{{ search_form.pk__in }}
</div>
<div class="cell">
<label class="sd" for="id_product_id">{% trans "Product" %}</label>
{{ search_form.product }}
</div>
<div class="cell">
<label class="sd" for="id_version_id">{% trans "Product Version" %}</label>
{{ search_form.version }}
</div>
<div class="cell">
<label class="sd" for="id_type_id">{% trans "Plan Type" %}</label>
{{ search_form.type }}
</div>
<div class="cell">
<label class="sd" for="id_author_id">{% trans "Plan Author" %}</label>
{{ search_form.author__email__startswith }}
</div>
<div class="cell">
<label class="sd" for="id_tag_id">{% trans "Tag" %}</label>
{{ search_form.tag__name__in }}
</div>
<div class="cell">
<label class="sd" for="id_name_id">{% trans "Plan Summary" %}</label>
{{ search_form.name__icontains }}
</div>
<div class="cell">
<label class="sd" for="id_is_active_id">{% trans "Active" %}</label>
{{ search_form.is_active }}
</div>
<div class="cell" style=" margin-left:0">
<input type="submit" value="Filter plan" />
</div>
</form>
</div>
{% if submit_action %}
{{ clone_form.plan.errors }}
{% endif %}
</div>
</div>
<form id="id_clone_form" action="{% url "testcases-clone" %}" method="post">
{{ form.case_id }}
<div class="listinfo">
<label class="strong title"></label>
<input id="id_plan_id" type="hidden" name="" value="" />
<div id="id_plan_container" style="display: none;">
<div class="ajax_loading"></div>
</div>
<input id="id_plan_id" type="hidden" name="plan" value="{{ test_plan.pk }}" />
</div>
<div class="listinfo">
<label class="strong title">{% trans "Case(s)" %}</label>
Expand Down
25 changes: 0 additions & 25 deletions tcms/templates/case/clone_select_plan.html

This file was deleted.

23 changes: 2 additions & 21 deletions tcms/testcases/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,7 @@ def test_show_clone_page_with_from_plan(self):
{'from_plan': self.plan.pk,
'case': [self.case_1.pk, self.case_2.pk]})

self.assertContains(
response,
"""<div>
<input type="radio" id="id_use_sameplan" name="selectplan" value="%s">
<label for="id_use_sameplan" class="strong">%s -- %s : %s</label>
</div>""" % (self.plan.pk, _('Use the same Plan'), self.plan.pk, self.plan.name),
html=True)
self.assertContains(response, "TP-%s: %s" % (self.plan.pk, self.plan.name))

for loop_counter, case in enumerate([self.case_1, self.case_2]):
self.assertContains(
Expand All @@ -357,20 +351,7 @@ def test_show_clone_page_with_from_plan(self):

def test_show_clone_page_without_from_plan(self):
response = self.client.get(self.clone_url, {'case': self.case_1.pk})

self.assertNotContains(
response,
'Use the same Plan -- {0} : {1}'.format(self.plan.pk,
self.plan.name),
)

self.assertContains(
response,
'<label for="id_case_0">'
'<input checked="checked" id="id_case_0" name="case" '
'type="checkbox" value="{0}"> {1}</label>'.format(
self.case_1.pk, self.case_1.summary),
html=True)
self.assertRedirects(response, '/')


class TestSearchCases(BasePlanCase):
Expand Down
21 changes: 7 additions & 14 deletions tcms/testcases/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from tcms.testruns.models import TestExecutionStatus
from tcms.testcases.forms import NewCaseForm, \
SearchCaseForm, CaseNotifyForm, CloneCaseForm
from tcms.testplans.forms import SearchPlanForm
from tcms.testcases.fields import MultipleEmailField


Expand Down Expand Up @@ -763,8 +762,12 @@ def clone(request, template_name='case/clone.html'):
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))

test_plan_src = plan_from_request_or_none(request)
test_plan = None
search_plan_form = SearchPlanForm()
if not test_plan_src:
messages.add_message(request,
messages.ERROR,
_('TestPlan is required'))
# redirect back where we came from
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))

# Do the clone action
if request.method == 'POST':
Expand Down Expand Up @@ -909,18 +912,8 @@ def clone(request, template_name='case/clone.html'):
})
clone_form.populate(case_ids=selected_cases)

# Generate search plan form
if request_data.get('from_plan'):
test_plan = TestPlan.objects.get(plan_id=request_data['from_plan'])
search_plan_form = SearchPlanForm(
initial={'product': test_plan.product_id, 'is_active': True})
search_plan_form.populate(product_id=test_plan.product_id)

submit_action = request_data.get('submit', None)
context = {
'test_plan': test_plan,
'search_form': search_plan_form,
'test_plan': test_plan_src,
'clone_form': clone_form,
'submit_action': submit_action,
}
return render(request, template_name, context)
12 changes: 3 additions & 9 deletions tcms/testplans/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,9 @@ def get_all(request): # pylint: disable=missing-permission-required
# Set search active plans only by default
search_form = SearchPlanForm(initial={'is_active': True})

# fixme: this view is scheduled for deletion
# TestCase clone workflow must be redesigned so it uses
# the TestPlan search page
template_name = ''
if request.GET.get('action') == 'clone_case':
template_name = 'case/clone_select_plan.html'
tps = tps.order_by('name')

# used in tree preview & TestCase add plan
template_name = 'non-existing.html'

# used in tree preview only
# fixme: must be replaced by JSON RPC and the
# JavaScript dialog that displays the preview
# should be converted to Patternfly
Expand Down

0 comments on commit 38bea09

Please sign in to comment.