6d92024b63
- 修复API测试认证问题:创建全局认证设置,更新Playwright配置 - 优化回归测试稳定性:增加超时时间到15秒,修复定位器 - 创建Woodpecker CI工作流:CI、部署和质量门禁配置 - 添加Jest配置和测试脚本 - 移除登录页面的默认账号密码显示(安全问题修复)
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { performanceThresholds } from '../../config/test-data';
|
|
|
|
export interface ContactFormData {
|
|
name: string;
|
|
email: string;
|
|
phone: string;
|
|
message: string;
|
|
subject?: string;
|
|
}
|
|
|
|
export interface PerformanceData {
|
|
url: string;
|
|
thresholds: typeof performanceThresholds;
|
|
}
|
|
|
|
export interface SEOData {
|
|
url: string;
|
|
expectedTitle: string;
|
|
expectedDescription: string;
|
|
}
|
|
|
|
export class TestDataFactory {
|
|
private static cache: Map<string, any> = new Map();
|
|
|
|
static createContactForm(overrides?: Partial<ContactFormData>): ContactFormData {
|
|
const cacheKey = 'contact-form';
|
|
if (!this.cache.has(cacheKey)) {
|
|
this.cache.set(cacheKey, {
|
|
name: '测试用户',
|
|
email: 'test@example.com',
|
|
phone: '13800138000',
|
|
message: '这是一条测试消息,用于测试表单提交功能',
|
|
subject: '测试主题'
|
|
});
|
|
}
|
|
|
|
return { ...this.cache.get(cacheKey), ...overrides };
|
|
}
|
|
|
|
static createPerformanceData(overrides?: Partial<PerformanceData>): PerformanceData {
|
|
const cacheKey = 'performance-data';
|
|
if (!this.cache.has(cacheKey)) {
|
|
this.cache.set(cacheKey, {
|
|
url: 'http://localhost:3000',
|
|
thresholds: performanceThresholds
|
|
});
|
|
}
|
|
|
|
return { ...this.cache.get(cacheKey), ...overrides };
|
|
}
|
|
|
|
static createSEOData(overrides?: Partial<SEOData>): SEOData {
|
|
const cacheKey = 'seo-data';
|
|
if (!this.cache.has(cacheKey)) {
|
|
this.cache.set(cacheKey, {
|
|
url: 'http://localhost:3000',
|
|
expectedTitle: 'Novalon - 创新科技解决方案',
|
|
expectedDescription: 'Novalon提供专业的科技解决方案'
|
|
});
|
|
}
|
|
|
|
return { ...this.cache.get(cacheKey), ...overrides };
|
|
}
|
|
|
|
static clearCache(): void {
|
|
this.cache.clear();
|
|
}
|
|
}
|