-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-3181 Handle on click contact support
- Loading branch information
Showing
10 changed files
with
176 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
import 'package:core/utils/app_logger.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
import 'package:model/extensions/contact_support_capability_extension.dart'; | ||
import 'package:model/support/contact_support_capability.dart'; | ||
import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart'; | ||
import 'package:tmail_ui_user/main/utils/app_utils.dart'; | ||
|
||
typedef OnTapContactSupportAction = Function(ContactSupportCapability contactSupport); | ||
|
||
mixin ContactSupportMixin { | ||
|
||
void onGetHelpOrReportBug( | ||
ContactSupportCapability contactSupport, | ||
MailboxDashBoardController mailboxDashBoardController, | ||
) { | ||
log('ContactSupportMixin::onGetHelpOrReportBug:contactSupport = $contactSupport'); | ||
if (contactSupport.isMailAddressSupported) { | ||
_handleMailAddress(contactSupport.supportMailAddress!, mailboxDashBoardController); | ||
} else if (contactSupport.isHttpLinkSupported) { | ||
_handleHttpLink(contactSupport.httpLink!); | ||
} | ||
} | ||
|
||
void _handleMailAddress( | ||
String mailAddress, | ||
MailboxDashBoardController mailboxDashBoardController, | ||
) { | ||
mailboxDashBoardController.goToComposer( | ||
ComposerArguments.fromEmailAddress(EmailAddress(null, mailAddress)), | ||
); | ||
} | ||
|
||
void _handleHttpLink(String httpLink) { | ||
AppUtils.launchLink(httpLink); | ||
} | ||
} |
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
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
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
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
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
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
11 changes: 11 additions & 0 deletions
11
model/lib/extensions/contact_support_capability_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,11 @@ | ||
|
||
import 'package:model/support/contact_support_capability.dart'; | ||
|
||
extension ContactSupportCapabilityExtension on ContactSupportCapability { | ||
|
||
bool get isMailAddressSupported => | ||
supportMailAddress?.trim().isNotEmpty == true; | ||
|
||
bool get isHttpLinkSupported => | ||
httpLink?.trim().isNotEmpty == true; | ||
} |
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ import 'package:jmap_dart_client/jmap/core/session/session.dart'; | |
import 'package:jmap_dart_client/jmap/core/state.dart'; | ||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart'; | ||
import 'package:jmap_dart_client/jmap/core/user_name.dart'; | ||
import 'package:model/support/contact_support_capability.dart'; | ||
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart'; | ||
|
||
import '../../fixtures/account_fixtures.dart'; | ||
|
@@ -102,4 +103,103 @@ void main() { | |
expect(result, isNull); | ||
}); | ||
}); | ||
|
||
group('getContactSupportCapability::test', () { | ||
test('SHOULD return ContactSupportCapability WHEN ContactSupportCapability is available', () { | ||
// Arrange | ||
final contactSupportCapability = ContactSupportCapability( | ||
supportMailAddress: '[email protected]', | ||
httpLink: 'https://contact.support', | ||
); | ||
final session = Session( | ||
{ | ||
SessionExtensions.linagoraContactSupportCapability: contactSupportCapability | ||
}, | ||
{ | ||
AccountFixtures.aliceAccountId: Account( | ||
AccountName('Alice'), | ||
true, | ||
false, | ||
{ | ||
SessionExtensions.linagoraContactSupportCapability: contactSupportCapability | ||
}, | ||
) | ||
}, | ||
{}, | ||
UserName(''), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
State(''), | ||
); | ||
|
||
// Act | ||
final result = session.getContactSupportCapability(AccountFixtures.aliceAccountId); | ||
|
||
// Assert | ||
expect(result?.supportMailAddress, equals(contactSupportCapability.supportMailAddress)); | ||
expect(result?.httpLink, equals(contactSupportCapability.httpLink)); | ||
}); | ||
|
||
test('SHOULD return null WHEN ContactSupportCapability is not available', () { | ||
// Arrange | ||
final session = Session( | ||
{ | ||
SessionExtensions.linagoraContactSupportCapability: EmptyCapability() | ||
}, | ||
{ | ||
AccountFixtures.aliceAccountId: Account( | ||
AccountName('Alice'), | ||
true, | ||
false, | ||
{ | ||
SessionExtensions.linagoraContactSupportCapability: EmptyCapability() | ||
}, | ||
) | ||
}, | ||
{}, | ||
UserName(''), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
State(''), | ||
); | ||
|
||
// Act | ||
final result = session.getContactSupportCapability(AccountFixtures.aliceAccountId); | ||
|
||
// Assert | ||
expect(result, isNull); | ||
}); | ||
|
||
test('SHOULD return null WHEN ContactSupportCapability is not supported', () { | ||
// Arrange | ||
final session = Session( | ||
{}, | ||
{ | ||
AccountFixtures.aliceAccountId: Account( | ||
AccountName('Alice'), | ||
true, | ||
false, | ||
{}, | ||
) | ||
}, | ||
{}, | ||
UserName(''), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
Uri(), | ||
State(''), | ||
); | ||
|
||
// Act | ||
final result = session.getContactSupportCapability(AccountFixtures.aliceAccountId); | ||
|
||
// Assert | ||
expect(result, isNull); | ||
}); | ||
}); | ||
} |