* [refac bug #56210,55424] Confirm for import exist case from xmind.
This commit is contained in:
@@ -1792,9 +1792,13 @@ class testcase extends control
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$productID = (int)$this->post->productID;
|
||||
$branch = $this->post->branch;
|
||||
$isInsert = (bool)$this->post->insert;
|
||||
$sceneList = json_decode($this->post->sceneList, true);
|
||||
$testcaseList = json_decode($this->post->testcaseList, true);
|
||||
$cases = $this->testcaseZen->buildCasesByXmind($testcaseList);
|
||||
|
||||
$cases = $this->testcaseZen->buildCasesByXmind($productID, $branch, $testcaseList, $isInsert);
|
||||
$result = $this->testcase->saveXmindImport($sceneList, $cases);
|
||||
if($result['result'] == 'success') $result['load'] = $this->createLink('testcase', 'browse');
|
||||
return $this->send($result);
|
||||
|
||||
@@ -41,17 +41,51 @@ $(document).ready(function()
|
||||
return;
|
||||
}
|
||||
|
||||
var sceneList = JSON.stringify(data.sceneList);
|
||||
var testcaseList = JSON.stringify(data.testcaseList);
|
||||
var hasExist = false;
|
||||
for(i in data.sceneList)
|
||||
{
|
||||
if(hasExist) break;
|
||||
|
||||
var form = new FormData();
|
||||
form.append("sceneList", sceneList);
|
||||
form.append("testcaseList", testcaseList);
|
||||
var scene = data.sceneList[i];
|
||||
if(typeof(scene.id) != 'undefined') hasExist = true;
|
||||
}
|
||||
for(i in data.testcaseList)
|
||||
{
|
||||
if(hasExist) break;
|
||||
|
||||
$.ajaxSubmit({url: $.createLink('testcase', 'saveXmindImport'), data: form});
|
||||
var testcase = data.testcaseList[i];
|
||||
if(typeof(testcase.id) != 'undefined') hasExist = true;
|
||||
}
|
||||
|
||||
if(hasExist)
|
||||
{
|
||||
var confirmActions = [{btnType: 'primary', class: 'btn-wide', key: 'confirm', text: importAndCoverLang}, {class: 'btn-wide', key: 'cancel', text: importAndInsertLang}];
|
||||
zui.Modal.confirm({message: noticeImport, actions: confirmActions}).then((confirmed) => {submitXmindImport(data, confirmed ? 0 : 1);})
|
||||
return;
|
||||
}
|
||||
|
||||
submitXmindImport(data);
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
function submitXmindImport(data, insert)
|
||||
{
|
||||
if(typeof(insert) == 'undefined') insert = 1;
|
||||
|
||||
var sceneList = JSON.stringify(data.sceneList);
|
||||
var testcaseList = JSON.stringify(data.testcaseList);
|
||||
|
||||
var form = new FormData();
|
||||
form.append("insert", insert);
|
||||
form.append("productID", productID);
|
||||
form.append("branch", branch);
|
||||
form.append("sceneList", sceneList);
|
||||
form.append("testcaseList", testcaseList);
|
||||
|
||||
$.ajaxSubmit({url: $.createLink('testcase', 'saveXmindImport'), data: form});
|
||||
}
|
||||
|
||||
function setStories(){
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@@ -2172,7 +2172,7 @@ class testcaseModel extends model
|
||||
|
||||
foreach($testcases as $testcase)
|
||||
{
|
||||
$result = $this->saveTestcase($testcase, $sceneIDList);
|
||||
$result = $this->saveTestcase($testcase, $sceneIDList);
|
||||
if($result['result'] == 'fail')
|
||||
{
|
||||
$this->dao->rollBack();
|
||||
|
||||
@@ -16,7 +16,10 @@ jsVar('userConfig_scene', $settings['scene']);
|
||||
jsVar('userConfig_case', $settings['case']);
|
||||
jsVar('userConfig_pri', $settings['pri']);
|
||||
jsVar('userConfig_group', $settings['group']);
|
||||
jsVar('jsLng', $this->lang->testcase->jsLng);
|
||||
jsVar('jsLng', $lang->testcase->jsLng);
|
||||
jsVar('noticeImport', $lang->noticeImport);
|
||||
jsVar('importAndCoverLang', $lang->importAndCover);
|
||||
jsVar('importAndInsertLang', $lang->importAndInsert);
|
||||
|
||||
$nodeTemplate =
|
||||
"<div data-toggle='tooltip' data-placement='bottom' id='node-{id}' class='mindmap-node' data-type='{type}' data-id='{id}' data-parent='{parent}'>" .
|
||||
|
||||
+12
-6
@@ -1562,11 +1562,14 @@ class testcaseZen extends testcase
|
||||
* 根据 xmind 构建导入用例的数据。
|
||||
* Build imported cases by xmind data.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param string $branch
|
||||
* @param array $caseList
|
||||
* @param bool $isInsert
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function buildCasesByXmind(array $caseList): array
|
||||
protected function buildCasesByXmind(int $productID, string $branch, array $caseList, bool $isInsert): array
|
||||
{
|
||||
$caseIdList = array_filter(array_map(function($case){return zget($case, 'id', 0);}, $caseList));
|
||||
$now = helper::now();
|
||||
@@ -1574,14 +1577,17 @@ class testcaseZen extends testcase
|
||||
$account = $this->app->user->account;
|
||||
$oldCases = $this->testcase->getByList($caseIdList);
|
||||
$oldSteps = $this->testcase->fetchStepsByList($caseIdList);
|
||||
$branch = (int)$branch;
|
||||
$modules = $this->loadModel('tree')->getOptionMenu($productID, 'case');
|
||||
|
||||
$cases = array();
|
||||
foreach($caseList as $caseData)
|
||||
{
|
||||
$case = new stdclass();
|
||||
$case->module = $caseData['module'];
|
||||
$case->product = $caseData['product'];
|
||||
$case->branch = zget($caseData, 'branch', 0);
|
||||
$moduleID = (int)$caseData['module'];
|
||||
$case = new stdclass();
|
||||
$case->module = isset($modules[$moduleID]) ? $moduleID : 0;
|
||||
$case->product = $productID;
|
||||
$case->branch = $branch;
|
||||
$case->title = $caseData['name'];
|
||||
$case->pri = $caseData['pri'];
|
||||
$case->tmpPId = $caseData['tmpPId'];
|
||||
@@ -1592,7 +1598,7 @@ class testcaseZen extends testcase
|
||||
$caseID = (int)zget($caseData, 'id', 0);
|
||||
$oldCase = zget($oldCases, $caseID, null);
|
||||
|
||||
if(empty($oldCase))
|
||||
if(empty($oldCase) || $isInsert)
|
||||
{
|
||||
$case->type = 'feature';
|
||||
$case->status = !$forceNotReview ? 'wait' : 'normal';
|
||||
|
||||
Reference in New Issue
Block a user