TF-4229 Add integration test on mobile for case search_email_with_tag_scenario
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tmail_ui_user/features/base/widget/context_menu/context_menu_dialog_item.dart';
|
||||
|
||||
import '../base/core_robot.dart';
|
||||
|
||||
class LabelListContextMenuRobot extends CoreRobot {
|
||||
LabelListContextMenuRobot(super.$);
|
||||
|
||||
Future<void> selectLabelByName(String name) async {
|
||||
final item = $(ContextMenuDialogItem).$(name);
|
||||
await $.scrollUntilVisible(finder: item);
|
||||
await item.tap();
|
||||
}
|
||||
}
|
||||
@@ -95,4 +95,8 @@ class SearchRobot extends CoreRobot {
|
||||
);
|
||||
await $(#mobile_hasAttachment_search_filter_button).tap();
|
||||
}
|
||||
|
||||
Future<void> openLabelListModal() async {
|
||||
await $(#mobile_labels_search_filter_button).tap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:labels/labels.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 '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../robots/label_list_context_menu_robot.dart';
|
||||
import '../../robots/search_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class SearchEmailWithTagScenario extends BaseTestScenario
|
||||
with ProvisioningLabelScenarioMixin {
|
||||
const SearchEmailWithTagScenario(super.$);
|
||||
|
||||
@override
|
||||
Future<void> setupPreLogin() async {
|
||||
PlatformInfo.isIntegrationTesting = true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> runTestLogic() async {
|
||||
const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL');
|
||||
|
||||
final threadRobot = ThreadRobot($);
|
||||
final searchRobot = SearchRobot($);
|
||||
final labelListContextMenuRobot = LabelListContextMenuRobot($);
|
||||
|
||||
final labels = await provisionLabelsByDisplayNames(
|
||||
['Search Tag 1', 'Search Tag 2', 'Search Tag 3'],
|
||||
);
|
||||
await $.pumpAndSettle();
|
||||
|
||||
int emailCount = 3;
|
||||
for (final label in labels) {
|
||||
await provisionEmail(
|
||||
buildEmailsForLabel(
|
||||
label: label,
|
||||
toEmail: emailUser,
|
||||
count: emailCount,
|
||||
),
|
||||
requestReadReceipt: false,
|
||||
);
|
||||
}
|
||||
await $.pumpAndSettle(duration: const Duration(seconds: 2));
|
||||
|
||||
await threadRobot.openSearchView();
|
||||
await _expectSearchViewVisible();
|
||||
|
||||
for (final label in labels) {
|
||||
final labelDisplayName = label.safeDisplayName;
|
||||
|
||||
await searchRobot.openLabelListModal();
|
||||
await _expectLabelListContextMenuVisible();
|
||||
|
||||
await labelListContextMenuRobot.selectLabelByName(labelDisplayName);
|
||||
await _expectEmailListDisplayedCorrectByTag(
|
||||
tagDisplayName: labelDisplayName,
|
||||
emailCount: emailCount,
|
||||
);
|
||||
|
||||
await $.pumpAndSettle(duration: const Duration(seconds: 1));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _expectSearchViewVisible() async {
|
||||
await expectViewVisible($(SearchEmailView));
|
||||
}
|
||||
|
||||
Future<void> _expectLabelListContextMenuVisible() async {
|
||||
await expectViewVisible($(#label_list_bottom_sheet_context_menu));
|
||||
}
|
||||
|
||||
Future<void> _expectEmailListDisplayedCorrectByTag({
|
||||
required String tagDisplayName,
|
||||
required int emailCount,
|
||||
}) async {
|
||||
final listEmailTileWithTag = $.tester.widgetList<EmailTileBuilder>(
|
||||
$(EmailTileBuilder).which<EmailTileBuilder>((widget) =>
|
||||
widget.presentationEmail.subject?.contains(tagDisplayName) == true),
|
||||
);
|
||||
|
||||
expect(listEmailTileWithTag.length, greaterThanOrEqualTo(emailCount));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> disposeAfterTest() async {
|
||||
PlatformInfo.isIntegrationTesting = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import '../../base/test_base.dart';
|
||||
import '../../scenarios/search/search_email_with_tag_scenario.dart';
|
||||
|
||||
void main() {
|
||||
TestBase().runPatrolTest(
|
||||
description: 'Should display email list correctly when search with tag',
|
||||
scenarioBuilder: ($) => SearchEmailWithTagScenario($),
|
||||
);
|
||||
}
|
||||
@@ -81,6 +81,7 @@ mixin SearchLabelFilterModalMixin on PopupContextMenuActionMixin {
|
||||
}).toList();
|
||||
|
||||
openBottomSheetContextMenuAction(
|
||||
key: const Key('label_list_bottom_sheet_context_menu'),
|
||||
context: context,
|
||||
itemActions: contextMenuActions,
|
||||
onContextMenuActionClick: (menuAction) {
|
||||
|
||||
@@ -753,14 +753,12 @@ class SearchEmailView extends GetWidget<SearchEmailController>
|
||||
|
||||
final isLabelAvailable = dashboardController.isLabelAvailable;
|
||||
|
||||
final labelController = dashboardController.labelController;
|
||||
final listLabels = dashboardController.labelController.labels;
|
||||
|
||||
List<Label>? emailLabels;
|
||||
|
||||
if (isLabelAvailable) {
|
||||
emailLabels = presentationEmail.getLabelList(
|
||||
labelController.labels,
|
||||
);
|
||||
emailLabels = presentationEmail.getLabelList(listLabels);
|
||||
}
|
||||
|
||||
return EmailTileBuilder(
|
||||
|
||||
@@ -622,15 +622,13 @@ class ThreadView extends GetWidget<ThreadController>
|
||||
final isLabelAvailable = controller
|
||||
.mailboxDashBoardController.isLabelAvailable;
|
||||
|
||||
final labelController =
|
||||
controller.mailboxDashBoardController.labelController;
|
||||
final listLabels =
|
||||
controller.mailboxDashBoardController.labelController.labels;
|
||||
|
||||
List<Label>? emailLabels;
|
||||
|
||||
if (isLabelAvailable) {
|
||||
emailLabels = presentationEmail.getLabelList(
|
||||
labelController.labels,
|
||||
);
|
||||
emailLabels = presentationEmail.getLabelList(listLabels);
|
||||
}
|
||||
|
||||
return Dismissible(
|
||||
|
||||
Reference in New Issue
Block a user