-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3294 Fix BLUE-BAR mail to attendees duplicated recipients
- Loading branch information
Showing
5 changed files
with
115 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
lib/features/email/presentation/extensions/calendar_attendee_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
|
||
extension CalendarAttendeeExtension on CalendarAttendee { | ||
EmailAddress toEmailAddress() { | ||
return EmailAddress( | ||
name?.name, | ||
mailto?.mailAddress.value, | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
lib/features/email/presentation/extensions/calendar_organizer_extension.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_organizer.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
|
||
extension CalendarOrganizerExtension on CalendarOrganizer { | ||
EmailAddress toEmailAddress() { | ||
return EmailAddress( | ||
name, | ||
mailto?.value, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
model/test/extensions/list_email_address_extension_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
import 'package:model/extensions/email_address_extension.dart'; | ||
import 'package:model/extensions/list_email_address_extension.dart'; | ||
|
||
void main() { | ||
group('ListEmailAddressExtension::removeInvalidEmails::test', () { | ||
test('SHOULD remove email addresses that are empty', () { | ||
final emails = [ | ||
EmailAddress('Alice', '[email protected]'), | ||
EmailAddress('Bob', ''), | ||
EmailAddress('Charlie', '[email protected]'), | ||
]; | ||
|
||
final validEmails = emails.removeInvalidEmails('[email protected]'); | ||
|
||
expect(validEmails.length, 2); | ||
expect(validEmails[0].emailAddress, '[email protected]'); | ||
expect(validEmails[1].emailAddress, '[email protected]'); | ||
}); | ||
|
||
test('SHOULD remove email addresses that match the provided username', () { | ||
final emails = [ | ||
EmailAddress('Alice', '[email protected]'), | ||
EmailAddress('Bob', '[email protected]'), | ||
EmailAddress('Charlie', '[email protected]'), | ||
]; | ||
|
||
final validEmails = emails.removeInvalidEmails('[email protected]'); | ||
|
||
expect(validEmails.length, 2); | ||
expect(validEmails[0].emailAddress, '[email protected]'); | ||
expect(validEmails[1].emailAddress, '[email protected]'); | ||
}); | ||
|
||
test('SHOULD remove duplicate email addresses, keeping only the first occurrence', () { | ||
final emails = [ | ||
EmailAddress('Alice', '[email protected]'), | ||
EmailAddress('Bob', '[email protected]'), | ||
EmailAddress('Charlie', '[email protected]'), | ||
EmailAddress('David', '[email protected]'), | ||
]; | ||
|
||
final validEmails = emails.removeInvalidEmails('[email protected]'); | ||
|
||
expect(validEmails.length, 2); | ||
expect(validEmails[0].emailAddress, '[email protected]'); | ||
expect(validEmails[1].emailAddress, '[email protected]'); | ||
}); | ||
|
||
test('SHOULD return an empty list if all email addresses are invalid', () { | ||
final emails = [ | ||
EmailAddress('Alice', ''), | ||
EmailAddress('Bob', '[email protected]'), | ||
EmailAddress('Charlie', '[email protected]'), | ||
]; | ||
|
||
final validEmails = emails.removeInvalidEmails('[email protected]'); | ||
|
||
expect(validEmails.isEmpty, true); | ||
}); | ||
|
||
test('SHOULD return an empty list for an empty input list', () { | ||
final emails = <EmailAddress>[]; | ||
|
||
final validEmails = emails.removeInvalidEmails('[email protected]'); | ||
|
||
expect(validEmails.isEmpty, true); | ||
}); | ||
}); | ||
} |