feat: add configuration management system

This commit is contained in:
张翔
2026-03-06 12:05:51 +08:00
parent 66c868de03
commit c7686bf1a3
4 changed files with 173 additions and 0 deletions
@@ -0,0 +1,35 @@
import { TestConfig } from '../types';
export const defaultConfig: TestConfig = {
baseURL: 'http://localhost:3000',
timeout: 5000,
retries: 3,
environment: 'development',
headless: true,
slowMo: undefined
};
export const testTimeouts = {
short: 2000,
medium: 5000,
long: 10000,
veryLong: 30000
};
export const testThresholds = {
performance: {
good: 90,
needsImprovement: 50,
poor: 0
},
accessibility: {
good: 95,
needsImprovement: 80,
poor: 0
},
seo: {
good: 90,
needsImprovement: 70,
poor: 0
}
};
@@ -0,0 +1,29 @@
import { TestConfig } from '../types';
export const environments: Record<string, TestConfig> = {
development: {
baseURL: 'http://localhost:3000',
timeout: 5000,
retries: 3,
environment: 'development',
headless: false
},
staging: {
baseURL: 'https://staging.novalon.com',
timeout: 10000,
retries: 2,
environment: 'staging',
headless: true
},
production: {
baseURL: 'https://www.novalon.com',
timeout: 10000,
retries: 1,
environment: 'production',
headless: true
}
};
export function getEnvironmentConfig(env: string = 'development'): TestConfig {
return environments[env] || environments.development;
}
+35
View File
@@ -0,0 +1,35 @@
export const formData = {
valid: {
name: '测试用户',
email: 'test@example.com',
phone: '13800138000',
message: '这是一条测试消息'
},
invalid: {
email: 'invalid-email',
phone: '123',
empty: ''
}
};
export const performanceThresholds = {
loadTime: 3000,
domContentLoaded: 2000,
firstContentfulPaint: 1500,
largestContentfulPaint: 2500,
cumulativeLayoutShift: 0.1,
firstInputDelay: 100
};
export const accessibilityThresholds = {
score: 80,
maxViolations: 5
};
export const seoThresholds = {
score: 80,
minTitleLength: 10,
maxTitleLength: 60,
minDescriptionLength: 50,
maxDescriptionLength: 160
};
@@ -0,0 +1,74 @@
import { PageConfig } from '../types';
export const testPages: Record<string, PageConfig> = {
home: {
name: '首页',
url: '/',
selectors: {
title: 'h1',
hero: '.hero-section',
features: '.features-section'
}
},
about: {
name: '关于我们',
url: '/about',
selectors: {
title: 'h1',
content: '.about-content'
}
},
contact: {
name: '联系我们',
url: '/contact',
selectors: {
title: 'h1',
form: '#contact-form',
submitButton: 'button[type="submit"]'
}
},
products: {
name: '产品',
url: '/products',
selectors: {
title: 'h1',
productGrid: '.products-grid',
productCard: '.product-card'
}
},
services: {
name: '服务',
url: '/services',
selectors: {
title: 'h1',
servicesList: '.services-list',
serviceItem: '.service-item'
}
},
cases: {
name: '案例',
url: '/cases',
selectors: {
title: 'h1',
casesGrid: '.cases-grid',
caseCard: '.case-card'
}
},
news: {
name: '新闻',
url: '/news',
selectors: {
title: 'h1',
newsList: '.news-list',
newsItem: '.news-item'
}
}
};
export function getPageConfig(pageKey: string): PageConfig {
return testPages[pageKey] || testPages.home;
}
export function getAllPageConfigs(): PageConfig[] {
return Object.values(testPages);
}