-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-2528 Add integration test for search email with sort by sender nam…
…e ascending
- Loading branch information
Showing
9 changed files
with
182 additions
and
12 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
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,51 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; | ||
|
||
import '../base/core_robot.dart'; | ||
|
||
class SearchRobot extends CoreRobot { | ||
SearchRobot(super.$); | ||
|
||
Future<void> enterQueryString(String queryString) async { | ||
await $(#search_email_text_field).enterText(queryString); | ||
await ensureViewVisible($(#suggestion_search_list_view)); | ||
} | ||
|
||
Future<void> scrollToEndListSearchFilter() async { | ||
await $.scrollUntilVisible( | ||
finder: $(#mobile_sortBy_search_filter_button), | ||
view: $(#search_filter_list_view), | ||
scrollDirection: AxisDirection.right, | ||
delta: 300, | ||
); | ||
await ensureViewVisible($(#mobile_sortBy_search_filter_button)); | ||
} | ||
|
||
Future<void> openSortOrderBottomDialog() async { | ||
await $(#mobile_sortBy_search_filter_button).tap(); | ||
await ensureViewVisible($(#sort_filter_context_menu)); | ||
} | ||
|
||
Future<void> selectSenderAscending() async { | ||
await $(find.text(AppLocalizations().senderAscending)).tap(); | ||
await Future.delayed(const Duration(seconds: 2)); | ||
await ensureViewVisible($(#search_email_list_notification_listener)); | ||
} | ||
|
||
Future<void> expectEmailListDisplayedInFullOrder({ | ||
required String queryString, | ||
required List<EmailAddress> recipientListSorted, | ||
}) async { | ||
expect( | ||
find.byType(ListTile), | ||
findsNWidgets(recipientListSorted.length), | ||
); | ||
|
||
for (var i = 0; i < recipientListSorted.length; i++) { | ||
final itemFinder = find.text('$queryString ${recipientListSorted[i].name}'); | ||
expect(itemFinder, findsOneWidget); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
import 'package:model/model.dart'; | ||
|
||
import '../base/base_scenario.dart'; | ||
import '../robots/composer_robot.dart'; | ||
import '../robots/search_robot.dart'; | ||
import '../robots/thread_robot.dart'; | ||
import 'login_with_basic_auth_scenario.dart'; | ||
|
||
class SearchEmailScenario extends BaseScenario { | ||
const SearchEmailScenario( | ||
super.$, | ||
{ | ||
required this.loginWithBasicAuthScenario, | ||
required this.queryString, | ||
required this.recipientListSorted, | ||
} | ||
); | ||
|
||
final LoginWithBasicAuthScenario loginWithBasicAuthScenario; | ||
final String queryString; | ||
final List<EmailAddress> recipientListSorted; | ||
|
||
@override | ||
Future<void> execute() async { | ||
await loginWithBasicAuthScenario.execute(); | ||
|
||
final threadRobot = ThreadRobot($); | ||
final composerRobot = ComposerRobot($); | ||
|
||
for (var i = 0; i < recipientListSorted.length; i++) { | ||
await threadRobot.openComposer(); | ||
await composerRobot.grantContactPermission(); | ||
await composerRobot.addRecipient(recipientListSorted[i].emailAddress); | ||
await composerRobot.addSubject('Subject'); | ||
await composerRobot.addContent('$queryString ${recipientListSorted[i].name}'); | ||
await composerRobot.sendEmail(); | ||
await composerRobot.expectSendEmailSuccessToast(); | ||
// Send each email after 2s | ||
await Future.delayed(const Duration(seconds: 2)); | ||
} | ||
|
||
await threadRobot.openSearchView(); | ||
|
||
final searchRobot = SearchRobot($); | ||
await searchRobot.enterQueryString(queryString); | ||
await searchRobot.scrollToEndListSearchFilter(); | ||
await searchRobot.openSortOrderBottomDialog(); | ||
await searchRobot.selectSenderAscending(); | ||
|
||
await searchRobot.expectEmailListDisplayedInFullOrder( | ||
queryString: queryString, | ||
recipientListSorted: recipientListSorted, | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; | ||
|
||
import '../../base/test_base.dart'; | ||
import '../../scenarios/login_with_basic_auth_scenario.dart'; | ||
import '../../scenarios/search_email_scenario.dart'; | ||
|
||
void main() { | ||
TestBase().runPatrolTest( | ||
description: 'Should see list email sort by SenderName ascending when search email successfully', | ||
test: ($) async { | ||
const username = String.fromEnvironment('USERNAME'); | ||
const password = String.fromEnvironment('PASSWORD'); | ||
const hostUrl = String.fromEnvironment('BASIC_AUTH_URL'); | ||
const email = String.fromEnvironment('BASIC_AUTH_EMAIL'); | ||
|
||
final loginWithBasicAuthScenario = LoginWithBasicAuthScenario( | ||
$, | ||
username: username, | ||
password: password, | ||
hostUrl: hostUrl, | ||
email: email, | ||
); | ||
|
||
const queryString = 'Hello'; | ||
final recipientList = [ | ||
EmailAddress('alice1', '[email protected]'), | ||
EmailAddress('alice2', '[email protected]'), | ||
EmailAddress('alice3', '[email protected]'), | ||
]; | ||
|
||
final searchEmailScenario = SearchEmailScenario( | ||
$, | ||
loginWithBasicAuthScenario: loginWithBasicAuthScenario, | ||
queryString: queryString, | ||
recipientListSorted: recipientList, | ||
); | ||
|
||
await searchEmailScenario.execute(); | ||
}, | ||
); | ||
} |
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