mirror of
https://github.com/cloud-shuttle/leptos-shadcn-ui.git
synced 2025-12-22 22:00:00 +00:00
🏗️ MAJOR MILESTONE: Phase 2 Infrastructure Complete This commit delivers a comprehensive, production-ready infrastructure system for leptos-shadcn-ui with full automation, testing, and monitoring capabilities. ## 🎯 Infrastructure Components Delivered ### 1. WASM Browser Testing ✅ - Cross-browser WASM compatibility testing (Chrome, Firefox, Safari, Mobile) - Performance monitoring with initialization time, memory usage, interaction latency - Memory leak detection and pressure testing - Automated error handling and recovery - Bundle analysis and optimization recommendations - Comprehensive reporting (HTML, JSON, Markdown) ### 2. E2E Test Integration ✅ - Enhanced Playwright configuration with CI/CD integration - Multi-browser testing with automated execution - Performance regression testing and monitoring - Comprehensive reporting with artifact management - Environment detection (CI vs local) - GitHub Actions workflow with notifications ### 3. Performance Benchmarking ✅ - Automated regression testing with baseline comparison - Real-time performance monitoring with configurable intervals - Multi-channel alerting (console, file, webhook, email) - Performance trend analysis and prediction - CLI benchmarking tools and automated monitoring - Baseline management and optimization recommendations ### 4. Accessibility Automation ✅ - WCAG compliance testing (A, AA, AAA levels) - Comprehensive accessibility audit automation - Screen reader support and keyboard navigation testing - Color contrast and focus management validation - Custom accessibility rules and violation detection - Component-specific accessibility testing ## 🚀 Key Features - **Production Ready**: All systems ready for immediate production use - **CI/CD Integration**: Complete GitHub Actions workflow - **Automated Monitoring**: Real-time performance and accessibility monitoring - **Cross-Browser Support**: Chrome, Firefox, Safari, Mobile Chrome, Mobile Safari - **Comprehensive Reporting**: Multiple output formats with detailed analytics - **Error Recovery**: Graceful failure handling and recovery mechanisms ## 📁 Files Added/Modified ### New Infrastructure Files - tests/e2e/wasm-browser-testing.spec.ts - tests/e2e/wasm-performance-monitor.ts - tests/e2e/wasm-test-config.ts - tests/e2e/e2e-test-runner.ts - tests/e2e/accessibility-automation.ts - tests/e2e/accessibility-enhanced.spec.ts - performance-audit/src/regression_testing.rs - performance-audit/src/automated_monitoring.rs - performance-audit/src/bin/performance-benchmark.rs - scripts/run-wasm-tests.sh - scripts/run-performance-benchmarks.sh - scripts/run-accessibility-audit.sh - .github/workflows/e2e-tests.yml - playwright.config.ts ### Enhanced Configuration - Enhanced Makefile with comprehensive infrastructure commands - Enhanced global setup and teardown for E2E tests - Performance audit system integration ### Documentation - docs/infrastructure/PHASE2_INFRASTRUCTURE_GUIDE.md - docs/infrastructure/INFRASTRUCTURE_SETUP_GUIDE.md - docs/infrastructure/PHASE2_COMPLETION_SUMMARY.md - docs/testing/WASM_TESTING_GUIDE.md ## 🎯 Usage ### Quick Start ```bash # Run all infrastructure tests make test # Run WASM browser tests make test-wasm # Run E2E tests make test-e2e-enhanced # Run performance benchmarks make benchmark # Run accessibility audit make accessibility-audit ``` ### Advanced Usage ```bash # Run tests on specific browsers make test-wasm-browsers BROWSERS=chromium,firefox # Run with specific WCAG level make accessibility-audit-wcag LEVEL=AAA # Run performance regression tests make regression-test # Start automated monitoring make performance-monitor ``` ## 📊 Performance Metrics - **WASM Initialization**: <5s (Chrome) to <10s (Mobile Safari) - **First Paint**: <3s (Chrome) to <5s (Mobile Safari) - **Interaction Latency**: <100ms average - **Memory Usage**: <50% increase during operations - **WCAG Compliance**: AA level with AAA support ## 🎉 Impact This infrastructure provides: - **Reliable Component Development**: Comprehensive testing and validation - **Performance Excellence**: Automated performance monitoring and optimization - **Accessibility Compliance**: WCAG compliance validation and reporting - **Production Deployment**: CI/CD integration with automated testing ## 🚀 Next Steps Ready for Phase 3: Component Completion - Complete remaining 41 components using established patterns - Leverage infrastructure for comprehensive testing - Ensure production-ready quality across all components **Status**: ✅ PHASE 2 COMPLETE - READY FOR PRODUCTION Closes: Phase 2 Infrastructure Implementation Related: #infrastructure #testing #automation #ci-cd
201 lines
6.9 KiB
TypeScript
201 lines
6.9 KiB
TypeScript
import { chromium, FullConfig } from '@playwright/test';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
/**
|
|
* Enhanced Global Setup for E2E Tests
|
|
*
|
|
* This setup function handles environment preparation, dependency checks,
|
|
* and initial test data setup for comprehensive E2E testing.
|
|
*/
|
|
|
|
async function globalSetup(config: FullConfig) {
|
|
console.log('🎭 Setting up enhanced Playwright test environment...');
|
|
|
|
const startTime = Date.now();
|
|
const setupResults = {
|
|
environment: 'unknown',
|
|
dependencies: [] as string[],
|
|
services: [] as string[],
|
|
errors: [] as string[],
|
|
warnings: [] as string[],
|
|
};
|
|
|
|
try {
|
|
// 1. Environment Detection
|
|
setupResults.environment = process.env.CI ? 'ci' : 'local';
|
|
console.log(`📍 Environment: ${setupResults.environment}`);
|
|
|
|
// 2. Dependency Checks
|
|
console.log('🔍 Checking dependencies...');
|
|
|
|
// Check if WASM target is installed
|
|
try {
|
|
const { execSync } = require('child_process');
|
|
const rustTargets = execSync('rustup target list --installed', { encoding: 'utf8' });
|
|
if (rustTargets.includes('wasm32-unknown-unknown')) {
|
|
setupResults.dependencies.push('wasm32-unknown-unknown');
|
|
console.log('✅ WASM target is installed');
|
|
} else {
|
|
setupResults.warnings.push('WASM target not installed - some tests may fail');
|
|
console.log('⚠️ WASM target not installed');
|
|
}
|
|
} catch (error) {
|
|
setupResults.errors.push('Failed to check Rust targets');
|
|
console.error('❌ Failed to check Rust targets:', error);
|
|
}
|
|
|
|
// Check if Playwright browsers are installed
|
|
try {
|
|
const { execSync } = require('child_process');
|
|
execSync('pnpm playwright --version', { encoding: 'utf8' });
|
|
setupResults.dependencies.push('playwright');
|
|
console.log('✅ Playwright is installed');
|
|
} catch (error) {
|
|
setupResults.errors.push('Playwright not installed');
|
|
console.error('❌ Playwright not installed:', error);
|
|
}
|
|
|
|
// 3. Service Health Checks
|
|
console.log('🏥 Checking service health...');
|
|
|
|
// Check if test server is accessible
|
|
try {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage();
|
|
|
|
// Try to access the test server
|
|
const baseURL = config.use?.baseURL || 'http://localhost:8082';
|
|
await page.goto(baseURL, { timeout: 10000 });
|
|
|
|
setupResults.services.push('test-server');
|
|
console.log('✅ Test server is accessible');
|
|
|
|
await browser.close();
|
|
} catch (error) {
|
|
setupResults.warnings.push('Test server not accessible - will be started by webServer');
|
|
console.log('⚠️ Test server not accessible, will be started automatically');
|
|
}
|
|
|
|
// 4. Test Data Preparation
|
|
console.log('📊 Preparing test data...');
|
|
|
|
// Create test results directory
|
|
const testResultsDir = path.join(process.cwd(), 'test-results');
|
|
if (!fs.existsSync(testResultsDir)) {
|
|
fs.mkdirSync(testResultsDir, { recursive: true });
|
|
console.log('✅ Created test results directory');
|
|
}
|
|
|
|
// Create browser-specific directories
|
|
const browsers = ['chromium', 'firefox', 'webkit', 'Mobile Chrome', 'Mobile Safari'];
|
|
browsers.forEach(browser => {
|
|
const browserDir = path.join(testResultsDir, browser);
|
|
if (!fs.existsSync(browserDir)) {
|
|
fs.mkdirSync(browserDir, { recursive: true });
|
|
}
|
|
});
|
|
|
|
// 5. Performance Baseline Setup
|
|
console.log('📈 Setting up performance baselines...');
|
|
|
|
const performanceBaseline = {
|
|
maxInitializationTime: parseInt(process.env.MAX_INIT_TIME || '5000'),
|
|
maxFirstPaint: parseInt(process.env.MAX_FIRST_PAINT || '3000'),
|
|
maxFirstContentfulPaint: parseInt(process.env.MAX_FCP || '4000'),
|
|
maxInteractionLatency: parseInt(process.env.MAX_INTERACTION_LATENCY || '100'),
|
|
environment: setupResults.environment,
|
|
timestamp: new Date().toISOString(),
|
|
};
|
|
|
|
fs.writeFileSync(
|
|
path.join(testResultsDir, 'performance-baseline.json'),
|
|
JSON.stringify(performanceBaseline, null, 2)
|
|
);
|
|
|
|
// 6. Environment Variables Setup
|
|
console.log('🔧 Setting up environment variables...');
|
|
|
|
// Set test-specific environment variables
|
|
process.env.TEST_ENVIRONMENT = setupResults.environment;
|
|
process.env.TEST_START_TIME = startTime.toString();
|
|
process.env.TEST_BASE_URL = config.use?.baseURL || 'http://localhost:8082';
|
|
|
|
// 7. Browser Capability Detection
|
|
console.log('🌐 Detecting browser capabilities...');
|
|
|
|
try {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage();
|
|
|
|
const capabilities = await page.evaluate(() => {
|
|
return {
|
|
webAssembly: typeof WebAssembly !== 'undefined',
|
|
sharedArrayBuffer: typeof SharedArrayBuffer !== 'undefined',
|
|
bigInt: typeof BigInt !== 'undefined',
|
|
userAgent: navigator.userAgent,
|
|
language: navigator.language,
|
|
platform: navigator.platform,
|
|
};
|
|
});
|
|
|
|
fs.writeFileSync(
|
|
path.join(testResultsDir, 'browser-capabilities.json'),
|
|
JSON.stringify(capabilities, null, 2)
|
|
);
|
|
|
|
await browser.close();
|
|
console.log('✅ Browser capabilities detected');
|
|
} catch (error) {
|
|
setupResults.warnings.push('Failed to detect browser capabilities');
|
|
console.log('⚠️ Failed to detect browser capabilities');
|
|
}
|
|
|
|
// 8. Setup Summary
|
|
const setupDuration = Date.now() - startTime;
|
|
console.log(`\n📋 Setup Summary (${setupDuration}ms):`);
|
|
console.log(` Environment: ${setupResults.environment}`);
|
|
console.log(` Dependencies: ${setupResults.dependencies.join(', ')}`);
|
|
console.log(` Services: ${setupResults.services.join(', ')}`);
|
|
|
|
if (setupResults.warnings.length > 0) {
|
|
console.log(` Warnings: ${setupResults.warnings.join(', ')}`);
|
|
}
|
|
|
|
if (setupResults.errors.length > 0) {
|
|
console.log(` Errors: ${setupResults.errors.join(', ')}`);
|
|
}
|
|
|
|
// Save setup results
|
|
fs.writeFileSync(
|
|
path.join(testResultsDir, 'setup-results.json'),
|
|
JSON.stringify({
|
|
...setupResults,
|
|
duration: setupDuration,
|
|
timestamp: new Date().toISOString(),
|
|
}, null, 2)
|
|
);
|
|
|
|
console.log('✅ Enhanced global setup complete');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Global setup failed:', error);
|
|
setupResults.errors.push(`Setup failed: ${error}`);
|
|
|
|
// Save error results
|
|
const testResultsDir = path.join(process.cwd(), 'test-results');
|
|
fs.writeFileSync(
|
|
path.join(testResultsDir, 'setup-results.json'),
|
|
JSON.stringify({
|
|
...setupResults,
|
|
duration: Date.now() - startTime,
|
|
timestamp: new Date().toISOString(),
|
|
}, null, 2)
|
|
);
|
|
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export default globalSetup;
|