Skip to content

Conversation

oskarhurst
Copy link
Contributor

Adds the funtionality to support cloning multiple test plans at once from the testplans search page, addressing issue #3976.

Important notes and considerations before merge. The existing single clone page still exists as a seperate page. For the most part these two pages are identical however since we are handellign multiple testplans at once I removed the ability to give the clone test plan a new name instead always keeping the old name. In the future I can look at combining these two pages into one. Also this code assumes all test plans that want to be coded are going to be clone into the same product and version. If user want more cotimization I believe they should filter and do clones in smaller groups, however we could add more check bozes to the page to ask indiviualy for each test plan if they want to set the old test plan as the parent and if they want to copy test cases, rn the response is uniform.


def get(self, request):
if not self._is_request_data_valid(request, "p"):
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium test

Untrusted URL redirection depends on a
user-provided value
.

def post(self, request):
if not self._is_request_data_valid(request):
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium test

Untrusted URL redirection depends on a
user-provided value
.

# invalid form
messages.add_message(request, messages.ERROR, clone_form.errors)
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium test

Untrusted URL redirection depends on a
user-provided value
.
Copy link
Member

@atodorov atodorov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few initial comments.

})

// header “select all”
$('#resultsTable thead').on('change', '#select-all', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not liking this in the header that much.

Can you move the "Select All" + the "Clone Selected" buttons into the button box above the table?

See how the rest of the buttons are defined. For icon, use fa-code-fork icon to match existing UI.

The order should be
[ ] <clone-selected> <excel> <.... the rest of the buttons>.

Note: (a follow up improvement can be made to the rest of these table buttons to operate only on the current selection if present.

$('#btn_clone_bulk').click(function () {
const selectedTestPlans = getSelectedTestPlans()
if (selectedTestPlans.length === 0) {
alert('No test plans selected for cloning.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string must be translatable. See how it's done for other strings on dynamic pages (.data('trans- selectors).

$('#id_product').change(updateVersionSelectFromProduct)
}

function getSelectedTestPlans () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, this feels like a duplicate. Need to check if we don't have something more generic which already does this.

In testplans/static/testplans/js/get.js there is getSelectedTestCases() and IIRC there was another one in utils.js but let's leave this for later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main differences between getSelectedTestPlans() and getSelectedTestCases() is that getplans has the handle selecting child nested elements where getcases does not do this.



@method_decorator(permission_required("testplans.add_testplan"), name="dispatch")
class MultiClone(FormView):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not liking this one very much b/c it adds unnecessary code.

IMO all could be done with the existing cloning code but needs more attention to the details.

Let's sort the GUI part first and then will circle back to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could remove the original single clone classes and code and change it to redirect to multiclone checking if there is only one and if so letting you change its name.

return false
}

window.location.assign(`/plan/clone/?p=${selectedTestPlans.join('&p=')}`)

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium test

DOM text
is reinterpreted as HTML without escaping meta-characters.
@oskarhurst
Copy link
Contributor Author

Added a few initial comments.

@atodorov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants