diff --git a/integration_test/robots/composer_robot.dart b/integration_test/robots/composer_robot.dart index c75f432cf..ef51d648c 100644 --- a/integration_test/robots/composer_robot.dart +++ b/integration_test/robots/composer_robot.dart @@ -9,6 +9,7 @@ import 'package:model/email/prefix_email_address.dart'; import 'package:model/extensions/session_extension.dart'; import 'package:model/upload/file_info.dart'; import 'package:rich_text_composer/rich_text_composer.dart'; +import 'package:tmail_ui_user/features/base/widget/popup_item_widget.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/view/mobile/mobile_editor_view.dart'; @@ -163,4 +164,10 @@ class ComposerRobot extends CoreRobot { fileName: file.path.split('/').last, ))); } + + Future toggleReadReceipt() async { + await $(PopupItemWidget) + .which((widget) => widget.iconAction == ImagePaths().icReadReceipt) + .tap(); + } } diff --git a/integration_test/scenarios/composer/send_email_with_read_receipt_enabled_scenario.dart b/integration_test/scenarios/composer/send_email_with_read_receipt_enabled_scenario.dart new file mode 100644 index 000000000..d576c1178 --- /dev/null +++ b/integration_test/scenarios/composer/send_email_with_read_receipt_enabled_scenario.dart @@ -0,0 +1,78 @@ +import 'package:core/core.dart'; +import 'package:duration/duration.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:model/email/prefix_email_address.dart'; +import 'package:tmail_ui_user/features/composer/presentation/composer_view.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; + +import '../../base/base_test_scenario.dart'; +import '../../robots/composer_robot.dart'; +import '../../robots/thread_robot.dart'; + +class SendEmailWithReadReceiptEnabledScenario extends BaseTestScenario { + const SendEmailWithReadReceiptEnabledScenario(super.$); + + @override + Future runTestLogic() async { + const additionalRecipient = String.fromEnvironment('ADDITIONAL_MAIL_RECIPIENT'); + const email = String.fromEnvironment('BASIC_AUTH_EMAIL'); + const subject = 'Test read receipt subject'; + const content = 'Test content'; + + final threadRobot = ThreadRobot($); + final composerRobot = ComposerRobot($); + final imagePaths = ImagePaths(); + final appLocalizations = AppLocalizations(); + + await threadRobot.openComposer(); + await _expectComposerViewVisible(); + + await composerRobot.grantContactPermission(); + + await composerRobot.addRecipientIntoField( + prefixEmailAddress: PrefixEmailAddress.to, + email: email, + ); + await composerRobot.addRecipientIntoField( + prefixEmailAddress: PrefixEmailAddress.to, + email: additionalRecipient, + ); + await composerRobot.addSubject(subject); + await composerRobot.addContent(content); + await composerRobot.tapMoreOptionOnAppBar(); + await composerRobot.toggleReadReceipt(); + await _expectReadReceiptToggleSuccessfullyToast(appLocalizations); + + await composerRobot.sendEmail(imagePaths); + + await _expectSendEmailSuccessToast(appLocalizations); + + await $.pumpAndSettle(duration: seconds(5)); + await threadRobot.openEmailWithSubject(subject); + await _expectReadReceiptRequestDialog(appLocalizations); + } + + Future _expectReadReceiptRequestDialog( + AppLocalizations appLocalizations + ) async { + await expectViewVisible( + $(appLocalizations.titleReadReceiptRequestNotificationMessage) + ); + } + + Future _expectReadReceiptToggleSuccessfullyToast( + AppLocalizations appLocalizations + ) async { + await expectViewVisible( + $(appLocalizations.requestReadReceiptHasBeenEnabled) + ); + } + + Future _expectComposerViewVisible() => expectViewVisible($(ComposerView)); + + Future _expectSendEmailSuccessToast(AppLocalizations appLocalizations) async { + await expectViewVisible( + $(find.text(appLocalizations.message_has_been_sent_successfully)), + ); + } +}