import 'package:block_seasons/data/save_repository.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); Future freshRepo() async { SharedPreferences.setMockInitialValues({}); return SaveRepository(await SharedPreferences.getInstance()); } test('reviewRequested starts false', () async { final repo = await freshRepo(); expect(repo.reviewRequested, isFalse); }); test('markReviewRequested flips the flag and persists across reload', () async { final repo = await freshRepo(); await repo.markReviewRequested(); expect(repo.reviewRequested, isTrue); // A fresh repository over the same prefs must see the saved flag. final reloaded = SaveRepository(await SharedPreferences.getInstance()); expect(reloaded.reviewRequested, isTrue); }); test('stagesClearedCount counts distinct stages cleared with >=1 star', () async { final repo = await freshRepo(); expect(repo.stagesClearedCount, 0); await repo.recordResult( seasonId: 'season_001', stageId: 's1', stars: 1, score: 100); await repo.recordResult( seasonId: 'season_001', stageId: 's2', stars: 3, score: 300); // Replaying the same stage must not double-count. await repo.recordResult( seasonId: 'season_001', stageId: 's1', stars: 2, score: 500); expect(repo.stagesClearedCount, 2); }); }