mirror of
https://github.com/Dvorinka/1356.git
synced 2026-06-04 20:12:56 +00:00
feat: Complete Phase 1 - Full Flutter app implementation with comprehensive features
Version: 1.1.0 Major changes: - Implemented complete Flutter app structure with all core features - Added comprehensive UI screens for auth, countdown, goals, profile, settings, and social features - Integrated Supabase backend with authentication and data repositories - Added offline support with Hive caching and local storage - Implemented comprehensive routing with go_router - Added location services with Google Maps integration - Implemented notifications and home widget support - Added voice recording capabilities and AI chat features - Created comprehensive test suite and documentation - Added Android and iOS platform configurations - Implemented achievements system and social features - Added calendar integration and bucket list functionality This represents a complete Phase 1 milestone with 3,775 additions across 31 files.
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/material.dart';
|
||||
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/onboarding/presentation/onboarding_intro_screen.dart';
|
||||
import 'package:lifetimer/data/models/user_model.dart';
|
||||
import 'package:lifetimer/data/repositories/auth_repository.dart';
|
||||
|
||||
class MockAuthRepository extends AuthRepository {
|
||||
bool _isAuthenticated = false;
|
||||
|
||||
MockAuthRepository() : super(null);
|
||||
|
||||
@override
|
||||
User? get currentUser => _isAuthenticated ? TestData.createTestUser() : null;
|
||||
|
||||
@override
|
||||
Stream<User?> get authStateChanges => Stream.value(currentUser);
|
||||
|
||||
@override
|
||||
bool get isAuthenticated => _isAuthenticated;
|
||||
|
||||
@override
|
||||
String? get currentUserId => currentUser?.id;
|
||||
|
||||
@override
|
||||
Future<void> signInWithEmail(String email, String password) async {}
|
||||
|
||||
@override
|
||||
Future<void> signUpWithEmail(String email, String password, String username) async {}
|
||||
|
||||
@override
|
||||
Future<void> signInWithGoogle() async {}
|
||||
|
||||
@override
|
||||
Future<void> signInWithApple() async {}
|
||||
|
||||
@override
|
||||
Future<void> signOut() async {}
|
||||
|
||||
@override
|
||||
Future<void> resetPassword(String email) async {}
|
||||
|
||||
@override
|
||||
Future<bool> isSessionValid() async => true;
|
||||
|
||||
@override
|
||||
Future<void> refreshSession() async {}
|
||||
|
||||
@override
|
||||
Future<void> updateProfile({
|
||||
String? username,
|
||||
String? bio,
|
||||
String? avatarUrl,
|
||||
bool? isPublicProfile,
|
||||
}) async {}
|
||||
|
||||
@override
|
||||
void dispose() {}
|
||||
}
|
||||
|
||||
class TestData {
|
||||
static User createTestUser() {
|
||||
return User(
|
||||
id: 'test-user-id',
|
||||
username: 'testuser',
|
||||
email: 'test@example.com',
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('AuthGate Widget', () {
|
||||
testWidgets('should show AuthChoiceScreen when user is not authenticated',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
authRepositoryProvider.overrideWithValue(MockAuthRepository()),
|
||||
],
|
||||
child: const MaterialApp(
|
||||
home: AuthGate(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AuthChoiceScreen), findsOneWidget);
|
||||
expect(find.byType(OnboardingIntroScreen), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should show OnboardingIntroScreen when user is authenticated',
|
||||
(WidgetTester tester) async {
|
||||
final mockRepo = MockAuthRepository();
|
||||
mockRepo._isAuthenticated = true;
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
authRepositoryProvider.overrideWithValue(mockRepo),
|
||||
],
|
||||
child: const MaterialApp(
|
||||
home: AuthGate(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(OnboardingIntroScreen), findsOneWidget);
|
||||
expect(find.byType(AuthChoiceScreen), findsNothing);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
// ignore_for_file: unnecessary_const
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lifetimer/features/auth/presentation/sign_in_screen.dart';
|
||||
|
||||
void main() {
|
||||
group('SignInScreen Widget', () {
|
||||
testWidgets('should display email and password fields',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Welcome back'), findsOneWidget);
|
||||
expect(find.text('Sign in to continue your journey'), findsOneWidget);
|
||||
expect(find.byType(TextFormField), findsNWidgets(2));
|
||||
expect(find.text('Email'), findsOneWidget);
|
||||
expect(find.text('Password'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show sign in button', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign In'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show forgot password button',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Forgot password?'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show sign up link', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text("Don't have an account?"), findsOneWidget);
|
||||
expect(find.text('Sign Up'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should validate email field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find email field
|
||||
final emailField = find.widgetWithText(TextFormField, 'Email');
|
||||
await tester.enterText(emailField, 'invalid-email');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Try to submit
|
||||
final signInButton = find.text('Sign In');
|
||||
await tester.tap(signInButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should show validation error
|
||||
expect(find.text('Please enter a valid email address'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should validate password field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find password field
|
||||
final passwordField = find.widgetWithText(TextFormField, 'Password');
|
||||
await tester.enterText(passwordField, '123');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Try to submit
|
||||
final signInButton = find.text('Sign In');
|
||||
await tester.tap(signInButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should show validation error
|
||||
expect(find.text('Password must be at least 6 characters'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should toggle password visibility',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignInScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find password visibility toggle button
|
||||
final toggleButton = find.byIcon(Icons.visibility_off);
|
||||
expect(toggleButton, findsOneWidget);
|
||||
|
||||
await tester.tap(toggleButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should now show visibility icon
|
||||
expect(find.byIcon(Icons.visibility), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
// ignore_for_file: unnecessary_const
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lifetimer/features/auth/presentation/sign_up_screen.dart';
|
||||
|
||||
void main() {
|
||||
group('SignUpScreen Widget', () {
|
||||
testWidgets('should display username, email, and password fields',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Create your account'), findsOneWidget);
|
||||
expect(find.text('Start your 1356-day journey'), findsOneWidget);
|
||||
expect(find.byType(TextFormField), findsNWidgets(3));
|
||||
expect(find.text('Username'), findsOneWidget);
|
||||
expect(find.text('Email'), findsOneWidget);
|
||||
expect(find.text('Password'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show sign up button', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign Up'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show sign in link', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Already have an account?'), findsOneWidget);
|
||||
expect(find.text('Sign In'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should validate username field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find username field
|
||||
final usernameField = find.widgetWithText(TextFormField, 'Username');
|
||||
await tester.enterText(usernameField, 'ab');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Try to submit
|
||||
final signUpButton = find.text('Sign Up');
|
||||
await tester.tap(signUpButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should show validation error
|
||||
expect(find.text('Username must be at least 3 characters'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should validate email field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find email field
|
||||
final emailField = find.widgetWithText(TextFormField, 'Email');
|
||||
await tester.enterText(emailField, 'invalid-email');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Try to submit
|
||||
final signUpButton = find.text('Sign Up');
|
||||
await tester.tap(signUpButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should show validation error
|
||||
expect(find.text('Please enter a valid email address'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should validate password field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find password field
|
||||
final passwordField = find.widgetWithText(TextFormField, 'Password');
|
||||
await tester.enterText(passwordField, '123');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Try to submit
|
||||
final signUpButton = find.text('Sign Up');
|
||||
await tester.tap(signUpButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should show validation error
|
||||
expect(find.text('Password must be at least 6 characters'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should toggle password visibility',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Find password visibility toggle button
|
||||
final toggleButton = find.byIcon(Icons.visibility_off);
|
||||
expect(toggleButton, findsOneWidget);
|
||||
|
||||
await tester.tap(toggleButton);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Should now show visibility icon
|
||||
expect(find.byIcon(Icons.visibility), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show Google sign up button',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign up with Google'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should show Apple sign up button',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ProviderScope(
|
||||
child: const MaterialApp(
|
||||
home: SignUpScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign up with Apple'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user