TF-4404 Add e2e test for Mail to attendees action on mobile
This commit is contained in:
@@ -0,0 +1,79 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/email_view.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/features/search/email/presentation/search_email_view.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
|
import '../base/base_scenario.dart';
|
||||||
|
import '../robots/search_robot.dart';
|
||||||
|
import '../robots/thread_robot.dart';
|
||||||
|
|
||||||
|
mixin OpenCalendarEventScenarioMixin on BaseScenario {
|
||||||
|
static const eventEmailSubject = 'Proposed new time';
|
||||||
|
|
||||||
|
Future<void> openCalendarEvent({
|
||||||
|
required ThreadRobot threadRobot,
|
||||||
|
required SearchRobot searchRobot,
|
||||||
|
required AppLocalizations appLocalizations,
|
||||||
|
}) async {
|
||||||
|
await threadRobot.openSearchView();
|
||||||
|
await _expectSearchViewVisible();
|
||||||
|
|
||||||
|
await searchRobot.enterQueryString(eventEmailSubject);
|
||||||
|
await searchRobot.tapOnShowAllResultsText();
|
||||||
|
await _expectSearchResultEmailListVisible();
|
||||||
|
|
||||||
|
await searchRobot.openEmailWithSubject(eventEmailSubject);
|
||||||
|
await _expectEmailViewVisible();
|
||||||
|
await _expectYesButtonVisible(appLocalizations);
|
||||||
|
await _expectMailToAttendeesButtonVisible(appLocalizations);
|
||||||
|
await _expectNoButtonInvisible(appLocalizations);
|
||||||
|
await _expectMaybeButtonInvisible(appLocalizations);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectSearchViewVisible() async {
|
||||||
|
await expectViewVisible($(SearchEmailView));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectSearchResultEmailListVisible() async {
|
||||||
|
await expectViewVisible($(#search_email_list_notification_listener));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectEmailViewVisible() async {
|
||||||
|
await expectViewVisible($(EmailView), alignment: Alignment.topCenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectYesButtonVisible(
|
||||||
|
AppLocalizations appLocalizations,
|
||||||
|
) async {
|
||||||
|
final yesButton =
|
||||||
|
$(CalendarEventActionButtonWidget).$(appLocalizations.yes);
|
||||||
|
await yesButton.scrollTo(scrollDirection: AxisDirection.down);
|
||||||
|
await expectViewVisible(yesButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectMailToAttendeesButtonVisible(
|
||||||
|
AppLocalizations appLocalizations,
|
||||||
|
) async {
|
||||||
|
final mailToAttendeesButton =
|
||||||
|
$(CalendarEventActionButtonWidget).$(appLocalizations.mailToAttendees);
|
||||||
|
await mailToAttendeesButton.scrollTo();
|
||||||
|
await expectViewVisible(mailToAttendeesButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectNoButtonInvisible(
|
||||||
|
AppLocalizations appLocalizations,
|
||||||
|
) async {
|
||||||
|
final noButton = $(CalendarEventActionButtonWidget).$(appLocalizations.no);
|
||||||
|
await expectViewInvisible(noButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectMaybeButtonInvisible(
|
||||||
|
AppLocalizations appLocalizations,
|
||||||
|
) async {
|
||||||
|
final maybeButton =
|
||||||
|
$(CalendarEventActionButtonWidget).$(appLocalizations.maybe);
|
||||||
|
await expectViewInvisible(maybeButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,4 +99,8 @@ class EmailRobot extends CoreRobot {
|
|||||||
Future<void> tapDeleteThreadButton() async {
|
Future<void> tapDeleteThreadButton() async {
|
||||||
await $(#delete_thread_button).tap();
|
await $(#delete_thread_button).tap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> tapMailToAttendeesEventActionButton() async {
|
||||||
|
await $(#mailToAttendees_event_action_button).tap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,87 +1,30 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/email_view.dart';
|
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_event_action_banner_widget.dart';
|
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_event_action_banner_widget.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/widgets/calendar_event/calendar_event_action_button_widget.dart';
|
|
||||||
import 'package:tmail_ui_user/features/search/email/presentation/search_email_view.dart';
|
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
import '../../base/base_test_scenario.dart';
|
import '../../base/base_test_scenario.dart';
|
||||||
|
import '../../mixin/open_calendar_event_scenario_mixin.dart';
|
||||||
import '../../robots/search_robot.dart';
|
import '../../robots/search_robot.dart';
|
||||||
import '../../robots/thread_robot.dart';
|
import '../../robots/thread_robot.dart';
|
||||||
|
|
||||||
class CalendarEventCounterScenario extends BaseTestScenario {
|
class CalendarEventCounterScenario extends BaseTestScenario
|
||||||
|
with OpenCalendarEventScenarioMixin {
|
||||||
const CalendarEventCounterScenario(super.$);
|
const CalendarEventCounterScenario(super.$);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> runTestLogic() async {
|
Future<void> runTestLogic() async {
|
||||||
const emailSubject = 'Proposed new time';
|
|
||||||
|
|
||||||
final threadRobot = ThreadRobot($);
|
final threadRobot = ThreadRobot($);
|
||||||
final searchRobot = SearchRobot($);
|
final searchRobot = SearchRobot($);
|
||||||
final appLocalizations = AppLocalizations();
|
final appLocalizations = AppLocalizations();
|
||||||
|
|
||||||
await threadRobot.openSearchView();
|
await openCalendarEvent(
|
||||||
await _expectSearchViewVisible();
|
threadRobot: threadRobot,
|
||||||
|
searchRobot: searchRobot,
|
||||||
await searchRobot.enterQueryString(emailSubject);
|
appLocalizations: appLocalizations,
|
||||||
await searchRobot.tapOnShowAllResultsText();
|
);
|
||||||
await _expectSearchResultEmailListVisible();
|
|
||||||
|
|
||||||
await searchRobot.openEmailWithSubject(emailSubject);
|
|
||||||
await _expectEmailViewVisible();
|
|
||||||
await _expectYesButtonVisible(appLocalizations);
|
|
||||||
await _expectMailToAttendeesButtonVisible(appLocalizations);
|
|
||||||
await _expectNoButtonInvisible(appLocalizations);
|
|
||||||
await _expectMaybeButtonInvisible(appLocalizations);
|
|
||||||
await _expectProposedEventChangesTextVisible(appLocalizations);
|
await _expectProposedEventChangesTextVisible(appLocalizations);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _expectSearchViewVisible() async {
|
|
||||||
await expectViewVisible($(SearchEmailView));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectSearchResultEmailListVisible() async {
|
|
||||||
await expectViewVisible($(#search_email_list_notification_listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectEmailViewVisible() async {
|
|
||||||
await expectViewVisible($(EmailView), alignment: Alignment.topCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectYesButtonVisible(
|
|
||||||
AppLocalizations appLocalizations,
|
|
||||||
) async {
|
|
||||||
final yesButton = $(CalendarEventActionButtonWidget)
|
|
||||||
.$(appLocalizations.yes);
|
|
||||||
await yesButton.scrollTo(scrollDirection: AxisDirection.down);
|
|
||||||
await expectViewVisible(yesButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectMailToAttendeesButtonVisible(
|
|
||||||
AppLocalizations appLocalizations,
|
|
||||||
) async {
|
|
||||||
final mailToAttendeesButton = $(CalendarEventActionButtonWidget)
|
|
||||||
.$(appLocalizations.mailToAttendees);
|
|
||||||
await mailToAttendeesButton.scrollTo();
|
|
||||||
await expectViewVisible(mailToAttendeesButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectNoButtonInvisible(
|
|
||||||
AppLocalizations appLocalizations,
|
|
||||||
) async {
|
|
||||||
final noButton = $(CalendarEventActionButtonWidget)
|
|
||||||
.$(appLocalizations.no);
|
|
||||||
await expectViewInvisible(noButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectMaybeButtonInvisible(
|
|
||||||
AppLocalizations appLocalizations,
|
|
||||||
) async {
|
|
||||||
final maybeButton = $(CalendarEventActionButtonWidget)
|
|
||||||
.$(appLocalizations.maybe);
|
|
||||||
await expectViewInvisible(maybeButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _expectProposedEventChangesTextVisible(
|
Future<void> _expectProposedEventChangesTextVisible(
|
||||||
AppLocalizations appLocalizations,
|
AppLocalizations appLocalizations,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/presentation/composer_view.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/subject_composer_widget.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||||
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
|
|
||||||
|
import '../../base/base_test_scenario.dart';
|
||||||
|
import '../../mixin/open_calendar_event_scenario_mixin.dart';
|
||||||
|
import '../../robots/composer_robot.dart';
|
||||||
|
import '../../robots/email_robot.dart';
|
||||||
|
import '../../robots/search_robot.dart';
|
||||||
|
import '../../robots/thread_robot.dart';
|
||||||
|
|
||||||
|
class MailToAttendeesEventEmailScenario extends BaseTestScenario
|
||||||
|
with OpenCalendarEventScenarioMixin {
|
||||||
|
const MailToAttendeesEventEmailScenario(super.$);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> runTestLogic() async {
|
||||||
|
final threadRobot = ThreadRobot($);
|
||||||
|
final searchRobot = SearchRobot($);
|
||||||
|
final composerRobot = ComposerRobot($);
|
||||||
|
final emailRobot = EmailRobot($);
|
||||||
|
final appLocalizations = AppLocalizations();
|
||||||
|
|
||||||
|
await openCalendarEvent(
|
||||||
|
threadRobot: threadRobot,
|
||||||
|
searchRobot: searchRobot,
|
||||||
|
appLocalizations: appLocalizations,
|
||||||
|
);
|
||||||
|
|
||||||
|
await emailRobot.tapMailToAttendeesEventActionButton();
|
||||||
|
await _expectComposerViewVisible();
|
||||||
|
await composerRobot.grantContactPermission();
|
||||||
|
|
||||||
|
await _expectSubjectFilledCorrectly(appLocalizations);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectComposerViewVisible() async {
|
||||||
|
await expectViewVisible($(ComposerView));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _expectSubjectFilledCorrectly(
|
||||||
|
AppLocalizations appLocalizations,
|
||||||
|
) async {
|
||||||
|
await expectViewVisible($(SubjectComposerWidget));
|
||||||
|
|
||||||
|
final composerController = Get.find<ComposerController>();
|
||||||
|
final actualSubject = composerController.subjectEmail.value ?? '';
|
||||||
|
|
||||||
|
final expectedSubject = EmailUtils.applyPrefix(
|
||||||
|
subject: 'Come for a chat',
|
||||||
|
defaultPrefix: EmailUtils.defaultReplyPrefix,
|
||||||
|
localizedPrefix: appLocalizations.prefix_reply_email,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(actualSubject, contains(appLocalizations.prefix_reply_email));
|
||||||
|
expect(actualSubject, equals(expectedSubject));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import '../../base/test_base.dart';
|
||||||
|
import '../../scenarios/calendar/mail_to_attendees_event_email_scenario.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestBase().runPatrolTest(
|
||||||
|
description: 'Should fill subject with reply prefix '
|
||||||
|
'when user taps mail to attendees button '
|
||||||
|
'on calendar event email',
|
||||||
|
scenarioBuilder: ($) => MailToAttendeesEventEmailScenario($),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -24,6 +24,8 @@ enum EventActionType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Key getKeyButton() => Key('${name}_event_action_button');
|
||||||
|
|
||||||
String getToastMessageSuccess(BuildContext context) {
|
String getToastMessageSuccess(BuildContext context) {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
case EventActionType.yes:
|
case EventActionType.yes:
|
||||||
|
|||||||
+1
@@ -40,6 +40,7 @@ class CalendarEventActionButtonWidget extends StatelessWidget {
|
|||||||
.map((action) => AbsorbPointer(
|
.map((action) => AbsorbPointer(
|
||||||
absorbing: _getCallbackFunction(action) == null,
|
absorbing: _getCallbackFunction(action) == null,
|
||||||
child: TMailButtonWidget(
|
child: TMailButtonWidget(
|
||||||
|
key: action.getKeyButton(),
|
||||||
text: action.getLabelButton(context),
|
text: action.getLabelButton(context),
|
||||||
backgroundColor: _getButtonBackgroundColor(action),
|
backgroundColor: _getButtonBackgroundColor(action),
|
||||||
borderRadius: CalendarEventActionButtonWidgetStyles.borderRadius,
|
borderRadius: CalendarEventActionButtonWidgetStyles.borderRadius,
|
||||||
|
|||||||
Reference in New Issue
Block a user