diff --git a/module/story/test/lib/ui/tasks.ui.class.php b/module/story/test/lib/ui/tasks.ui.class.php new file mode 100644 index 0000000000..591e8e6a32 --- /dev/null +++ b/module/story/test/lib/ui/tasks.ui.class.php @@ -0,0 +1,80 @@ +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测试通过'); + } +} diff --git a/module/story/test/ui/page/tasks.php b/module/story/test/ui/page/tasks.php new file mode 100644 index 0000000000..d04d9af3e0 --- /dev/null +++ b/module/story/test/ui/page/tasks.php @@ -0,0 +1,22 @@ +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); + } +} diff --git a/module/story/test/ui/tasks.php b/module/story/test/ui/tasks.php new file mode 100755 index 0000000000..6ed2c8b92c --- /dev/null +++ b/module/story/test/ui/tasks.php @@ -0,0 +1,88 @@ +#!/usr/bin/env php +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();