diff --git a/module/common/lang/de.php b/module/common/lang/de.php index 4bc250f97a..c2a3329d1e 100644 --- a/module/common/lang/de.php +++ b/module/common/lang/de.php @@ -24,6 +24,7 @@ $lang->null = 'Null'; $lang->ellipsis = '…'; $lang->percent = '%'; $lang->dash = '-'; +$lang->slash = '/'; $lang->and = 'and'; $lang->to = 'To'; diff --git a/module/common/lang/en.php b/module/common/lang/en.php index a320403f0f..91689bc918 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -24,6 +24,7 @@ $lang->null = 'Null'; $lang->ellipsis = '…'; $lang->percent = '%'; $lang->dash = '-'; +$lang->slash = '/'; $lang->and = 'and'; $lang->to = 'To'; diff --git a/module/common/lang/fr.php b/module/common/lang/fr.php index e95475e996..29aa4c43fb 100644 --- a/module/common/lang/fr.php +++ b/module/common/lang/fr.php @@ -24,6 +24,7 @@ $lang->null = 'Null'; $lang->ellipsis = '…'; $lang->percent = '%'; $lang->dash = '-'; +$lang->slash = '/'; $lang->and = 'and'; $lang->to = 'To'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index 4b76b486d0..7bf18b182a 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -24,6 +24,7 @@ $lang->null = '空'; $lang->ellipsis = '…'; $lang->percent = '%'; $lang->dash = '-'; +$lang->slash = '/'; $lang->and = '和'; $lang->to = '至'; diff --git a/module/testtask/control.php b/module/testtask/control.php index 6ecd39c93b..dcdcec4ef9 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -1321,12 +1321,15 @@ class testtask extends control if($this->post->results) { $this->testtask->batchRun($from, $taskID); + $this->loadModel('action'); foreach(array_keys($this->post->results) as $caseID) $this->action->create('case', $caseID, 'run', '', $taskID); - return print(js::locate($url, 'parent')); + + return $this->send(array('result' => 'success', 'load' => $url)); } if(!$this->post->caseIdList) return print(js::locate($url, 'parent')); + $caseIdList = array_unique($this->post->caseIdList); /* The case of tasks of qa. */ diff --git a/module/testtask/js/batchrun.ui.js b/module/testtask/js/batchrun.ui.js new file mode 100644 index 0000000000..4d9f5267fa --- /dev/null +++ b/module/testtask/js/batchrun.ui.js @@ -0,0 +1,68 @@ +function toggleAction() +{ + const result = $(this).val(); + const stepsOrReals = $(this).parents('tr').find('table .steps, table .reals'); + if(result == 'pass') + { + stepsOrReals.addClass('hidden'); + + stepsOrReals.find('select[id^=steps]').val(result); + if(stepsOrReals.parent().prop('tagName') == 'TR') + { + stepsOrReals.closest('tbody').children('tr').each(function() + { + var $td = $(this).children('td').first(); + if($td.attr('colspan') != undefined) $td.attr('colspan', 2); + }); + } + } + else + { + stepsOrReals.removeClass('hidden'); + + stepsOrReals.find('select[id^=steps]').eq(-1).val(result); + + if(stepsOrReals.parent().prop('tagName') == 'TR') + { + stepsOrReals.closest('tbody').children('tr').each(function() + { + var $td = $(this).children('td').first(); + if($td.attr('colspan') != undefined) $td.attr('colspan', 4); + }); + } + } +} + +$(function() +{ + /* Readjust precondition width by cases precondition. */ + preconditionThWidth = $('th.precondition').width(); + $preconditionTD = $('tbody td.precondition'); + preconditionTdLength = $preconditionTD.length; + + for(i = 0; i < preconditionTdLength; i++) + { + preconditionTextWidth = $preconditionTD.eq(i).find('span').first().width(); + if(preconditionTextWidth > preconditionThWidth) + { + preconditionThWidth = preconditionTextWidth; + if(preconditionThWidth > 200) preconditionThWidth = 200; + + $('th.precondition').width(preconditionThWidth); + } + } +}) + +function toggleStep() +{ + var stepSelect = $(this).parent().prev().find('select'); + + if($(this).val() == '' && stepSelect.val() == 'fail') + { + stepSelect.val('pass'); + } + else if($(this).val() != '' && stepSelect.val() == 'pass') + { + stepSelect.val('fail'); + } +} diff --git a/module/testtask/ui/batchrun.html.php b/module/testtask/ui/batchrun.html.php new file mode 100644 index 0000000000..1a5fb906ab --- /dev/null +++ b/module/testtask/ui/batchrun.html.php @@ -0,0 +1,206 @@ + + * @package testtask + * @link https://www.zentao.net + */ +namespace zin; + +$caseItems = array(); +foreach($cases as $caseID => $case) +{ + if($case->auto == 'auto' && $confirm == 'yes') continue; + if($case->status == 'wait') continue; + + $stepItems = array(); + if(!empty($steps[$caseID])) + { + $stepId = $childId = 0; + foreach($steps[$caseID] as $stepID => $step) + { + if($step->type == 'group' || $step->type == 'step') + { + $stepId ++; + $childId = 0; + } + $currentID = $step->type == 'item' ? "{$stepId}.{$childId}" : $stepId; + $stepClass = $step->type == 'item' ? 'step-item pl-2' : 'step-group'; + + $stepItems[] = h::tr + ( + h::td + ( + set::width('30%'), + set::class('break-words'), + set::colspan($step->type == 'group' ? 2 : 1), + span + ( + set::class($stepClass), + set::hint(true), + $currentID . '、' . $step->desc + ) + ), + $step->type != 'group' ? h::td + ( + set::width('30%'), + set::class('break-words'), + span + ( + set::hint(true), + $lang->testcase->stepExpect . ':' . $step->expect + ) + ) : null, + $step->type != 'group' ? h::td + ( + set::width('90px'), + set::class("hidden steps"), + select + ( + set::name("steps[$caseID][$stepID]"), + set::items($lang->testcase->resultList), + set::value('pass'), + ) + ) : null, + $step->type != 'group' ? h::td + ( + set::class("hidden reals"), + input + ( + set::name("reals[$caseID][$stepID]") + ) + ) : null, + ); + $childId ++; + } + } + + $caseItems[] = h::tr + ( + h::td + ( + !$productID ? input + ( + set::type('hidden'), + set::name("caseIDList[{$caseID}]"), + set::value($caseID) + ) : null, + $caseID, + input + ( + set::type('hidden'), + set::name("version[$caseID]"), + set::value($case->version) + ) + ), + h::td + ( + h::span + ( + set::hint(true), + $moduleOptionMenu[$case->module] + ) + ), + h::td + ( + set::class('break-words'), + h::span + ( + set::hint(true), + $case->title, + ) + ), + h::td + ( + set::class('precondition break-words'), + span + ( + set::hint(true), + $case->precondition, + ) + ), + h::td + ( + radioList + ( + set::primary(true), + set::name("results[$caseID]"), + set::value('pass'), + set::inline(false), + set::items($lang->testcase->resultList), + ) + ), + h::td + ( + set::class(empty($steps[$caseID]) ? 'hidden reals' : ''), + !empty($steps[$caseID]) ? h::table + ( + set::class('table bordered'), + $stepItems + ) : null, + empty($steps[$caseID]) ? input + ( + set::name("reals[$caseID][]") + ) : null, + ) + ); +} +formPanel +( + set::title(($from == 'testtask' ? $lang->testtask->common . $lang->colon : '') . $lang->testtask->batchRun), + set::width('auto'), + + on::click('[name^=results]', 'toggleAction'), + on::keyup('[name^=reals]', 'toggleStep'), + + h::table + ( + set::class('table bordered'), + h::thead + ( + h::tr + ( + h::th + ( + set::width('60px'), + $lang->idAB + ), + h::th + ( + set::width('100px'), + $lang->testcase->module + ), + h::th + ( + set::width('200px'), + $lang->testcase->title + ), + h::th + ( + set::width('100px'), + set::class('precondition'), + $lang->testcase->precondition + ), + h::th + ( + set::width('100px'), + $lang->testcase->result + ), + h::th + ( + $lang->testcase->stepDesc . $lang->slash . $lang->testcase->stepExpect + ), + ) + ), + h::tbody + ( + $caseItems + ) + ) +); + +render(); +