feat: Implement trip invitation functionality and notification handling
- Added TripInvitationRepository for managing trip invitations. - Created TripInvitation model with serialization methods. - Implemented notification payload parser for handling FCM notifications. - Enhanced NotificationService to manage trip invitations and related actions. - Updated UserRepository to include user search functionality. - Modified AuthRepository to store multiple FCM tokens. - Added tests for trip invitation logic and notification payload parsing. - Updated pubspec.yaml and pubspec.lock for dependency management.
This commit is contained in:
@@ -8,16 +8,22 @@ import 'package:travel_mate/blocs/auth/auth_state.dart';
|
||||
import 'package:travel_mate/repositories/auth_repository.dart';
|
||||
import 'package:travel_mate/models/user.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_core_platform_interface/test.dart';
|
||||
|
||||
import 'package:travel_mate/services/notification_service.dart';
|
||||
import 'package:travel_mate/services/analytics_service.dart';
|
||||
|
||||
import 'auth_bloc_test.mocks.dart';
|
||||
|
||||
@GenerateMocks([AuthRepository, NotificationService])
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('AuthBloc', () {
|
||||
late MockAuthRepository mockAuthRepository;
|
||||
late MockNotificationService mockNotificationService;
|
||||
late FakeAnalyticsService fakeAnalyticsService;
|
||||
late AuthBloc authBloc;
|
||||
|
||||
final user = User(
|
||||
@@ -28,12 +34,19 @@ void main() {
|
||||
platform: 'email',
|
||||
);
|
||||
|
||||
setUpAll(() async {
|
||||
setupFirebaseCoreMocks();
|
||||
await Firebase.initializeApp();
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
mockAuthRepository = MockAuthRepository();
|
||||
mockNotificationService = MockNotificationService();
|
||||
fakeAnalyticsService = FakeAnalyticsService();
|
||||
authBloc = AuthBloc(
|
||||
authRepository: mockAuthRepository,
|
||||
notificationService: mockNotificationService,
|
||||
analyticsService: fakeAnalyticsService,
|
||||
);
|
||||
|
||||
// Default stub for saveTokenToFirestore to avoid strict mock errors
|
||||
@@ -128,3 +141,14 @@ class MockFirebaseUser extends Mock implements firebase_auth.User {
|
||||
|
||||
MockFirebaseUser({required this.uid, this.email});
|
||||
}
|
||||
|
||||
class FakeAnalyticsService extends AnalyticsService {
|
||||
@override
|
||||
Future<void> logEvent({
|
||||
required String name,
|
||||
Map<String, Object>? parameters,
|
||||
}) async {}
|
||||
|
||||
@override
|
||||
Future<void> setUserId(String? id) async {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user