#!/usr/bin/env node

import { TradingViewAutomation } from './lib/tradingview-automation.js'

async function testPuppeteerLogin() {
  console.log('🧪 Testing Puppeteer TradingView Login...')
  
  const automation = TradingViewAutomation.getInstance()
  
  try {
    console.log('1. Initializing browser...')
    await automation.init()
    
    console.log('2. Testing login...')
    const loginSuccess = await automation.login()
    
    if (loginSuccess) {
      console.log('✅ SUCCESS: Login test passed!')
      
      console.log('3. Testing navigation...')
      await automation.navigateToSymbol('SOLUSD', '240')
      
      console.log('4. Taking test screenshot...')
      await automation.takeScreenshot({ filename: 'puppeteer_test.png' })
      
      console.log('✅ All tests passed!')
    } else {
      console.log('❌ FAILED: Login test failed')
    }
    
  } catch (error) {
    console.error('❌ TEST FAILED:', error)
  } finally {
    await automation.forceCleanup()
  }
}

testPuppeteerLogin()
