File size: 2,355 Bytes
21cac8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env node

const path = require('path');
require('dotenv').config();

// Simple test to see what's happening with the analysis
async function testAnalysis() {
  console.log('Testing analysis pipeline...');

  // Check if Gemini API key is available
  const apiKey = process.env.GEMINI_API_KEY;
  console.log(`API Key: ${apiKey ? 'Present' : 'Missing'}`);

  if (!apiKey) {
    console.log('❌ No Gemini API key found. Set GEMINI_API_KEY environment variable.');
    return;
  }

  try {
    // Test basic UXAnalyzer initialization
    const UXAnalyzer = require('./lib/UXAnalyzer');

    const config = {
      ai: {
        geminiApiKey: apiKey,
        gemini: {
          apiKey: apiKey,
          model: "gemini-1.5-flash"
        }
      },
      database: {
        type: "sqlite",
        path: "./data/analysis.db"
      },
      screenshots: {
        storagePath: "./data/screenshots",
        viewports: {
          desktop: { width: 1920, height: 1080 }
        },
        timeoutMs: 60000,
        waitForMs: 5000
      },
      browser: {
        poolSize: 1,
        headless: "new",
        launchArgs: ["--no-sandbox", "--disable-setuid-sandbox"]
      },
      analysis: {
        maxConcurrentAnalyses: 1,
        timeoutMs: 120000
      }
    };

    console.log('✓ Creating UXAnalyzer...');
    const analyzer = new UXAnalyzer(config);

    console.log('✓ Starting analysis...');
    const result = await analyzer.analyze('https://example.com', {
      viewports: ['desktop'],
      analysisType: 'quick',
      includeCodeGeneration: true,
      includeAccessibility: false
    });

    console.log('\n=== ANALYSIS RESULT ===');
    console.log('Status:', result.status);
    console.log('Screenshots:', result.screenshots?.length || 0);
    console.log('Implementation code:', result.implementationCode ? 'Yes' : 'No');
    console.log('Report:', result.report ? 'Yes' : 'No');

    if (result.screenshots?.length > 0) {
      console.log('Screenshot files:');
      result.screenshots.forEach((s, i) => {
        console.log(`  ${i}: ${s.filepath} (exists: ${require('fs').existsSync(s.filepath)})`);
      });
    }

    await analyzer.cleanup();
    console.log('✅ Test completed');

  } catch (error) {
    console.error('❌ Test failed:', error.message);
    console.error(error.stack);
  }
}

testAnalysis();