small fix, don't worry about it

This commit is contained in:
Tomas Dvorak
2026-04-10 12:05:40 +02:00
parent 7b7ed0083f
commit 5ab2773f98
55 changed files with 3240 additions and 483 deletions
@@ -3,10 +3,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:lifetimer/features/auth/application/auth_controller.dart';
import 'package:lifetimer/features/auth/presentation/auth_gate.dart';
import 'package:lifetimer/features/auth/presentation/auth_choice_screen.dart';
import 'package:lifetimer/features/auth/presentation/auth_showcase_screen.dart';
import 'package:lifetimer/features/onboarding/presentation/onboarding_intro_screen.dart';
import 'package:lifetimer/features/onboarding/application/onboarding_controller.dart';
import 'package:lifetimer/data/models/user_model.dart';
import 'package:lifetimer/data/repositories/auth_repository.dart';
import 'package:lifetimer/core/utils/unit_conversion_utils.dart';
class MockAuthRepository extends AuthRepository {
bool _isAuthenticated = false;
@@ -29,13 +31,14 @@ class MockAuthRepository extends AuthRepository {
Future<void> signInWithEmail(String email, String password) async {}
@override
Future<void> signUpWithEmail(String email, String password, String username) async {}
Future<void> signUpWithEmail(String email, String password, String username, {double? heightCm, double? weightKg, int? age, Gender? gender, HeightUnit? heightUnit, WeightUnit? weightUnit}) async {}
@override
Future<void> signInWithGoogle() async {}
@override
Future<void> signInWithApple() async {}
Future<void> signInWithApple() async {
// Mock implementation
}
@override
Future<void> signOut() async {}
@@ -55,12 +58,27 @@ class MockAuthRepository extends AuthRepository {
String? bio,
String? avatarUrl,
bool? isPublicProfile,
double? heightCm,
double? weightKg,
int? age,
Gender? gender,
HeightUnit? heightUnit,
WeightUnit? weightUnit,
}) async {}
@override
void dispose() {}
}
class MockOnboardingController extends OnboardingController {
MockOnboardingController() : super();
@override
Future<void> loadOnboardingStatus() async {
// Do nothing in test
}
}
class TestData {
static User createTestUser() {
return User(
@@ -75,23 +93,28 @@ class TestData {
void main() {
group('AuthGate Widget', () {
testWidgets('should show AuthChoiceScreen when user is not authenticated',
testWidgets('should continue to onboarding when backend is unavailable and user is not authenticated',
(WidgetTester tester) async {
await tester.pumpWidget(
ProviderScope(
overrides: [
authRepositoryProvider.overrideWithValue(MockAuthRepository()),
onboardingControllerProvider.overrideWith((ref) => MockOnboardingController()),
],
child: const MaterialApp(
home: AuthGate(),
child: MaterialApp(
home: const AuthGate(),
builder: (context, child) => MediaQuery(
data: const MediaQueryData(size: Size(800, 600)),
child: child!,
),
),
),
);
await tester.pumpAndSettle();
expect(find.byType(AuthChoiceScreen), findsOneWidget);
expect(find.byType(OnboardingIntroScreen), findsNothing);
expect(find.byType(OnboardingIntroScreen), findsOneWidget);
expect(find.byType(AuthShowcaseScreen), findsNothing);
});
testWidgets('should show OnboardingIntroScreen when user is authenticated',
@@ -103,9 +126,14 @@ void main() {
ProviderScope(
overrides: [
authRepositoryProvider.overrideWithValue(mockRepo),
onboardingControllerProvider.overrideWith((ref) => MockOnboardingController()),
],
child: const MaterialApp(
home: AuthGate(),
child: MaterialApp(
home: const AuthGate(),
builder: (context, child) => MediaQuery(
data: const MediaQueryData(size: Size(800, 600)),
child: child!,
),
),
),
);
@@ -113,7 +141,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byType(OnboardingIntroScreen), findsOneWidget);
expect(find.byType(AuthChoiceScreen), findsNothing);
expect(find.byType(AuthShowcaseScreen), findsNothing);
});
});
}