// ignore_for_file: avoid_print

import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
import 'package:superport/di/injection_container.dart';
import 'package:superport/data/datasources/remote/api_client.dart';
import 'license_screen_test.dart';
import '../../framework/infrastructure/test_context.dart';
import '../../framework/infrastructure/report_collector.dart';
import '../../framework/core/api_error_diagnostics.dart';
import '../../framework/core/auto_fixer.dart' as auto_fixer;
import '../../framework/core/test_data_generator.dart';

void main() {
  late LicenseScreenTest licenseScreenTest;
  late GetIt getIt;
  late ApiClient apiClient;
  late TestContext testContext;
  late ReportCollector reportCollector;
  late ApiErrorDiagnostics errorDiagnostics;
  late auto_fixer.ApiAutoFixer autoFixer;
  late TestDataGenerator dataGenerator;

  setUpAll(() async {
    // 의존성 주입 초기화
    getIt = GetIt.instance;
    await setupDependencies();
    
    // 테스트 컴포넌트 초기화
    apiClient = getIt<ApiClient>();
    testContext = TestContext();
    reportCollector = ReportCollector();
    errorDiagnostics = ApiErrorDiagnostics();
    autoFixer = auto_fixer.ApiAutoFixer(diagnostics: errorDiagnostics);
    dataGenerator = TestDataGenerator();
    
    // 라이선스 화면 테스트 인스턴스 생성
    licenseScreenTest = LicenseScreenTest(
      apiClient: apiClient,
      getIt: getIt,
      testContext: testContext,
      errorDiagnostics: errorDiagnostics,
      autoFixer: autoFixer,
      dataGenerator: dataGenerator,
      reportCollector: reportCollector,
    );
  });

  tearDownAll(() async {
    // 정리 작업
    await getIt.reset();
  });

  group('License Screen Tests', () {
    test('should run all license screen tests', () async {
      // 테스트 실행
      final result = await licenseScreenTest.runTests();
      
      // 결과 검증
      expect(result, isNotNull);
      expect(result.failedTests, equals(0), reason: '라이선스 화면 테스트 실패');
      
      // 테스트 완료 출력
      debugPrint('테스트 완료: ${result.totalTests}개 중 ${result.passedTests}개 성공');
    });
  });
}