diff --git a/test-framework/shared/config/base.config.ts b/test-framework/shared/config/base.config.ts new file mode 100644 index 0000000..22451ab --- /dev/null +++ b/test-framework/shared/config/base.config.ts @@ -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 + } +}; diff --git a/test-framework/shared/config/environments.ts b/test-framework/shared/config/environments.ts new file mode 100644 index 0000000..e73924a --- /dev/null +++ b/test-framework/shared/config/environments.ts @@ -0,0 +1,29 @@ +import { TestConfig } from '../types'; + +export const environments: Record = { + 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; +} diff --git a/test-framework/shared/config/test-data.ts b/test-framework/shared/config/test-data.ts new file mode 100644 index 0000000..90c1e87 --- /dev/null +++ b/test-framework/shared/config/test-data.ts @@ -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 +}; diff --git a/test-framework/shared/config/test-pages.ts b/test-framework/shared/config/test-pages.ts new file mode 100644 index 0000000..556bdda --- /dev/null +++ b/test-framework/shared/config/test-pages.ts @@ -0,0 +1,74 @@ +import { PageConfig } from '../types'; + +export const testPages: Record = { + 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); +}