T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.quebec/public_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/public_html/scripts/test-live-cases-enhancement.js
const fs = require('fs');
const path = require('path');

function testLiveCasesEnhancement() {
  console.log('๐Ÿงช Testing Live Cases Page Enhancement...\n');
  
  let allTestsPassed = true;
  
  // Test 1: Check enhanced Live Cases page structure
  console.log('๐Ÿ“‹ Test 1: Checking enhanced Live Cases page structure...');
  try {
    const liveCasesPath = path.join(__dirname, '../src/pages/live-cases.tsx');
    const liveCasesContent = fs.readFileSync(liveCasesPath, 'utf8');
    
    const checks = [
      { name: 'Multi-tab navigation', pattern: 'activeTab.*overview.*cases.*analytics.*insights' },
      { name: 'Stats interface', pattern: 'interface LiveCasesStats' },
      { name: 'StatCard component', pattern: 'const StatCard' },
      { name: 'InsightCard component', pattern: 'const InsightCard' },
      { name: 'API stats fetch', pattern: 'fetchLiveCasesStats' },
      { name: 'Overview tab content', pattern: 'activeTab === \'overview\'' },
      { name: 'Analytics tab content', pattern: 'activeTab === \'analytics\'' },
      { name: 'Insights tab content', pattern: 'activeTab === \'insights\'' },
      { name: 'Quick actions section', pattern: 'Quick Actions' },
      { name: 'Market insights section', pattern: 'Market Insights' },
      { name: 'Recent activity section', pattern: 'Recent Activity' },
      { name: 'Enhanced header', pattern: 'Live Cases Hub' }
    ];
    
    let pageChecksPassed = 0;
    checks.forEach(check => {
      if (liveCasesContent.includes(check.pattern)) {
        console.log(`โœ… PASS: ${check.name}`);
        pageChecksPassed++;
      } else {
        console.log(`โŒ FAIL: ${check.name}`);
      }
    });
    
    if (pageChecksPassed === checks.length) {
      console.log('โœ… PASS: All Live Cases page structure checks passed');
    } else {
      console.log(`โŒ FAIL: ${checks.length - pageChecksPassed} Live Cases page structure checks failed`);
      allTestsPassed = false;
    }
  } catch (error) {
    console.log(`โŒ ERROR: Could not read live-cases.tsx - ${error.message}`);
    allTestsPassed = false;
  }
  
  // Test 2: Check API endpoint implementation
  console.log('\n๐Ÿ“‹ Test 2: Checking API endpoint implementation...');
  try {
    const apiPath = path.join(__dirname, '../src/pages/api/live-cases/stats.ts');
    const apiContent = fs.readFileSync(apiPath, 'utf8');
    
    const checks = [
      { name: 'Prisma client import', pattern: 'import.*PrismaClient' },
      { name: 'GET method handler', pattern: 'req.method !== \'GET\'' },
      { name: 'Public cases query', pattern: 'isPublic: true' },
      { name: 'Lawyers query', pattern: 'role: \'LAWYER\'' },
      { name: 'Clients query', pattern: 'role: \'CLIENT\'' },
      { name: 'Statistics calculation', pattern: 'totalCases.*activeCases.*urgentCases' },
      { name: 'Category analysis', pattern: 'categoryCounts' },
      { name: 'Jurisdiction analysis', pattern: 'jurisdictionCounts' },
      { name: 'Activity feed', pattern: 'recentActivity' },
      { name: 'Response structure', pattern: 'res.status(200).json(stats)' }
    ];
    
    let apiChecksPassed = 0;
    checks.forEach(check => {
      if (apiContent.includes(check.pattern)) {
        console.log(`โœ… PASS: ${check.name}`);
        apiChecksPassed++;
      } else {
        console.log(`โŒ FAIL: ${check.name}`);
      }
    });
    
    if (apiChecksPassed === checks.length) {
      console.log('โœ… PASS: All API endpoint checks passed');
    } else {
      console.log(`โŒ FAIL: ${checks.length - apiChecksPassed} API endpoint checks failed`);
      allTestsPassed = false;
    }
  } catch (error) {
    console.log(`โŒ ERROR: Could not read stats.ts - ${error.message}`);
    allTestsPassed = false;
  }
  
  // Test 3: Check component imports and dependencies
  console.log('\n๐Ÿ“‹ Test 3: Checking component imports and dependencies...');
  try {
    const liveCasesPath = path.join(__dirname, '../src/pages/live-cases.tsx');
    const liveCasesContent = fs.readFileSync(liveCasesPath, 'utf8');
    
    const requiredImports = [
      'useState',
      'useEffect',
      'TrendingUp',
      'Users',
      'DollarSign',
      'Clock',
      'Award',
      'BarChart3',
      'BookOpen',
      'AlertTriangle',
      'Target',
      'Zap'
    ];
    
    let importChecksPassed = 0;
    requiredImports.forEach(importName => {
      if (liveCasesContent.includes(importName)) {
        console.log(`โœ… PASS: ${importName} import found`);
        importChecksPassed++;
      } else {
        console.log(`โŒ FAIL: ${importName} import not found`);
      }
    });
    
    if (importChecksPassed === requiredImports.length) {
      console.log('โœ… PASS: All required imports found');
    } else {
      console.log(`โŒ FAIL: ${requiredImports.length - importChecksPassed} imports missing`);
      allTestsPassed = false;
    }
  } catch (error) {
    console.log(`โŒ ERROR: Could not check imports - ${error.message}`);
    allTestsPassed = false;
  }
  
  // Test 4: Check UI component structure
  console.log('\n๐Ÿ“‹ Test 4: Checking UI component structure...');
  try {
    const liveCasesPath = path.join(__dirname, '../src/pages/live-cases.tsx');
    const liveCasesContent = fs.readFileSync(liveCasesPath, 'utf8');
    
    const uiChecks = [
      { name: 'Navigation tabs', pattern: 'Navigation Tabs' },
      { name: 'Stat cards grid', pattern: 'grid.*grid-cols-1.*md:grid-cols-2.*lg:grid-cols-4' },
      { name: 'Quick actions section', pattern: 'Quick Actions' },
      { name: 'Market insights section', pattern: 'Market Insights' },
      { name: 'Progress bars', pattern: 'bg-gray-200.*rounded-full.*h-2' },
      { name: 'Loading states', pattern: 'animate-pulse' },
      { name: 'Hover effects', pattern: 'hover:shadow-md.*transition-shadow' },
      { name: 'Responsive design', pattern: 'max-w-7xl.*mx-auto' }
    ];
    
    let uiChecksPassed = 0;
    uiChecks.forEach(check => {
      if (liveCasesContent.includes(check.pattern)) {
        console.log(`โœ… PASS: ${check.name}`);
        uiChecksPassed++;
      } else {
        console.log(`โŒ FAIL: ${check.name}`);
      }
    });
    
    if (uiChecksPassed === uiChecks.length) {
      console.log('โœ… PASS: All UI component checks passed');
    } else {
      console.log(`โŒ FAIL: ${uiChecks.length - uiChecksPassed} UI component checks failed`);
      allTestsPassed = false;
    }
  } catch (error) {
    console.log(`โŒ ERROR: Could not check UI structure - ${error.message}`);
    allTestsPassed = false;
  }
  
  // Test 5: Check data flow and state management
  console.log('\n๐Ÿ“‹ Test 5: Checking data flow and state management...');
  try {
    const liveCasesPath = path.join(__dirname, '../src/pages/live-cases.tsx');
    const liveCasesContent = fs.readFileSync(liveCasesPath, 'utf8');
    
    const dataFlowChecks = [
      { name: 'Stats state', pattern: 'useState.*LiveCasesStats.*null' },
      { name: 'Loading state', pattern: 'useState.*loading.*true' },
      { name: 'Active tab state', pattern: 'useState.*activeTab.*overview' },
      { name: 'useEffect hook', pattern: 'useEffect.*fetchLiveCasesStats' },
      { name: 'API fetch function', pattern: 'fetchLiveCasesStats.*async' },
      { name: 'Error handling', pattern: 'catch.*error' },
      { name: 'Loading states', pattern: 'loading.*?' },
      { name: 'Conditional rendering', pattern: 'stats.*?' }
    ];
    
    let dataFlowChecksPassed = 0;
    dataFlowChecks.forEach(check => {
      if (liveCasesContent.includes(check.pattern)) {
        console.log(`โœ… PASS: ${check.name}`);
        dataFlowChecksPassed++;
      } else {
        console.log(`โŒ FAIL: ${check.name}`);
      }
    });
    
    if (dataFlowChecksPassed === dataFlowChecks.length) {
      console.log('โœ… PASS: All data flow checks passed');
    } else {
      console.log(`โŒ FAIL: ${dataFlowChecks.length - dataFlowChecksPassed} data flow checks failed`);
      allTestsPassed = false;
    }
  } catch (error) {
    console.log(`โŒ ERROR: Could not check data flow - ${error.message}`);
    allTestsPassed = false;
  }
  
  console.log('\n๐Ÿ“Š Test Summary:');
  console.log(allTestsPassed ? 'โœ… All tests passed!' : 'โŒ Some tests failed');
  
  if (allTestsPassed) {
    console.log('\n๐ŸŽ‰ Live Cases Page Enhancement Complete!');
    console.log('\n๐Ÿ“‹ What was implemented:');
    console.log('   โ€ข Multi-tab navigation system (Overview, Cases, Analytics, Insights)');
    console.log('   โ€ข Real-time market statistics and analytics');
    console.log('   โ€ข Interactive dashboard components (StatCard, InsightCard)');
    console.log('   โ€ข Comprehensive API endpoint (/api/live-cases/stats)');
    console.log('   โ€ข Enhanced user experience with loading states and animations');
    console.log('   โ€ข Market insights and activity tracking');
    console.log('   โ€ข Responsive design with mobile optimization');
    console.log('\n๐Ÿ” Next steps:');
    console.log('   โ€ข Test the API endpoint with real data');
    console.log('   โ€ข Verify all tabs work correctly');
    console.log('   โ€ข Test responsive design on different devices');
    console.log('   โ€ข Monitor performance and user engagement');
  }
  
  return allTestsPassed;
}

// Run the test if this file is executed directly
if (require.main === module) {
  testLiveCasesEnhancement();
}

module.exports = { testLiveCasesEnhancement }; 

CasperSecurity Mini