#!/usr/bin/env node
/**
 * 测试新框架
 */
require('dotenv').config();
const { AutomationFactory } = require('./src/tools/automation-framework');
const logger = require('./src/shared/logger');

async function test() {
  try {
    logger.info('Test', '========================================');
    logger.info('Test', '🚀 开始测试新框架');
    logger.info('Test', '========================================');
    
    // 使用 AdsPower 浏览器（从 .env 或参数获取）
    const adspowerUserId = process.env.ADSPOWER_USER_ID || 'k1728p8l';
    
    logger.info('Test', `使用 Profile: ${adspowerUserId}`);
    
    const result = await AutomationFactory.registerWithAdsPower('windsurf', adspowerUserId);
    
    logger.info('Test', '========================================');
    
    if (result.success) {
      logger.success('Test', '✅ 注册成功！');
      logger.info('Test', `邮箱: ${result.accountData?.email}`);
      logger.info('Test', `密码: ${result.accountData?.password}`);
      logger.info('Test', `卡号: ${result.cardInfo?.number}`);
    } else {
      logger.error('Test', '❌ 注册失败');
      logger.error('Test', `错误: ${result.error}`);
    }
    
    logger.info('Test', '========================================');
    
  } catch (error) {
    logger.error('Test', `测试异常: ${error.message}`);
    console.error(error);
    process.exit(1);
  }
}

test();
