feat: complete system test fixes - 100% pass rate (85/85)
- 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
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { TestResult, PerformanceMetrics, ComparisonResult } from '../../types/reporting';
|
||||
|
||||
export class PerformanceBaseline {
|
||||
private baseline: Map<string, PerformanceMetrics> = new Map();
|
||||
|
||||
calculate(results: TestResult[]): PerformanceBaseline {
|
||||
results.forEach(result => {
|
||||
if (result.type === 'performance' && result.metrics) {
|
||||
this.updateBaseline(result);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
private updateBaseline(result: TestResult): void {
|
||||
const key = result.name;
|
||||
const current = this.baseline.get(key);
|
||||
const metrics = result.metrics as PerformanceMetrics;
|
||||
|
||||
if (!current || metrics.loadTime < current.loadTime) {
|
||||
this.baseline.set(key, metrics);
|
||||
}
|
||||
}
|
||||
|
||||
compareWithBaseline(metrics: PerformanceMetrics, testName: string): ComparisonResult {
|
||||
const baseline = this.baseline.get(testName);
|
||||
if (!baseline) {
|
||||
return { status: 'no-baseline', difference: 0 };
|
||||
}
|
||||
|
||||
const difference = metrics.loadTime - baseline.loadTime;
|
||||
const status = difference > 500 ? 'regression' : difference < -500 ? 'improvement' : 'stable';
|
||||
|
||||
return { status, difference };
|
||||
}
|
||||
|
||||
getBaseline(testName: string): PerformanceMetrics | undefined {
|
||||
return this.baseline.get(testName);
|
||||
}
|
||||
|
||||
getAllBaselines(): Map<string, PerformanceMetrics> {
|
||||
return this.baseline;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user