From 7ae1b6f1af70d76a8993efc7fa99a9dbc1527f6e Mon Sep 17 00:00:00 2001 From: yulujie Date: Thu, 24 Apr 2025 09:41:51 +0800 Subject: [PATCH] * [task#142427,doing,7h,1h] Add ui test function of create execution in lite. --- .../test/lib/createInLite.ui.class.php | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100755 module/execution/test/lib/createInLite.ui.class.php diff --git a/module/execution/test/lib/createInLite.ui.class.php b/module/execution/test/lib/createInLite.ui.class.php new file mode 100755 index 0000000000..07926ee3d4 --- /dev/null +++ b/module/execution/test/lib/createInLite.ui.class.php @@ -0,0 +1,160 @@ +initForm('execution', 'create', '', 'appIframe-project'); + $form->wait(1); + 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['code'])) $form->dom->code->setValue($execution['code']); + if(isset($execution['begin'])) $form->dom->begin->datePicker($execution['begin']); + if(isset($execution['end'])) $form->dom->end->datePicker($execution['end']); + $form->dom->btn($this->lang->save)->click(); + $form->wait(1); + } + + /** + * 看板名称、看板代号已存在时获取提示信息。 + * Get error info of repeat name. + * + * @param string $field name|code + * @access public + * @return bool + */ + public function checkRepeatInfo($field) + { + $form = $this->loadPage(); + $text = $form->dom->{$field . 'Tip'}->getText(); + if($field == 'name') $info = sprintf($this->lang->error->repeat, $this->lang->kanban->name, $form->dom->name->getValue()); + if($field == 'code') $info = sprintf($this->lang->error->repeat, $this->lang->kanban->common . $this->lang->code, $form->dom->code->getValue()); + + if($text == $info) return true; + return false; + } + + /** + * 计划起止日期错误时获取提示信息。 + * 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') + { + $text = $form->dom->beginTip->getText(); + if($this->config->default->lang == 'zh-cn') $info = '看板开始日期应大于等于项目的开始日期:。'; + if($this->config->default->lang == 'en') $info = 'The start date of Kanban should be ≥ the start date of Project : .'; + } + else + { + $text = $form->dom->endTip->getText(); + if($this->config->default->lang == 'zh-cn') $info = '看板截止日期应小于等于项目的截止日期:。'; + if($this->config->default->lang == 'en') $info = 'The deadline of Kanban should be ≤ the deadline of Project : .'; + } + + /* 获取页面返回信息中除日期外的内容 */ + 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 true; + return false; + } + + /** + * 创建看板。 + * Create a new execution . + * + * @param array $execution + * @param string $module execution|kanban + * @access public + * @return object + */ + public function create($execution, $module = 'execution') + { + $this->switchVision('lite'); + $this->inputFields($execution); + + /* 创建成功会跳转至看板列表全部标签下,从url中获取status字段内容 */ + $url = explode('status=', $this->response('url')); + /* 根据url中是否包含status,判断是否创建成功 */ + if(!isset($url[1])) + { + if($this->checkFormTips($module)) return $this->success('创建看板表单页提示信息正确'); + return $this->failed('创建看板表单页提示信息不正确'); + } + return $this->success('创建执行成功'); + } + + /** + * 看板名称、看板代号为空创建执行。 + * + * @param array $execution + * @param string $field + * @access public + * @return object + */ + public function createWithEmptyName($execution, $field) + { + $this->switchVision('lite'); + $this->inputFields($execution); + $form = $this->loadPage(); + $text = $form->dom->{$field . 'Tip'}->getText(); + if($field == 'name') $info = sprintf($this->lang->error->notempty, $this->lang->kanban->name); + if($field == 'code') $info = sprintf($this->lang->error->notempty, $this->lang->kanban->common . $this->lang->code); + + if($text == $info) return $this->success('创建看板表单页提示信息正确'); + return $this->failed('创建看板表单页提示信息不正确'); + } + + /** + * 看板名称、看板代号已存在创建执行。 + * Create execution with repeat name or code. + * + * @param array $execution + * @param string $field name|code + * @access public + * @return object + */ + public function createWithRepeatName($execution, $field) + { + $this->switchVision('lite'); + $this->inputFields($execution); + if($this->checkRepeatInfo($field)) return $this->success('创建看板表单页提示信息正确'); + return $this->failed('创建看板表单页提示信息不正确'); + } + + /** + * 看板起止日期错误创建看板。 + * Create execution with date error. + * + * @param array $execution + * @param string $dateType begin|end + * @access public + * @return object + */ + public function createWithDateError($execution, $dateType = 'end') + { + $this->switchVision('lite'); + $this->inputFields($execution); + if($this->checkDateInfo($dateType)) return $this->success('创建看板表单页提示信息正确'); + return $this->failed('创建看板表单页提示信息不正确'); + } +}