// app/modules/dev_tools/static/admin/js/testing-hub.js // ✅ Use centralized logger - ONE LINE! // Create custom logger for testing hub const testingLog = window.LogConfig.createLogger('TESTING-HUB'); /** * Testing Hub Alpine.js Component * Central hub for all test suites and QA tools */ function adminTestingHub() { return { // ✅ CRITICAL: Inherit base layout functionality ...data(), // ✅ CRITICAL: Set page identifier currentPage: 'testing', // Test suites data testSuites: [ { id: 'auth-flow', name: 'Authentication Flow', description: 'Test login, logout, token expiration, redirects, and protected route access.', url: '/admin/test/auth-flow', icon: 'lock-closed', color: 'blue', testCount: 6, features: [ 'Login with valid/invalid credentials', 'Token expiration handling', 'Protected route access & redirects', 'localStorage state monitoring' ] }, { id: 'vendors-users', name: 'Data Migration & CRUD', description: 'Test vendor and user creation, listing, editing, deletion, and data migration scenarios.', url: '/admin/test/vendors-users-migration', icon: 'database', color: 'orange', testCount: 10, features: [ 'Vendor CRUD operations', 'User management & roles', 'Data migration validation', 'Form validation & error handling' ] } ], // Stats stats: { totalSuites: 2, totalTests: 16, coverage: 'Auth, CRUD', avgDuration: '< 5 min' }, // Loading state loading: false, // ✅ CRITICAL: Proper initialization with guard async init() { testingLog.info('=== TESTING HUB INITIALIZING ==='); // Prevent multiple initializations if (window._testingHubInitialized) { testingLog.warn('Testing hub already initialized, skipping...'); return; } window._testingHubInitialized = true; // Calculate stats this.calculateStats(); testingLog.info('=== TESTING HUB INITIALIZATION COMPLETE ==='); }, /** * Calculate test statistics */ calculateStats() { this.stats.totalSuites = this.testSuites.length; this.stats.totalTests = this.testSuites.reduce((sum, suite) => sum + suite.testCount, 0); testingLog.debug('Stats calculated:', this.stats); }, /** * Get color classes for test suite cards */ getColorClasses(color) { const colorMap = { blue: { gradient: 'from-blue-500 to-blue-600', button: 'bg-blue-600 hover:bg-blue-700' }, orange: { gradient: 'from-orange-500 to-orange-600', button: 'bg-orange-600 hover:bg-orange-700' }, green: { gradient: 'from-green-500 to-green-600', button: 'bg-green-600 hover:bg-green-700' }, purple: { gradient: 'from-purple-500 to-purple-600', button: 'bg-purple-600 hover:bg-purple-700' } }; return colorMap[color] || colorMap.blue; }, /** * Navigate to test suite */ goToTest(url) { testingLog.info('Navigating to test suite:', url); window.location.href = url; } }; } testingLog.info('Testing hub module loaded');