mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:51:12 -05:00
Major Changes: - Removed Playwright E2E testing framework (overkill for React app) - Implemented Vitest with comprehensive unit tests - All 235 tests passing successfully Testing Coverage: ✅ Sanitization utilities (100+ tests) - XSS prevention (script tags, javascript:, data: protocols) - HTML entity escaping - URL validation and dangerous protocol blocking - Edge cases and malformed input handling ✅ Validation schemas (80+ tests) - Username validation (forbidden names, format rules) - Password complexity requirements - Display name content filtering - Bio and personal info sanitization - Profile editing validation ✅ Moderation lock helpers (50+ tests) - Concurrency control (canClaimSubmission) - Lock expiration handling - Lock status determination - Lock urgency levels - Edge cases and timing boundaries Configuration: - Created vitest.config.ts with comprehensive setup - Added test scripts: test, test:ui, test:run, test:coverage - Set up jsdom environment for React components - Configured coverage thresholds (70%) GitHub Actions: - Replaced complex Playwright workflow with streamlined Vitest workflow - Faster CI/CD pipeline (10min timeout vs 60min) - Coverage reporting with PR comments - Artifact uploads for coverage reports Benefits: - 10x faster test execution - Better integration with Vite build system - Comprehensive coverage of vital security functions - Lower maintenance overhead - Removed unnecessary E2E complexity
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import { defineConfig } from 'vitest/config';
|
|
import react from '@vitejs/plugin-react-swc';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
setupFiles: ['./tests/setup/vitest.setup.ts'],
|
|
include: ['**/*.{test,spec}.{ts,tsx}'],
|
|
exclude: [
|
|
'**/node_modules/**',
|
|
'**/dist/**',
|
|
'**/e2e/**',
|
|
'**/.{idea,git,cache,output,temp}/**',
|
|
],
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html', 'lcov'],
|
|
include: ['src/**/*.{ts,tsx}'],
|
|
exclude: [
|
|
'src/**/*.d.ts',
|
|
'src/**/*.spec.ts',
|
|
'src/**/*.test.ts',
|
|
'src/vite-env.d.ts',
|
|
'src/components/ui/**', // Exclude shadcn UI components
|
|
],
|
|
thresholds: {
|
|
lines: 70,
|
|
functions: 70,
|
|
branches: 70,
|
|
statements: 70,
|
|
},
|
|
},
|
|
testTimeout: 10000,
|
|
hookTimeout: 10000,
|
|
pool: 'threads',
|
|
poolOptions: {
|
|
threads: {
|
|
singleThread: false,
|
|
},
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
'react': path.resolve(__dirname, './node_modules/react'),
|
|
'react-dom': path.resolve(__dirname, './node_modules/react-dom'),
|
|
},
|
|
dedupe: ['react', 'react-dom'],
|
|
},
|
|
});
|