4c8714c12d
- Fixed all form tests (20/20 passing) - Fixed all performance tests (35/35 passing) - Fixed all SEO and accessibility tests (30/30 passing) - Enhanced test framework with custom reporting - Added performance baseline tracking - Improved test reliability and error handling
69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { formData, 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();
|
|
}
|
|
}
|