* Finish task #107892.

This commit is contained in:
tanghucheng
2023-12-15 01:06:57 -05:00
parent 0dc797b6db
commit 8415e68eaa
3 changed files with 114 additions and 21 deletions
+48 -10
View File
@@ -561,8 +561,52 @@ class testtask extends control
$sort = common::appendOrder($orderBy, 't2.id');
/* Get test cases. */
$runs = $this->testtask->getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task);
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
$runs = array();
$pager->pageID = $pageID; // 场景和用例混排,$pageID 可能大于场景分页后的总页数。在 pager 构造函数中会被设为 1,这里要重新赋值。
$scenes = $this->testcase->getSceneGroups($productID, $task->branch, $moduleID, '', $orderBy, $pager); // 获取包含子场景和用例的顶级场景树。
$recPerPage = $pager->recPerPage;
$sceneTotal = $pager->recTotal;
$sceneCount = count($scenes);
/* 场景条数小于每页记录数,继续获取用例。 */
if($sceneCount < $recPerPage)
{
/* 重置 $pager 属性,只获取需要的用例条数。*/
$pager->recTotal = 0;
$pager->pageID = 1; // 查询用例时的分页起始偏移量单独计算,每次查询的页码都设为 1 即可,后面会重新设置页码。
$pager->recPerPage = $recPerPage - $sceneCount; // 可能存在场景没排满一页,需要用例补全的情况。这里只查询需要补全的记录数。
if($sceneCount == 0) $pager->offset = $recPerPage * ($pageID - 1) - $sceneTotal; // 场景数为 0 表示本页查询只显示用例,需要计算用例分页的起始
$runs = $this->testtask->getTaskCases($productID, $browseType, $queryID, $moduleID, $sort, $pager, $task);
/* Process case for check story changed. */
$runs = $this->loadModel('story')->checkNeedConfirm($runs);
$runs = $this->testcase->appendData($runs, 'run');
foreach($runs as $runID => $run)
{
unset($runs[$runID]);
if($run->task != $taskID and $run->scene) continue;
$run->id = 'case_' . $run->case; // Add a prefix to avoid duplication with the scene ID.
$run->parent = 0;
$run->grade = 1;
$run->path = ',' . $run->case . ',';
$run->isScene = false;
$runs[$run->id] = $run;
}
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
}
/* 合并场景和用例的总记录数,并重新计算总页数和当前页码。*/
$pager->recTotal = $sceneTotal + count($runs);
$pager->recPerPage = $recPerPage;
$pager->pageTotal = ceil($pager->recTotal / $recPerPage);
$pager->pageID = $pageID;
$sceneRuns = $this->testcase->processSearchedData($scenes, $runs);
/* Build the search form. */
$this->loadModel('testcase');
@@ -584,22 +628,16 @@ class testtask extends control
$this->loadModel('search')->setSearchParams($this->config->testcase->search);
/* Append bugs and results. */
$runs = $this->testcase->appendData($runs, 'run');
$case2RunMap = array();
foreach($runs as $run) $case2RunMap[$run->case] = $run->id;
$showModule = $this->loadModel('setting')->getItem("owner={$this->app->user->account}&module=datatable&section=testtaskCases&key=showModule");
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases;
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
$this->view->position[] = $this->lang->testtask->common;
$this->view->position[] = $this->lang->testtask->cases;
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases;
$this->view->runs = $sceneRuns;
$this->view->productID = $productID;
$this->view->productName = $this->products[$productID];
$this->view->task = $task;
$this->view->runs = $runs;
$this->view->case2RunMap = $case2RunMap;
$this->view->users = $this->loadModel('user')->getPairs('noclosed|qafirst|noletter');
$this->view->assignedToList = $assignedToList;
+60
View File
@@ -14,3 +14,63 @@ td .warning {color: red;}
#modules .active {font-weight: bolder;}
.tree li > a.active {color: #0c64eb;}
body {margin-bottom: 25px;}
.w-220px {width: 220px;}
.w-170px {width: 170px;}
#createActionMenu .dropdown-menu {width: 100%;}
#caseForm table tbody tr td {overflow: hidden; white-space: nowrap;}
#caseForm .setting {height: 25px;}
#caseForm table tbody .c-name {overflow: hidden; padding-right: 65px;}
#caseForm table tbody .c-name a:first-child {overflow: hidden; display: inline-block; max-width: 100%;}
.dropdown-menu.with-search {padding: 0; min-width: 150px; overflow: hidden; max-height: 302px;}
.dropdown-menu > .menu-search .input-group {width: 100%;}
.dropdown-menu > .menu-search .input-group-addon {position: absolute; right: 10px; top: 0; z-index: 10; background: none; border: none; color: #666;}
.dropdown-menu > .menu-search .form-control {border: none !important; box-shadow: none !important; border-top: 1px solid #ddd !important;}
.dropdown-list {display: block; padding: 0; max-height: 270px; overflow-y: auto;}
.dropdown-list > li > a {display: block; padding: 3px 20px; clear: both; font-weight: normal; line-height: 1.53846154; color: #141414; white-space: nowrap;}
.dropdown-list > li > a:hover,
.dropdown-list > li > a:focus {color: #1a4f85; text-decoration: none; background-color: #ddd;}
.pl-5px {padding-left: 5px;}
tbody > tr > td > .btn-icon {margin-right: 3px;}
tbody > tr > td .icon-share {font-size: 9px;}
.table td.c-title > a:first-child {display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
#importToLib .select-lib {width: 100px; text-align: right;}
#subHeader #currentBranch + #dropMenu .col-left {padding-bottom: 30px;}
.status-blocked {left: -5px;}
#mainMenu .pull-left .dividing-line {margin: 7px 5px 0 0;}
.btn-toolbar>.btn, .btn-toolbar>.btn-group, .btn-toolbar>.dropdown {margin-right: 5px;}
#mainMenu > .btn-toolbar > .checkbox-primary{float: left;}
.table-nest-icon { cursor: pointer; }
.tr-moving { opacity: 0.3; }
.tr-acceptable { border: 2px solid rgba(255,0,0,0.5); }
.none-select { -webkit-user-select: none; -moz-user-select: none; -moz-user-select: none; user-select: none; }
.table-nest-toggle { vertical-align: middle; }
.table-nest-title .icon-test { pointer-events: none; }
.icon-test:after,.icon-ztf:after { border: 0px solid!important; }
#caseTableList.sortable-sorting > tr {opacity: 0.7}
#caseTableList.sortable-sorting > tr.drag-row {opacity: 1;}
#caseTableList > tr.drop-not-allowed {opacity: 0.1!important}
#caseList .c-actions {overflow: visible;}
#caseList > thead > tr > th .table-nest-toggle-global {top: 6px}
#caseList > thead > tr > th .table-nest-toggle-global:before {color: #a6aab8;}
#caseTableList > tr:last-child .c-actions .dropdown-menu {top: auto; bottom: 100%; margin-bottom: -5px;}
#caseTableList .icon-common:before {width: 22px; height: 22px; background: none; color: rgb(166, 170, 184); top: 0; line-height: 22px; margin-right: 2px; font-size: 14px}
#caseTableList .icon-project:before {content: '\e99c';}
#caseTableList .icon-test:before {content: '\e956';}
#caseTableList .icon-ztf:before {content: '\e9dd';}
#caseTableList .icon-waterfall:before {content: '\e9a4';}
#caseTableList .icon-kanban:before {content: '\e983';}
+6 -11
View File
@@ -11,7 +11,7 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/datatable.fix.html.php';?>
<?php include '../../testcase/view/datatable.fix.html.php';?>
<?php include './caseheader.html.php';?>
<?php js::set('confirmUnlink', $lang->testtask->confirmUnlinkCase)?>
<?php js::set('taskCaseBrowseType', ($browseType == 'bymodule' and $this->session->taskCaseBrowseType == 'bysearch') ? 'all' : $this->session->taskCaseBrowseType);?>
@@ -45,7 +45,8 @@
$datatableId = $this->moduleName . ucfirst($this->methodName);
$useDatatable = (isset($config->datatable->$datatableId->mode) and $config->datatable->$datatableId->mode == 'datatable');
?>
<form class='main-table table-cases' data-hot='true' method='post' name='casesform' id='casesForm' <?php if(!$useDatatable) echo "data-ride='table'";?>>
<form class='main-table table-case' data-nested='true' data-expand-nest-child='false' data-checkable='true' data-enable-empty-nested-row='true' data-replace-id='caseTableList' data-preserve-nested='true'
id='caseForm' method='post' <?php if(!$useDatatable) echo "data-ride='table'";?>>
<div class="table-header fixed-right">
<nav class="btn-toolbar pull-right"></nav>
</div>
@@ -62,15 +63,13 @@
if($useDatatable) include '../../common/view/datatable.html.php';
if(!$useDatatable) include '../../common/view/tablesorter.html.php';
$config->testcase->datatable->defaultField = $config->testtask->datatable->defaultField;
$config->testcase->datatable->fieldList['actions']['width'] = '120';
$setting = $this->datatable->getSetting('testtask');
$widths = $this->datatable->setFixedFieldWidth($setting);
$columns = 0;
?>
<?php if(!$useDatatable) echo '<div class="table-responsive">';?>
<table class='table has-sort-head<?php if($useDatatable) echo ' datatable';?>' id='caseList' data-fixed-left-width='<?php echo $widths['leftWidth']?>' data-fixed-right-width='<?php echo $widths['rightWidth']?>' data-checkbox-name='caseIDList[]'>
<table class='table has-sort-head table-fixed table-nested table has-sort-head<?php if($useDatatable) echo ' datatable';?>' id='caseList' data-fixed-left-width='<?php echo $widths['leftWidth']?>' data-fixed-right-width='<?php echo $widths['rightWidth']?>' data-checkbox-name='caseIDList[]'>
<thead>
<tr>
<?php
@@ -85,12 +84,8 @@
?>
</tr>
</thead>
<tbody>
<?php foreach($runs as $run):?>
<tr data-id='<?php echo $run->id?>' data-auto='<?php echo $run->auto;?>'>
<?php foreach($setting as $key => $value) $this->testtask->printCell($value, $run, $users, $task, $branches, $modulePairs, $useDatatable ? 'datatable' : 'table');?>
</tr>
<?php endforeach;?>
<tbody id='caseTableList'>
<?php $this->testcase->printRow($runs, $setting, $users, array(), $modulePairs, $browseType, $useDatatable ? 'datatable' : 'table');?>
</tbody>
</table>
<?php if(!$useDatatable) echo '</div>';?>