TF-4301 Add E2E tests for label creation and tagging from email view
This commit is contained in:
@@ -51,6 +51,10 @@ class EmailRobot extends CoreRobot {
|
||||
await $(AppLocalizations().starred).tap();
|
||||
}
|
||||
|
||||
Future<void> tapEmailDetailedLabelAsOptionInContextMenu() async {
|
||||
await $(#labelAs_action).tap();
|
||||
}
|
||||
|
||||
Future<void> tapEmailDetailedUnstarButton() async {
|
||||
await $(AppLocalizations().not_starred).tap();
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/widgets/labels/label_list_item.dart';
|
||||
|
||||
import '../base/core_robot.dart';
|
||||
|
||||
class LabelRobot extends CoreRobot {
|
||||
LabelRobot(super.$);
|
||||
|
||||
Future<void> openLabelByName(String name) async {
|
||||
final item = $(LabelListItem).$(name);
|
||||
await $.scrollUntilVisible(finder: item);
|
||||
await item.tap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../base/core_robot.dart';
|
||||
|
||||
class AddLabelModalRobot extends CoreRobot {
|
||||
AddLabelModalRobot(super.$);
|
||||
|
||||
Future<void> tapCreateANewLabel() async {
|
||||
await $(#create_a_new_label_button).tap();
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,10 @@ class LabelRobot extends CoreRobot {
|
||||
Future<void> tapCreateNewLabelButton() async {
|
||||
await $(#labels_bar_widget_add_new_label_button).tap();
|
||||
}
|
||||
|
||||
Future<void> openLabelByName(String name) async {
|
||||
final item = $(LabelListItem).$(name);
|
||||
await $.scrollUntilVisible(finder: item);
|
||||
await item.tap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../models/provisioning_email.dart';
|
||||
import '../../robots/email_robot.dart';
|
||||
import '../../robots/labels/add_label_modal_robot.dart';
|
||||
import '../../robots/labels/create_label_modal_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class CreateANewTagFromAnEmailScenario extends BaseTestScenario
|
||||
with ProvisioningLabelScenarioMixin {
|
||||
const CreateANewTagFromAnEmailScenario(super.$);
|
||||
|
||||
@override
|
||||
Future<void> runTestLogic() async {
|
||||
const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL');
|
||||
expect(emailUser, isNotEmpty, reason: 'BASIC_AUTH_EMAIL must be set');
|
||||
|
||||
const subject = 'Create new label from email';
|
||||
|
||||
final threadRobot = ThreadRobot($);
|
||||
final emailRobot = EmailRobot($);
|
||||
final addLabelModalRobot = AddLabelModalRobot($);
|
||||
final createLabelModalRobot = CreateLabelModalRobot($);
|
||||
|
||||
await provisionEmail(
|
||||
[
|
||||
ProvisioningEmail(
|
||||
toEmail: emailUser,
|
||||
subject: subject,
|
||||
content: subject,
|
||||
),
|
||||
],
|
||||
requestReadReceipt: false,
|
||||
);
|
||||
await $.pumpAndSettle();
|
||||
|
||||
await threadRobot.openEmailWithSubject(subject);
|
||||
await $.pumpAndSettle();
|
||||
await emailRobot.tapEmailDetailedMoreButton();
|
||||
await _expectEmailDetailedLabelAsOptionVisible();
|
||||
|
||||
await emailRobot.tapEmailDetailedLabelAsOptionInContextMenu();
|
||||
await _expectAddLabelModalVisible();
|
||||
|
||||
await addLabelModalRobot.tapCreateANewLabel();
|
||||
await _expectCreateNewLabelModalVisible();
|
||||
|
||||
const newLabelName = 'New Label 1';
|
||||
await createLabelModalRobot.enterNewLabelName(newLabelName);
|
||||
await createLabelModalRobot.tapPositiveActionButton(LabelActionType.create);
|
||||
await _expectLabelAsToEmailToastMessageSuccessVisible(
|
||||
AppLocalizations().addLabelToEmailSuccessfullyMessage(newLabelName),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _expectEmailDetailedLabelAsOptionVisible() async {
|
||||
await expectViewVisible($(#labelAs_action));
|
||||
}
|
||||
|
||||
Future<void> _expectAddLabelModalVisible() async {
|
||||
await expectViewVisible($(#add_label_to_email_modal));
|
||||
}
|
||||
|
||||
Future<void> _expectCreateNewLabelModalVisible() async {
|
||||
await expectViewVisible($(#create_new_label_modal));
|
||||
}
|
||||
|
||||
Future<void> _expectLabelAsToEmailToastMessageSuccessVisible(String name) async {
|
||||
await expectViewVisible($(find.text(name)));
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../robots/label_robot.dart';
|
||||
import '../../robots/labels/label_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class DisplayEmptyViewWhenOpenTagScenario extends BaseTestScenario
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_bu
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../robots/label_robot.dart';
|
||||
import '../../robots/labels/label_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class DisplayViewWithAllEmailWithTagScenario extends BaseTestScenario
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../robots/email_robot.dart';
|
||||
import '../../robots/label_robot.dart';
|
||||
import '../../robots/labels/label_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
class RemoveALabelFromEmailScenario extends BaseTestScenario
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:tmail_ui_user/features/thread/presentation/widgets/email_tile_bu
|
||||
|
||||
import '../../base/base_test_scenario.dart';
|
||||
import '../../mixin/provisioning_label_scenario_mixin.dart';
|
||||
import '../../robots/label_list_context_menu_robot.dart';
|
||||
import '../../robots/labels/label_list_context_menu_robot.dart';
|
||||
import '../../robots/search_robot.dart';
|
||||
import '../../robots/thread_robot.dart';
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import '../../base/test_base.dart';
|
||||
import '../../scenarios/labels/create_a_new_tag_from_an_email_scenario.dart';
|
||||
|
||||
void main() {
|
||||
TestBase().runPatrolTest(
|
||||
description:
|
||||
'Should create a new label and add to email when select "Create a new Label" button in add label modal of detailed email view',
|
||||
scenarioBuilder: ($) => CreateANewTagFromAnEmailScenario($),
|
||||
);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ mixin LabelModalMixin {
|
||||
}) async {
|
||||
return DialogRouter().openDialogModal(
|
||||
child: CreateNewLabelModal(
|
||||
key: const Key('create_label_modal'),
|
||||
key: const Key('create_new_label_modal'),
|
||||
labels: labels,
|
||||
accountId: accountId,
|
||||
imagePaths: imagePaths,
|
||||
|
||||
@@ -124,6 +124,7 @@ class _AddLabelToEmailModalState extends State<AddLabelToEmailModal> {
|
||||
),
|
||||
),
|
||||
TMailButtonWidget(
|
||||
key: const Key('create_a_new_label_button'),
|
||||
text: appLocalizations.createANewLabel,
|
||||
icon: _imagePaths.icAddNewFolder,
|
||||
iconColor: AppColor.primaryMain,
|
||||
|
||||
+2
@@ -1,4 +1,5 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
@@ -32,6 +33,7 @@ extension AddLabelToThreadExtension on ThreadDetailController {
|
||||
|
||||
final newLabel = await DialogRouter().openDialogModal(
|
||||
child: AddLabelToEmailModal(
|
||||
key: const Key('add_label_to_thread_modal'),
|
||||
labels: labels,
|
||||
emailLabels: threadLabels,
|
||||
emailIds: emailIds,
|
||||
|
||||
@@ -27,6 +27,7 @@ class DialogRouter {
|
||||
required String routeName,
|
||||
required Object? arguments
|
||||
}) async {
|
||||
try {
|
||||
if (PlatformInfo.isWeb) {
|
||||
_isMapDialogOpened[routeName] = true;
|
||||
}
|
||||
@@ -36,13 +37,17 @@ class DialogRouter {
|
||||
barrierDismissible: true,
|
||||
barrierLabel: routeName,
|
||||
routeSettings: RouteSettings(arguments: arguments),
|
||||
pageBuilder: (_, __, ___) => _generateView(routeName: routeName)
|
||||
pageBuilder: (_, __, ___) => _generateView(routeName: routeName),
|
||||
);
|
||||
|
||||
return returnedValue;
|
||||
} catch (e) {
|
||||
logWarning('DialogRouter::pushGeneralDialog: Exception = $e');
|
||||
} finally {
|
||||
if (PlatformInfo.isWeb) {
|
||||
_isMapDialogOpened.remove(routeName);
|
||||
}
|
||||
return returnedValue;
|
||||
}
|
||||
}
|
||||
|
||||
final RxMap<String, bool> _isMapDialogOpened = RxMap<String, bool>();
|
||||
@@ -95,10 +100,10 @@ class DialogRouter {
|
||||
|
||||
Future<dynamic> openDialogModal({
|
||||
required Widget child,
|
||||
required String dialogLabel,
|
||||
String? dialogLabel,
|
||||
}) async {
|
||||
try {
|
||||
if (PlatformInfo.isWeb) {
|
||||
if (PlatformInfo.isWeb && dialogLabel != null) {
|
||||
_isMapDialogOpened[dialogLabel] = true;
|
||||
}
|
||||
|
||||
@@ -110,7 +115,7 @@ class DialogRouter {
|
||||
} catch (e) {
|
||||
logWarning('DialogRouter::openDialogModal: Exception = $e');
|
||||
} finally {
|
||||
if (PlatformInfo.isWeb) {
|
||||
if (PlatformInfo.isWeb && dialogLabel != null) {
|
||||
_isMapDialogOpened.remove(dialogLabel);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user