#!/usr/bin/env node

/**
 * Test the Superior Screenshot API
 */

async function testSuperiorAPI() {
  console.log('🚀 Testing Superior Screenshot API')
  
  try {
    // Test 1: Single timeframe (quick test)
    console.log('\n📸 Test 1: Single Timeframe Capture')
    const singleResponse = await fetch('http://localhost:9001/api/superior-screenshot', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        symbol: 'SOLUSD',
        timeframe: '60',
        layouts: ['ai'],
        analyze: false
      })
    })
    
    const singleResult = await singleResponse.json()
    console.log('✅ Single result:', singleResult.success ? 'SUCCESS' : 'FAILED')
    console.log(`   Duration: ${singleResult.duration?.toFixed(2)}s`)
    console.log(`   Screenshots: ${singleResult.screenshots?.length || 0}`)
    
    // Test 2: Parallel scalp preset (full test)
    console.log('\n🎯 Test 2: Parallel Scalp Preset')
    const parallelResponse = await fetch('http://localhost:9001/api/superior-screenshot', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        symbol: 'SOLUSD',
        preset: 'scalp',
        layouts: ['ai', 'diy'],
        analyze: false
      })
    })
    
    const parallelResult = await parallelResponse.json()
    console.log('✅ Parallel result:', parallelResult.success ? 'SUCCESS' : 'FAILED')
    console.log(`   Duration: ${parallelResult.duration?.toFixed(2)}s`)
    console.log(`   Total Screenshots: ${parallelResult.totalScreenshots}`)
    console.log(`   Success Rate: ${parallelResult.successRate}%`)
    console.log(`   Timeframes: ${parallelResult.successfulTimeframes}/${parallelResult.totalTimeframes}`)
    
    console.log('\n🎉 Superior Screenshot API Test Completed!')
    
  } catch (error) {
    console.error('❌ Test failed:', error.message)
    process.exit(1)
  }
}

testSuperiorAPI()
