diff --git a/module/ai/test/lib/ai.unittest.class.php b/module/ai/test/lib/ai.unittest.class.php index 19bac5dac8..20bc500a35 100644 --- a/module/ai/test/lib/ai.unittest.class.php +++ b/module/ai/test/lib/ai.unittest.class.php @@ -994,4 +994,20 @@ class aiTest return $result; } + + /** + * Test togglePromptStatus method. + * + * @param int|object $prompt prompt (or id) to toggle. + * @param string $status optional, will set status to $status if provided. + * @access public + * @return mixed + */ + public function togglePromptStatusTest($prompt = null, $status = '') + { + $result = $this->objectModel->togglePromptStatus($prompt, $status); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/ai/test/model/togglepromptstatus.php b/module/ai/test/model/togglepromptstatus.php new file mode 100755 index 0000000000..9b84820fab --- /dev/null +++ b/module/ai/test/model/togglepromptstatus.php @@ -0,0 +1,52 @@ +#!/usr/bin/env php +id->range('1-10'); +$table->name->range('状态切换测试1,状态切换测试2,状态切换测试3,状态切换测试4,状态切换测试5,状态切换测试6,状态切换测试7,状态切换测试8,状态切换测试9,状态切换测试10'); +$table->desc->range('测试状态切换功能的提示词描述{10}'); +$table->model->range('1-3'); +$table->module->range('story{4},task{3},bug{3}'); +$table->source->range('story.title,task.name,bug.title'); +$table->targetForm->range('story.edit,task.edit,bug.edit'); +$table->purpose->range('测试状态切换目的{10}'); +$table->elaboration->range('测试状态切换详细说明{10}'); +$table->role->range('测试角色描述{10}'); +$table->characterization->range('测试角色特征{10}'); +$table->status->range('draft{5},active{5}'); +$table->createdBy->range('admin,user1,user2'); +$table->createdDate->range('`2023-08-10 10:00:00`,`2023-08-11 11:00:00`,`2023-08-12 12:00:00`'); +$table->deleted->range('0'); +$table->gen(10); + +// 3. 用户登录(选择合适角色) +su('admin'); + +// 4. 创建测试实例(变量名与模块名一致) +$aiTest = new aiTest(); + +// 5. 🔴 强制要求:必须包含至少5个测试步骤 +r($aiTest->togglePromptStatusTest(1, '')) && p() && e('1'); // 步骤1:使用ID切换draft状态prompt为active +r($aiTest->togglePromptStatusTest(6, '')) && p() && e('1'); // 步骤2:使用ID切换active状态prompt为draft +r($aiTest->togglePromptStatusTest($aiTest->getPromptByIdTest(2), '')) && p() && e('1'); // 步骤3:使用对象切换prompt状态 +r($aiTest->togglePromptStatusTest(3, 'active')) && p() && e('1'); // 步骤4:指定具体状态进行切换 +r($aiTest->togglePromptStatusTest(999, '')) && p() && e('0'); // 步骤5:测试不存在的prompt ID \ No newline at end of file diff --git a/module/ai/test/model/yaml/ai_prompt_togglepromptstatus.yaml b/module/ai/test/model/yaml/ai_prompt_togglepromptstatus.yaml new file mode 100644 index 0000000000..6d9e296411 --- /dev/null +++ b/module/ai/test/model/yaml/ai_prompt_togglepromptstatus.yaml @@ -0,0 +1,96 @@ +--- +title: AI Prompt状态切换测试数据 +desc: 为togglePromptStatus方法生成测试数据 +author: AI +version: 1.0 + +fields: +- field: id + note: 提示词ID + range: 1-10 + prefix: "" + postfix: "" + +- field: name + note: 提示词名称 + range: 状态切换测试1,状态切换测试2,状态切换测试3,状态切换测试4,状态切换测试5,状态切换测试6,状态切换测试7,状态切换测试8,状态切换测试9,状态切换测试10 + prefix: "" + postfix: "" + +- field: desc + note: 提示词描述 + range: [测试状态切换功能的提示词描述]{10} + prefix: "" + postfix: "" + +- field: model + note: 模型ID + range: 1,2,3 + prefix: "" + postfix: "" + +- field: module + note: 所属模块 + range: story{4},task{3},bug{3} + prefix: "" + postfix: "" + +- field: source + note: 数据源 + range: ',story.title,story.spec,',',task.name,task.desc,',',bug.title,bug.steps,' + prefix: "" + postfix: "" + +- field: targetForm + note: 目标表单 + range: story.edit,task.edit,bug.edit + prefix: "" + postfix: "" + +- field: purpose + note: 目的 + range: [测试状态切换目的]{10} + prefix: "" + postfix: "" + +- field: elaboration + note: 详细说明 + range: [测试状态切换详细说明]{10} + prefix: "" + postfix: "" + +- field: role + note: 角色描述 + range: [测试角色描述]{10} + prefix: "" + postfix: "" + +- field: characterization + note: 角色特征 + range: [测试角色特征]{10} + prefix: "" + postfix: "" + +- field: status + note: 状态 + range: draft{5},active{5} + prefix: "" + postfix: "" + +- field: createdBy + note: 创建者 + range: admin,user1,user2 + prefix: "" + postfix: "" + +- field: createdDate + note: 创建时间 + range: 2023-08-10 10:00:00,2023-08-11 11:00:00,2023-08-12 12:00:00 + prefix: "" + postfix: "" + +- field: deleted + note: 是否删除 + range: 0 + prefix: "" + postfix: "" \ No newline at end of file