Skip to content

Commit

Permalink
On TR page allow removal of individual parametrized TEs. Closes #3282
Browse files Browse the repository at this point in the history
instead of removing all of them. Adjusts internal state accordingly.

Add deprecation warning for API method TestRun.remove_case()
  • Loading branch information
atodorov committed Feb 20, 2024
1 parent 1b7c0dc commit d08a95b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
9 changes: 2 additions & 7 deletions tcms/rpc/api/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,8 @@ def remove_case(run_id, case_id):
"""
.. function:: RPC TestRun.remove_case(run_id, case_id)
Remove a TestCase from the selected test run.
:param run_id: PK of TestRun to modify
:type run_id: int
:param case_id: PK of TestCase to be removed
:type case_id: int
:raises PermissionDenied: if missing *testruns.delete_testexecution* permission
WARNING: this method is deprecated in favor of ``TestExecution.remove()``!
Nothing in Kiwi TCMS uses it directly and it will be removed in the future!
"""
TestExecution.objects.filter(run=run_id, case=case_id).delete()

Expand Down
19 changes: 8 additions & 11 deletions tcms/testruns/static/testruns/js/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function pageTestrunsGetReadyHandler () {

const areYouSureText = $('#test_run_pk').data('trans-are-you-sure')
if (confirm(areYouSureText)) {
removeCases(testRunId, selected.caseIds)
removeCases(selected.executionIds)
}

return false
Expand Down Expand Up @@ -292,7 +292,7 @@ function addTestCaseToRun (runId) {
}

jsonRPC('TestRun.add_case', [runId, testCase.id], function (result) {
// IMPORTANT: the API result includes a 'sortkey' field value!
// IMPORTANT: the API result includes a 'sortkey' field value!
window.location.reload(true)

// TODO: remove the page reload above and add the new case to the list
Expand Down Expand Up @@ -927,16 +927,13 @@ export function bindDeleteLinkButton () {
})
}

function removeCases (testRunId, testCaseIds) {
for (const testCaseId of testCaseIds) {
jsonRPC('TestRun.remove_case', [testRunId, testCaseId], () => {
const tePK = $(`.test-execution-case-${testCaseId}`)
.find('.test-execution-checkbox')
.data('test-execution-id')
$(`.test-execution-case-${testCaseId}`).remove()
function removeCases (executionIds) {
for (const executionId of executionIds) {
jsonRPC('TestExecution.remove', { id: executionId }, () => {
$(`#test-execution-${executionId}`).remove()

expandedExecutionIds.splice(expandedExecutionIds.indexOf(tePK), 1)
delete allExecutions[tePK]
expandedExecutionIds.splice(expandedExecutionIds.indexOf(executionId), 1)
delete allExecutions[executionId]

const testExecutionCountEl = $('.test-executions-count')
const count = parseInt(testExecutionCountEl[0].innerText)
Expand Down

0 comments on commit d08a95b

Please sign in to comment.