- 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.
43 lines
1.2 KiB
Dart
43 lines
1.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:travel_mate/services/notification_payload_parser.dart';
|
|
|
|
void main() {
|
|
group('NotificationPayloadParser', () {
|
|
test('uses explicit type when present', () {
|
|
final action = NotificationPayloadParser.parse({
|
|
'type': 'activity',
|
|
'tripId': 'trip_1',
|
|
'activityId': 'activity_42',
|
|
});
|
|
|
|
expect(action.type, 'activity');
|
|
expect(action.tripId, 'trip_1');
|
|
expect(action.activityId, 'activity_42');
|
|
});
|
|
|
|
test('infers invitation type when invitationId exists', () {
|
|
final action = NotificationPayloadParser.parse({
|
|
'invitationId': 'inv_1',
|
|
'tripId': 'trip_1',
|
|
});
|
|
|
|
expect(action.type, 'trip_invitation');
|
|
expect(action.invitationId, 'inv_1');
|
|
});
|
|
|
|
test('infers message type when groupId exists', () {
|
|
final action = NotificationPayloadParser.parse({'groupId': 'group_1'});
|
|
|
|
expect(action.type, 'message');
|
|
expect(action.groupId, 'group_1');
|
|
});
|
|
|
|
test('falls back to trip type when only tripId exists', () {
|
|
final action = NotificationPayloadParser.parse({'tripId': 'trip_1'});
|
|
|
|
expect(action.type, 'trip');
|
|
expect(action.tripId, 'trip_1');
|
|
});
|
|
});
|
|
}
|