/**
 * E2E Test Setup
 * 端到端测试环境设置
 */

// 增加测试超时时间
jest.setTimeout(60000);

// 设置测试环境变量
process.env.NODE_ENV = 'test';
process.env.DATABASE_URL = process.env.DATABASE_URL || 'postgresql://postgres:postgres@localhost:5432/referral_test?schema=public';
process.env.REDIS_HOST = process.env.REDIS_HOST || 'localhost';
process.env.REDIS_PORT = process.env.REDIS_PORT || '6379';
process.env.KAFKA_BROKERS = process.env.KAFKA_BROKERS || 'localhost:9092';
process.env.JWT_SECRET = 'test-jwt-secret-for-e2e-tests';
process.env.PORT = '3099'; // 使用不同的端口避免冲突

// 全局清理
afterAll(async () => {
  // 等待所有异步操作完成
  await new Promise((resolve) => setTimeout(resolve, 1000));
});
