#!/usr/bin/env node /** * Simple test script using curl to test the enhanced screenshot service */ const { execSync } = require('child_process'); async function testScreenshotService() { console.log('šŸš€ Testing Enhanced Screenshot Service with curl'); try { // Test the API endpoint console.log('\nšŸ” Testing API endpoint...'); const curlCommand = `curl -X POST http://localhost:3000/api/enhanced-screenshot \\ -H "Content-Type: application/json" \\ -d '{"symbol": "SOLUSD", "timeframe": "240", "layouts": ["ai"]}' \\ --max-time 120 \\ --silent \\ --show-error`; console.log('šŸ“ž Making API request...'); const startTime = Date.now(); const result = execSync(curlCommand, { encoding: 'utf8', maxBuffer: 1024 * 1024 }); const endTime = Date.now(); const duration = (endTime - startTime) / 1000; console.log('\nāœ… API Response received!'); console.log(`ā±ļø Duration: ${duration.toFixed(2)} seconds`); console.log('šŸ“„ Response:', result.slice(0, 500) + (result.length > 500 ? '...' : '')); try { const parsed = JSON.parse(result); if (parsed.screenshots) { console.log(`šŸ“ø Screenshots: ${parsed.screenshots.length}`); parsed.screenshots.forEach((screenshot, index) => { console.log(` ${index + 1}. ${screenshot}`); }); } if (parsed.errors) { console.log('āŒ Errors:'); parsed.errors.forEach((error, index) => { console.log(` ${index + 1}. ${error}`); }); } } catch (parseError) { console.log('āš ļø Response is not valid JSON, raw response:', result); } } catch (error) { console.error('\nāŒ Test failed:', error.message); console.error('Error details:', error.stdout || error.stderr || 'No additional details'); } } // Run the test testScreenshotService();