Merge branch release/21.7.7 of zentao/zentaopms (#12509)

This commit is contained in:
李阳
2025-11-24 17:12:26 +08:00
committed by Gitfox
3 changed files with 190 additions and 0 deletions
@@ -0,0 +1,80 @@
<?php
require_once dirname(__FILE__, 6) . '/test/lib/ui.php';
define('HEADERS', ['id','name','pri','status','assignedTo','estimate','consumed','left','progress']);
class tasksTester extends tester
{
/**
* 验证任务列表页
* Verify product tasks view
*
* @param int $storyID 需求ID
* @param int $executionID 执行ID
* @return 成功或者失败对象
*/
public function verifyTasksView($storyID, $executionID = 0)
{
$this->login();
$form = $this->initForm('story', 'tasks', array('storyID' => $storyID, 'executionID' => $executionID), 'appIframe-product');
$form->wait(2);
$displayed = new stdClass();
foreach(HEADERS as $c)
{
$displayed->$c = $form->dom->getElementListByXpathKey($c, true);
if(empty($displayed->$c)) return $this->failed("任务页列{$c}无内容");
}
global $uiTester;
$rows = $uiTester->dao->select('id,name,assignedTo,pri,status,estimate,consumed,`left`')
->from(TABLE_TASK)
->where('story')->eq($storyID)
->andWhere('execution')->eq($executionID)
->andWhere('deleted')->eq('0')
->fetchAll();
$users = $uiTester->dao->select('account,realname')->from(TABLE_USER)->fetchPairs('account','realname');
$expectedCount = count($rows);
if($expectedCount == 0) return $this->failed('数据库无任务数据');
if(count($displayed->id) != $expectedCount) return $this->failed('任务数量不匹配');
$byTaskName = array();
foreach($rows as $r) $byTaskName[$r->name] = $r;
$statusMap = (array)$this->lang->task->statusList;
for($i = 0; $i < $expectedCount; $i++)
{
$row = $byTaskName[$displayed->name[$i]];
foreach(HEADERS as $c)
{
switch($c)
{
case 'progress':
$expectProgress = '';
if((float)$row->left > 0)
{
$sum = (float)$row->consumed + (float)$row->left;
$expectProgress = (string)(round(((float)$row->consumed / $sum), 2) * 100);
}
else $expectProgress = ((float)$row->consumed == 0) ? '0' : '100';
if($displayed->$c[$i] !== $expectProgress) return $this->failed("第{$i}条任务{$c}不匹配");
break;
case 'status':
$expectStatus = isset($statusMap[$row->status]) ? $statusMap[$row->status] : $row->status;
if($displayed->$c[$i] !== $expectStatus) return $this->failed("第{$i}条任务{$c}不匹配");
break;
case 'assignedTo':
$expectUser = isset($users[$row->assignedTo]) ? $users[$row->assignedTo] : $row->assignedTo;
if($displayed->$c[$i] !== $expectUser) return $this->failed("第{$i}条任务{$c}不匹配");
break;
default:
if($displayed->$c[$i] !== (string)$row->$c) return $this->failed("第{$i}条任务{$c}不匹配");
break;
}
}
}
return $this->success('开源版m=story&f=tasks测试通过');
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
class tasksPage extends page
{
public function __construct($webdriver)
{
parent::__construct($webdriver);
$this->xpath = array(
'id' => "//div[@data-col='id' and @data-row!='HEADER']",
'name' => "//div[@data-col='name' and @data-row!='HEADER']",
'pri' => "//div[@data-col='pri' and @data-row!='HEADER']",
'status' => "//div[@data-col='status' and @data-row!='HEADER']",
'assignedTo' => "//div[@data-col='assignedTo' and @data-row!='HEADER']",
'estimate' => "//div[@data-col='estimate' and @data-row!='HEADER']",
'consumed' => "//div[@data-col='consumed' and @data-row!='HEADER']",
'left' => "//div[@data-col='left' and @data-row!='HEADER']",
'progress' => "//div[@data-col='progress' and @data-row!='HEADER']",
);
$this->dom->xpath = array_merge($this->dom->xpath, $this->xpath);
}
}
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 2) . '/lib/ui/tasks.ui.class.php';
/**
title=开源版m=story&f=tasks测试
timeout=0
cid=1
- 开源版m=story&f=tasks测试
- 最终测试状态 @SUCCESS
- 测试结果 @开源版m=story&f=tasks测试通过
*/
$projectMain = zenData('project');
$projectMain->id->range('1');
$projectMain->name->range('项目1');
$projectMain->type->range('project');
$projectMain->multiple->range('1');
$projectMain->vision->range('rnd');
$projectMain->isTpl->range('0');
$projectMain->status->range('doing');
$projectMain->gen(1);
$execution = zenData('project');
$execution->id->range('101');
$execution->name->range('迭代1');
$execution->project->range('1');
$execution->type->range('sprint');
$execution->multiple->range('1');
$execution->vision->range('rnd');
$execution->isTpl->range('0');
$execution->status->range('doing');
$execution->gen(1, false);
$team = zenData('team');
$team->id->range('1');
$team->root->range('101');
$team->type->range('execution');
$team->account->range('admin');
$team->role->range('dev');
$team->join->range('`2025-10-01`');
$team->days->range('10');
$team->hours->range('8');
$team->gen(1);
$story = zenData('story');
$story->id->range('1');
$story->product->range('1');
$story->title->range('需求1');
$story->status->range('active');
$story->version->range('1');
$story->vision->range('rnd');
$story->openedBy->range('admin');
$story->openedDate->range('`2025-11-01 09:00:00`');
$story->assignedTo->range('admin');
$story->stage->range('wait');
$story->gen(1);
$task = zenData('task');
$task->id->range('1-8');
$task->name->range('1-8')->prefix('任务');
$task->type->range('devel');
$task->pri->range('1,2,3,4');
$task->estimate->range('1,2,4,8');
$task->consumed->range('0,1,2,4');
$task->left->range('0,1,2,4');
$task->status->range('wait{2},doing{2},done{2},closed{2}');
$task->project->range('1');
$task->execution->range('101');
$task->story->range('1');
$task->storyVersion->range('1');
$task->assignedTo->range('admin');
$task->assignedDate->range('`2025-11-02 10:00:00`');
$task->openedBy->range('admin');
$task->openedDate->range('`2025-11-02 10:00:00`');
$task->lastEditedBy->range('admin');
$task->lastEditedDate->range('`2025-11-03 09:00:00`');
$task->vision->range('rnd');
$task->deadline->range('`2025-11-30`');
$task->gen(8);
$tester = new tasksTester();
r($tester->verifyTasksView(1, 101)) && p('status,message') && e('SUCCESS,开源版m=story&f=tasks测试通过'); // 开源版m=story&f=tasks测试
$tester->closeBrowser();