From a30f4acf0ddfe1514ee88d47274b7872e2e7ce14 Mon Sep 17 00:00:00 2001 From: yulujie Date: Thu, 3 Jul 2025 17:18:45 +0800 Subject: [PATCH] *[task#146066,doing,5h,1h] Add function. --- .../test/lib/editexecution.ui.class.php | 146 ++++++++++++++++-- 1 file changed, 136 insertions(+), 10 deletions(-) diff --git a/module/execution/test/lib/editexecution.ui.class.php b/module/execution/test/lib/editexecution.ui.class.php index d24baf67fe..16aeb8e239 100644 --- a/module/execution/test/lib/editexecution.ui.class.php +++ b/module/execution/test/lib/editexecution.ui.class.php @@ -11,19 +11,96 @@ class editExecutionTester extends tester */ public function editFields($execution) { - $form = $this->initForm('execution', 'view', array('execution' => '2'), 'appIframe-execution'); + $form = $this->initForm('execution', 'view', array('execution' => $execution['id']), 'appIframe-execution'); $form->wait(1); $form->dom->edit->click(); - if(isset($execution['project'])) $form->dom->project->picker($execution['project']); $form = $this->loadPage(); $form->wait(1); - if(isset($execution['name'])) $form->dom->name->setValue($execution['name']); - if(isset($execution['begin'])) $form->dom->begin->datePicker($execution['begin']); - if(isset($execution['end'])) $form->dom->end->datePicker($execution['end']); + if(isset($execution['name'])) $form->dom->name->setValue($execution['name']); + if(isset($execution['begin'])) $form->dom->begin->datePicker($execution['begin']); + if(isset($execution['end'])) $form->dom->end->datePicker($execution['end']); if(isset($execution['products'])) $form->dom->products->picker($execution['products']); $form->dom->submit->click(); $form->wait(1); - return $form; + } + + /** + * 执行名称已存在时获取提示信息。 + * Get error info of repeat name. + * + * @param string $type sprint|stage|kanban + * @access public + * @return bool + */ + public function checkRepeatInfo($type = 'sprint') + { + $form = $this->loadPage(); + $form->wait(1); + if(!is_object($form->dom->nameTip)) return $this->failed('执行名称重复没有提示信息'); + $text = $form->dom->nameTip->getText(); + if($type == 'kanban') + { + $info = sprintf($this->lang->error->repeat, $form->dom->nameLabel->getText(), $form->dom->name->getValue()); + } + else + { + $info = sprintf($this->lang->error->repeat, $form->dom->nameLabel->getText(), $form->dom->name->getValue()); + } + if($text != $info) return $this->failed('编辑执行表单页提示信息不正确'); + return $this->success('编辑执行表单页提示信息正确'); + } + + /** + * 计划起止日期错误时获取提示信息。 + * Get error info of begin and end date. + * + * @param string $dateType begin|end + * @access public + * @return bool + */ + public function checkDateInfo($dateType = 'end') + { + $form = $this->loadPage(); + $form->wait(1); + + if($dateType == 'begin') + { + if(!is_object($form->dom->beginTip)) return $thid->failed('开始日期错误没有提示信息'); + $text = $form->dom->beginTip->getText(); + $info = sprintf($this->lang->execution->errorCommonBegin, ''); + } + else + { + if(!is_object($form->dom->endTip)) return $thid->failed('完成日期错误没有提示信息'); + $text = $form->dom->endTip->getText(); + $info = sprintf($this->lang->execution->errorCommonEnd, ''); + } + + /* 获取页面返回信息中除日期外的内容 */ + preg_match_all('/(\d{4}-\d{2}-\d{2})/', $text, $matches); + $date = $matches[0]; + $params = str_replace($date, '', $text); + $params = trim($params); + + if($params != $info) return $this->failed('编辑执行表单页提示信息不正确'); + return $this->success('编辑执行表单页提示信息正确'); + } + + /** + * 关联产品必填时获取提示信息。 + * Get error info of manage products. + * + * @access public + * @return bool + */ + public function checkManageProductsInfo() + { + $form = $this->loadPage(); + $form->dom->waitElement($form->dom->xpath['productsTip'], 10); + $text = $form->dom->productsTip->getText(); + $info = $this->lang->project->errorNoProducts; + if($text != $info) return $this->failed('编辑执行表单页提示信息不正确'); + return $this->success('编辑执行表单页提示信息正确'); } /** @@ -38,12 +115,61 @@ class editExecutionTester extends tester { $form = $this->editFields($execution); /* 根据编辑弹窗中的保存按钮是否存在,判断是否编辑成功 */ - if($form->dom->submit === true) return $this->failed("编辑执行失败"); + if(is_object($form->dom->submit)) return $this->failed("编辑执行失败"); /* 查看相关内容是否正确 */ $viewPage = $this->loadPage('execution', 'view'); - if(isset($execution['name']) && ($viewPage->dom->executionName->getText() != $execution['name'])) return $this->failed('编辑后执行名称错误'); - if(isset($execution['begin']) && ($viewPage->dom->plannedBegin->getText() != $execution['begin'])) return $this->failed('编辑后计划开始时间错误'); - if(isset($execution['end']) && ($viewPage->dom->plannedEnd->getText() != $execution['end'])) return $this->failed('编辑后计划完成时间错误'); + $viewPage->wait(1); + if($this->checkFormTips('execution')) return $this->success('编辑执行表单页提示信息正确'); + if(isset($execution['name']) && ($viewPage->dom->executionName->getText() != $execution['name'])) return $this->failed('编辑后执行名称错误'); + if(isset($execution['begin']) && ($viewPage->dom->plannedBegin->getText() != $execution['begin'])) return $this->failed('编辑后计划开始时间错误'); + if(isset($execution['end']) && ($viewPage->dom->plannedEnd->getText() != $execution['end'])) return $this->failed('编辑后计划完成时间错误'); + if(isset($execution['status']) && ($viewPage->dom->status->getText() != $execution['status'])) return $this->failed('编辑后状态错误'); + if(isset($execution['product']) && ($viewPage->dom->linckedProducta->getText() != $execution['products'])) return $this->failed('编辑后产品错误'); return $this->success('编辑执行成功'); } + + /** + * 执行名称已存在编辑执行。 + * Edit execution with repeat name. + * + * @param array $execution + * @param string $type sprint|stage|kanban + * @access public + * @return object + */ + public function editWithRepeatName($execution, $type = 'sprint') + { + $this->editFields($execution); + return $this->checkRepeatInfo($type); + } + + /** + * 执行起止日期错误编辑执行。 + * Edit execution with date error. + * + * @param array $execution + * @param string $dateType begin|end + * @access public + * @return object + */ + public function editWithDateError($execution, $dateType = 'end') + { + $this->editFields($execution); + return $this->checkDateInfo($dateType); + } + + /** + * 执行关联产品必填,关联产品为空时编辑执行。 + * Edit execution with no manage products. + * + * @param array $execution + * @access public + * @return object + */ + public function editWithNoProducts($execution) + { + $this->editFields($execution); + return $this->checkManageProductsInfo(); + } + }