diff --git a/module/testcase/control.php b/module/testcase/control.php index ed3b5eac85..53809895dc 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -232,6 +232,7 @@ class testcase extends control $this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'case', $showModule) : array(); $this->view->showBranch = $showBranch; $this->view->libraries = $this->loadModel('caselib')->getLibraries(); + $this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID); $this->display(); } diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index 7f3892d8f7..cb32e80ab9 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -285,17 +285,38 @@ js::set('cancelURL', $this->createLink('testtask', 'batchRun', "productID=$ diff --git a/module/testtask/control.php b/module/testtask/control.php index 39260011f4..87d6e331dd 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -579,6 +579,7 @@ class testtask extends control $this->view->suites = $this->loadModel('testsuite')->getSuitePairs($productID); $this->view->suiteName = isset($suiteName) ? $suiteName : $this->lang->testtask->browseBySuite; $this->view->canBeChanged = $canBeChanged; + $this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID); $this->display(); } @@ -1233,7 +1234,7 @@ class testtask extends control $confirmURL = inlink('runCase', "runID=$runID&caseID=$caseID&version=$version&confirm=yes"); $cancelURL = inlink('runCase', "runID=$runID&caseID=$caseID&version=$version&confirm=no"); - if($automation and $confirm == '') return print(js::confirm($this->lang->zanode->runCaseConfirm, $confirmURL, $cancelURL)); + if($automation and $confirm == '' and $run->case->auto == 'auto') return print(js::confirm($this->lang->zanode->runCaseConfirm, $confirmURL, $cancelURL)); if($confirm == 'yes') { $resultID = $this->testtask->initResult($runID, $caseID, $run->case->version, $automation->node); @@ -1326,11 +1327,6 @@ class testtask extends control if($this->post->results) { - if($confirm == 'yes') - { - $this->post->set('node', $automation->node); - $this->post->set('automation', $automation->id); - } $this->testtask->batchRun($from, $taskID); $this->loadModel('action'); foreach(array_keys($this->post->results) as $caseID) $this->action->create('case', $caseID, 'run', '', $taskID); diff --git a/module/testtask/model.php b/module/testtask/model.php index 5677fbcd52..07e71b7d35 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -1351,15 +1351,8 @@ class testtaskModel extends model $result->stepResults = serialize($stepResults); $result->lastRunner = $this->app->user->account; $result->date = $now; - if(isset($postData->node)) $result->node = $postData->node; $this->dao->insert(TABLE_TESTRESULT)->data($result)->autoCheck()->exec(); - if(!dao::isError() and isset($postData->node)) - { - $resultID = $this->dao->lastInsertID(); - $this->loadModel('zanode')->runZTFScript($postData->automation, $caseID, $resultID); - } - $this->dao->update(TABLE_CASE)->set('lastRunner')->eq($this->app->user->account)->set('lastRunDate')->eq($now)->set('lastRunResult')->eq($caseResult)->where('id')->eq($caseID)->exec(); if($runID) @@ -1479,7 +1472,7 @@ class testtaskModel extends model } /* Get files of step result. */ - foreach($result->stepResults as $stepID => $stepResult) $result->stepResults[$stepID]['files'] = isset($stepFiles[$resultID][$stepID]) ? $stepFiles[$resultID][$stepID] : array(); + if(!empty($result->stepResults)) foreach($result->stepResults as $stepID => $stepResult) $result->stepResults[$stepID]['files'] = isset($stepFiles[$resultID][$stepID]) ? $stepFiles[$resultID][$stepID] : array(); } return $results; } diff --git a/module/testtask/view/cases.html.php b/module/testtask/view/cases.html.php index e2ff3219cd..4bd6e18c1c 100644 --- a/module/testtask/view/cases.html.php +++ b/module/testtask/view/cases.html.php @@ -166,19 +166,39 @@ if($shortcut.size() > 0) $(function(){$('#casesForm').table();}) $("thead").find('.c-assignedTo').attr('class', ''); -function confirmAction() +function runAutocase() +{ + var caseIDList = []; + $.each($('input[name^=caseIDList]:checked'),function(){ + caseIDList.push($(this).val()); + }); + + var url = createLink('zanode', 'ajaxRunZTFScript', 'scriptID=id;?>'); + + var postData = {'caseIDList' : caseIDList.join(',')}; + $.post(url, postData, function(result) + { + if(result.result == 'fail') + { + alert(result.message); + return false; + } + return true; + }, 'json'); +} + +function confirmAction(obj) { if(confirm(runCaseConfirm)) { - setFormAction(confirmURL, '', '#caseList'); + var result = runAutocase(); + if(result) setFormAction(confirmURL, '', '#caseList'); } else { setFormAction(cancelURL, '', '#caseList'); } - return false; } - diff --git a/module/testtask/view/results.html.php b/module/testtask/view/results.html.php index 378f510e8b..4fb93cf6dd 100644 --- a/module/testtask/view/results.html.php +++ b/module/testtask/view/results.html.php @@ -164,6 +164,7 @@ + stepResults)):?> stepResults as $stepID => $stepResult):?>