/**
 * Local Development Environment Configuration for HVAC Testing Framework
 * 
 * Configuration for local WordPress development environment
 * 
 * @package HVAC_Community_Events
 * @version 2.0.0
 * @created 2025-08-27
 */

module.exports = {
    // Application Settings
    app: {
        baseUrl: 'http://localhost:8080',
        environment: 'local',
        debug: true
    },
    
    // Test User Configurations
    environments: {
        users: {
            trainer: {
                username: 'test_trainer',
                email: 'test_trainer@localhost',
                password: 'TestTrainer123!',
                role: 'hvac_trainer',
                defaultPage: '/trainer/dashboard/'
            },
            masterTrainer: {
                username: 'test_master',
                email: 'test_master@localhost',
                password: 'TestMaster123!',
                role: 'hvac_master_trainer',
                defaultPage: '/master-trainer/master-dashboard/'
            },
            admin: {
                username: 'admin',
                email: 'admin@localhost',
                password: 'admin',
                role: 'administrator',
                defaultPage: '/wp-admin/'
            }
        }
    },
    
    // Database Configuration
    database: {
        host: 'localhost',
        name: 'hvac_test',
        user: 'root',
        password: '',
        prefix: 'wp_test_',
        charset: 'utf8mb4',
        isolation: true // Use transactions for test isolation
    },
    
    // WordPress-specific settings for local development
    wordpress: {
        cliPath: 'wp',
        adminPath: '/wp-admin/',
        loginPath: '/wp-login.php',
        customLoginPath: '/training-login/',
        apiPath: '/wp-json/',
        databaseIsolation: true,   // Safe to modify local database
        flushRewriteRules: true,   // Safe to flush rules locally
        clearCache: true           // Safe to clear cache locally
    },
    
    // Browser settings optimized for local development
    browser: {
        headless: false,  // Show browser in local development
        slowMo: 500,      // Slower for debugging
        viewport: {
            width: 1280,
            height: 720
        },
        args: [
            '--disable-dev-shm-usage',
            '--no-sandbox',
            '--disable-setuid-sandbox'
        ]
    },
    
    // Test execution parameters for local development
    framework: {
        timeout: 30000,
        retries: 1,        // Fewer retries locally
        parallel: false,   // Sequential execution for debugging
        maxWorkers: 1,     // Single worker for debugging
        testDataIsolation: true,
        screenshotsOnFailure: true,
        videosOnFailure: true
    },
    
    // Local test data management
    testData: {
        seedData: true,         // Safe to seed data locally
        cleanupAfterTests: true, // Clean up local test data
        isolateTransactions: true,
        backupDatabase: true,    // Backup before destructive operations
        fixtures: {
            users: './fixtures/local-users.json',
            events: './fixtures/local-events.json',
            venues: './fixtures/local-venues.json'
        }
    },
    
    // All features enabled in local development
    features: {
        trainerRegistration: true,
        eventCreation: true,
        profileManagement: true,
        announcements: true,
        masterTrainerTools: true,
        importExport: true,
        communicationTemplates: true,
        trainingLeads: true,
        certificates: true,
        geocoding: true,
        mobileResponsive: true,
        debugMode: true,
        testDataGeneration: true
    },
    
    // Standard selectors
    selectors: {
        dataTestIdAttribute: 'data-testid',
        roleAttribute: 'data-role',
        pageAttribute: 'data-page',
        formAttribute: 'data-form',
        buttonAttribute: 'data-action'
    },
    
    // Media settings for local development
    media: {
        screenshotDir: './test-results/screenshots/local',
        videoDir: './test-results/videos/local',
        screenshotMode: 'all', // Capture all screenshots locally
        videoMode: 'retain-on-failure',
        quality: 90,
        fullPage: true
    },
    
    // Enhanced reporting for local development
    reporting: {
        outputDir: './test-results/reports/local',
        formats: ['html', 'json', 'junit'],
        includeScreenshots: true,
        includeTimings: true,
        includeSourceMaps: true,
        groupByCategory: true,
        localSpecificMetadata: {
            environment: 'local',
            baseUrl: 'http://localhost:8080',
            wordpressVersion: 'latest',
            phpVersion: process.env.PHP_VERSION || '8.1'
        }
    },
    
    // Network settings for local development
    network: {
        timeout: 10000,
        ignoreHTTPSErrors: false,
        bypassCSP: true, // Useful for development
        userAgent: 'HVAC-Testing-Framework/2.0 Playwright (Local)'
    },
    
    // Local WordPress URLs
    urls: {
        login: '/training-login/',
        wpLogin: '/wp-login.php',
        trainerDashboard: '/trainer/dashboard/',
        masterDashboard: '/master-trainer/master-dashboard/',
        createEvent: '/trainer/create-event/',
        manageEvents: '/trainer/events/',
        profile: '/trainer/profile/',
        findTrainer: '/find-trainer/',
        registration: '/trainer-registration/'
    },
    
    // Expected local content
    expectedContent: {
        loginPageTitle: 'Training Login',
        dashboardTitle: 'HVAC Trainer Dashboard',
        masterDashboardTitle: 'Master Trainer Dashboard',
        welcomeMessage: 'Welcome to HVAC Training',
        noAccessMessage: 'You do not have permission to access this page'
    },
    
    // Local development specific settings
    localSpecific: {
        // Database reset capabilities
        allowDatabaseReset: true,
        
        // File system access
        allowFileSystemAccess: true,
        
        // WP-CLI access
        wpCliEnabled: true,
        
        // Debug features
        enableDebugLogs: true,
        enableVerboseOutput: true,
        
        // Fast test execution
        skipWaitTimes: false, // Keep waits for realistic testing
        
        // Development tools
        enableDevTools: true,
        allowScreenRecording: true,
        
        // Local-specific plugins that might be active
        developmentPlugins: [
            'query-monitor',
            'debug-bar',
            'user-switching'
        ],
        
        // Safe operations
        allowDestructiveOperations: true,
        allowPluginActivation: true,
        allowThemeChanges: true
    },
    
    // Docker configuration (if using Docker for local development)
    docker: {
        enabled: false,
        services: {
            wordpress: {
                image: 'wordpress:latest',
                port: 8080
            },
            mysql: {
                image: 'mysql:5.7',
                port: 3306,
                rootPassword: 'rootpassword',
                database: 'hvac_test'
            },
            redis: {
                image: 'redis:alpine',
                port: 6379
            }
        }
    }
};