import 'package:block_seasons/services/analytics_service.dart';
import 'package:flutter_test/flutter_test.dart';

class _RecordingBackend implements AnalyticsBackend {
  final events = <(String, Map<String, Object>)>[];

  @override
  void logEvent(String name, Map<String, Object> params) {
    events.add((name, params));
  }
}

void main() {
  test('typed helpers produce stable event names and params', () {
    final backend = _RecordingBackend();
    final analytics = AnalyticsService(backend);

    analytics.stageStart(seasonId: 'season_001', stageId: 's1');
    analytics.stageEnd(
      seasonId: 'season_001',
      stageId: 's1',
      won: true,
      stars: 3,
      score: 1200,
      movesUsed: 9,
    );
    analytics.endlessStart();
    analytics.endlessEnd(score: 500, isNewBest: true);
    analytics.rescueUsed(type: 'continue');
    analytics.tutorialFinished(skipped: false);

    expect(backend.events.map((e) => e.$1).toList(), [
      'stage_start',
      'stage_end',
      'endless_start',
      'endless_end',
      'rescue_used',
      'tutorial_finished',
    ]);
    expect(backend.events[1].$2, {
      'season_id': 'season_001',
      'stage_id': 's1',
      'won': 1,
      'stars': 3,
      'score': 1200,
      'moves_used': 9,
    });
    expect(backend.events[3].$2, {'score': 500, 'new_best': 1});
  });
}
