Feature Pack with bug fixes for V2

This commit is contained in:
Ujwal223
2026-06-13 13:06:25 +05:45
parent 39b6545e4a
commit b7c8120496
41 changed files with 453 additions and 414 deletions
+6 -21
View File
@@ -1,6 +1,5 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:focusgram/services/level_service.dart';
@@ -9,7 +8,6 @@ void main() {
setUp(() async {
SharedPreferences.setMockInitialValues({});
// Ensure Hive is available for LevelService
if (!Hive.isAdapterRegistered(0)) {
await Hive.initFlutter();
}
@@ -17,13 +15,9 @@ void main() {
group('AppFeature — Your Journey unlock table', () {
test('fullDmGhost is NOT in the all list', () async {
// fullDmGhost should still be defined as a constant
expect(AppFeature.fullDmGhost, isNotNull);
// But should NOT appear in the unlock table shown to users
final contains = AppFeature.all.any(
(f) => f.id == 'full_dm_ghost',
);
final contains = AppFeature.all.any((f) => f.id == 'full_dm_ghost');
expect(contains, isFalse);
});
@@ -47,20 +41,12 @@ void main() {
group('LevelService — No Firestore dependency', () {
test('init succeeds without Firestore (uses Hive only)', () async {
// This would crash if init tried to reach Firestore
// Since we removed Firebase, it should work with just Hive cache
final levelService = LevelService();
// Should not throw — even if no Firestore is available
await expectLater(
() => levelService.init(),
returnsNormally,
);
await expectLater(() => levelService.init(), returnsNormally);
// Default state
expect(levelService.level, equals(1));
expect(levelService.xp, equals(0));
expect(levelService.synced, isFalse);
});
test('addXpForAd awards XP without Firestore', () async {
@@ -73,14 +59,13 @@ void main() {
expect(levelService.adsWatchedTotal, equals(1));
});
test('debugSetLevel works with Hive-only storage', () async {
test('level progresses from XP', () async {
final levelService = LevelService();
await levelService.init();
await levelService.debugSetLevel(3, 300);
expect(levelService.level, equals(3));
expect(levelService.xp, equals(300));
expect(levelService.level, equals(1));
expect(levelService.xp, equals(0));
expect(levelService.levelProgress, equals(0.0));
});
});
}