Files
prompt-optimizer/tests/e2e/analysis/pro-variable.spec.ts
linshen 8467b96263 feat(test): 实现智能测试系统并改进测试策略
- 实现智能测试系统,统一测试入口
- 完成 Pro 路由重构和 Image 模式评估测试
- 为 Image 模式添加 data-testid 支持
- 完善 E2E 测试并修复选择器策略
- 优化 Seedream、OpenAI 和 SiliconFlow 适配器
- 移除调试日志,保留错误和警告日志
- 重命名 Pro 模式子模式(system/user → multi/variable)
- 清理测试代码并改进稳定性
2026-01-10 11:23:00 +08:00

63 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test, expect } from '../fixtures'
import { navigateToMode } from '../helpers/common'
import {
fillOriginalPrompt,
clickAnalyzeButton,
getEvaluationScore,
verifyAnalyzeButtonDisabledWhenEmpty
} from '../helpers/analysis'
/**
* Pro Variable 模式 - 提示词分析测试
*
* ✨ 最佳范式示例:
* - 使用 data-testid 精确定位,不依赖文本内容
* - 容器隔离:通过 data-mode 区分不同工作区
* - 类型安全:使用 TypeScript 类型定义
*
* 功能:分析带变量的用户提示词并显示评估分数
*
* 前提:
* - .env.local 已配置 API keys
* - 实际调用 LLM API会产生费用
*
* 测试流程:
* 1. 导航到 pro-variable 工作区
* 2. 填写带变量的用户提示词
* 3. 点击"分析"按钮
* 4. 等待 LLM 响应
* 5. 验证评估结果和分数显示
*
* 注意:本测试测试的是"分析"功能prompt-only 评估),不涉及优化
*/
const MODE = 'pro-variable' as const
test.describe('Pro Variable - 提示词分析', () => {
test('分析带变量的提示词并显示评估结果', async ({ page }) => {
test.setTimeout(180000) // 3分钟超时
// 1. 导航到 pro-variable 工作区
await navigateToMode(page, 'pro', 'variable')
// 2. 等待服务和组件完全初始化
// 3. 填写带变量的用户提示词(使用 data-testid 定位)
const testPrompt = '请根据{{任务描述}},为{{目标用户}}编写一份{{文档类型}},要求{{质量要求}}'
await fillOriginalPrompt(page, MODE, testPrompt)
// 4. 点击分析按钮(使用 data-testid 定位)
await clickAnalyzeButton(page, MODE)
// 5. 验证评估分数(使用 data-testid 定位)
const score = await getEvaluationScore(page, MODE)
})
test('验证分析按钮在没有提示词时禁用', async ({ page }) => {
await navigateToMode(page, 'pro', 'variable')
// 分析按钮应该在没有输入时禁用
await verifyAnalyzeButtonDisabledWhenEmpty(page, MODE)
})
})