-
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-3292 Write integration test for search emails by date and then sor…
…t them by relevance
- Loading branch information
Showing
5 changed files
with
189 additions
and
10 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
101 changes: 101 additions & 0 deletions
101
integration_test/scenarios/search_email_by_date_time_and_sort_order_relevance_scenario.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,101 @@ | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_receive_time_type.dart'; | ||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/email_sort_order_type.dart'; | ||
import 'package:tmail_ui_user/features/search/email/presentation/search_email_view.dart'; | ||
import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_builder.dart'; | ||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; | ||
|
||
import '../base/base_scenario.dart'; | ||
import '../models/provisioning_email.dart'; | ||
import '../robots/search_robot.dart'; | ||
import '../robots/thread_robot.dart'; | ||
import '../utils/scenario_utils_mixin.dart'; | ||
import 'login_with_basic_auth_scenario.dart'; | ||
|
||
class SearchEmailByDatetimeAndSortOrderRelevanceScenario extends BaseScenario | ||
with ScenarioUtilsMixin { | ||
|
||
const SearchEmailByDatetimeAndSortOrderRelevanceScenario( | ||
super.$, | ||
{ | ||
required this.loginWithBasicAuthScenario, | ||
required this.queryString, | ||
required this.listProvisioningEmail, | ||
} | ||
); | ||
|
||
final LoginWithBasicAuthScenario loginWithBasicAuthScenario; | ||
final String queryString; | ||
final List<ProvisioningEmail> listProvisioningEmail; | ||
|
||
@override | ||
Future<void> execute() async { | ||
await loginWithBasicAuthScenario.execute(); | ||
|
||
await provisionEmail(listProvisioningEmail); | ||
await $.pumpAndSettle(); | ||
|
||
final threadRobot = ThreadRobot($); | ||
await threadRobot.openSearchView(); | ||
await _expectSearchViewVisible(); | ||
|
||
final searchRobot = SearchRobot($); | ||
await searchRobot.enterQueryString(queryString); | ||
await _expectSuggestionSearchListViewVisible(); | ||
|
||
await searchRobot.scrollToDateTimeButtonFilter(); | ||
await _expectDateTimeSearchFilterButtonVisible(); | ||
|
||
await Future.delayed(const Duration(seconds: 2)); | ||
|
||
await searchRobot.openDateTimeBottomDialog(); | ||
await _expectDateTimeFilterContextMenuVisible(); | ||
|
||
final appLocalizations = AppLocalizations(); | ||
await searchRobot.selectDateTime( | ||
EmailReceiveTimeType.last7Days.getTitleByAppLocalizations(appLocalizations), | ||
); | ||
await _expectSearchResultEmailListVisible(); | ||
|
||
await Future.delayed(const Duration(seconds: 2)); | ||
|
||
await searchRobot.openSortOrderBottomDialog(); | ||
await _expectSortFilterContextMenuVisible(); | ||
await searchRobot.selectSortOrder( | ||
EmailSortOrderType.relevance.getTitleByAppLocalizations(appLocalizations), | ||
); | ||
await _expectSearchResultEmailListVisible(); | ||
|
||
await _expectEmailListDisplayedCorrectly(); | ||
} | ||
|
||
|
||
Future<void> _expectSearchViewVisible() async { | ||
await expectViewVisible($(SearchEmailView)); | ||
} | ||
|
||
Future<void> _expectSuggestionSearchListViewVisible() async { | ||
await expectViewVisible($(#suggestion_search_list_view)); | ||
} | ||
|
||
Future<void> _expectDateTimeSearchFilterButtonVisible() async { | ||
await expectViewVisible($(#mobile_dateTime_search_filter_button)); | ||
} | ||
|
||
Future<void> _expectDateTimeFilterContextMenuVisible() async { | ||
await expectViewVisible($(#date_time_filter_context_menu)); | ||
} | ||
|
||
Future<void> _expectSearchResultEmailListVisible() async { | ||
await expectViewVisible($(#search_email_list_notification_listener)); | ||
} | ||
|
||
Future<void> _expectSortFilterContextMenuVisible() async { | ||
await expectViewVisible($(#sort_filter_context_menu)); | ||
} | ||
|
||
Future<void> _expectEmailListDisplayedCorrectly() async { | ||
expect(find.byType(EmailTileBuilder), findsNWidgets(listProvisioningEmail.length)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
integration_test/tests/search/search_email_by_date_time_and_sort_order_relevance_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,44 @@ | ||
import '../../base/test_base.dart'; | ||
import '../../models/provisioning_email.dart'; | ||
import '../../scenarios/login_with_basic_auth_scenario.dart'; | ||
import '../../scenarios/search_email_by_date_time_and_sort_order_relevance_scenario.dart'; | ||
|
||
void main() { | ||
TestBase().runPatrolTest( | ||
description: 'Should see list email displayed by date time `Last 7 days` and sort order `Relevance` 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 = 'relevance'; | ||
const listUsername = ['Alice', 'Brian', 'Charlotte', 'David', 'Emma']; | ||
|
||
final listProvisioningEmail = listUsername | ||
.map((username) => ProvisioningEmail( | ||
toEmail: '${username.toLowerCase()}@example.com', | ||
subject: queryString, | ||
content: '$queryString to user $username', | ||
)) | ||
.toList(); | ||
|
||
final searchEmailByDatetimeAndSortOrderRelevanceScenario = SearchEmailByDatetimeAndSortOrderRelevanceScenario( | ||
$, | ||
loginWithBasicAuthScenario: loginWithBasicAuthScenario, | ||
queryString: queryString, | ||
listProvisioningEmail: listProvisioningEmail, | ||
); | ||
|
||
await searchEmailByDatetimeAndSortOrderRelevanceScenario.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