|
| 1 | +import 'package:core/core.dart'; |
| 2 | +import 'package:duration/duration.dart'; |
| 3 | +import 'package:flutter_test/flutter_test.dart'; |
| 4 | +import 'package:model/email/prefix_email_address.dart'; |
| 5 | +import 'package:tmail_ui_user/features/composer/presentation/composer_view.dart'; |
| 6 | +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; |
| 7 | + |
| 8 | +import '../../base/base_test_scenario.dart'; |
| 9 | +import '../../robots/composer_robot.dart'; |
| 10 | +import '../../robots/thread_robot.dart'; |
| 11 | + |
| 12 | +class SendEmailWithReadReceiptEnabledScenario extends BaseTestScenario { |
| 13 | + const SendEmailWithReadReceiptEnabledScenario(super.$); |
| 14 | + |
| 15 | + @override |
| 16 | + Future<void> runTestLogic() async { |
| 17 | + const additionalRecipient = String.fromEnvironment('ADDITIONAL_MAIL_RECIPIENT'); |
| 18 | + const email = String.fromEnvironment('BASIC_AUTH_EMAIL'); |
| 19 | + const subject = 'Test read receipt subject'; |
| 20 | + const content = 'Test content'; |
| 21 | + |
| 22 | + final threadRobot = ThreadRobot($); |
| 23 | + final composerRobot = ComposerRobot($); |
| 24 | + final imagePaths = ImagePaths(); |
| 25 | + final appLocalizations = AppLocalizations(); |
| 26 | + |
| 27 | + await threadRobot.openComposer(); |
| 28 | + await _expectComposerViewVisible(); |
| 29 | + |
| 30 | + await composerRobot.grantContactPermission(); |
| 31 | + |
| 32 | + await composerRobot.addRecipientIntoField( |
| 33 | + prefixEmailAddress: PrefixEmailAddress.to, |
| 34 | + email: email, |
| 35 | + ); |
| 36 | + await composerRobot.addRecipientIntoField( |
| 37 | + prefixEmailAddress: PrefixEmailAddress.to, |
| 38 | + email: additionalRecipient, |
| 39 | + ); |
| 40 | + await composerRobot.addSubject(subject); |
| 41 | + await composerRobot.addContent(content); |
| 42 | + await composerRobot.tapMoreOptions(); |
| 43 | + await composerRobot.toggleReadReceipt(); |
| 44 | + await _expectReadReceiptToggleSuccessfullyToast(appLocalizations); |
| 45 | + |
| 46 | + await composerRobot.sendEmail(imagePaths); |
| 47 | + |
| 48 | + await _expectSendEmailSuccessToast(appLocalizations); |
| 49 | + |
| 50 | + await $.pumpAndSettle(duration: seconds(5)); |
| 51 | + await threadRobot.openEmailWithSubject(subject); |
| 52 | + await _expectReadReceiptRequestDialog(appLocalizations); |
| 53 | + } |
| 54 | + |
| 55 | + Future<void> _expectReadReceiptRequestDialog( |
| 56 | + AppLocalizations appLocalizations |
| 57 | + ) async { |
| 58 | + await expectViewVisible( |
| 59 | + $(appLocalizations.titleReadReceiptRequestNotificationMessage) |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + Future<void> _expectReadReceiptToggleSuccessfullyToast( |
| 64 | + AppLocalizations appLocalizations |
| 65 | + ) async { |
| 66 | + await expectViewVisible( |
| 67 | + $(appLocalizations.requestReadReceiptHasBeenEnabled) |
| 68 | + ); |
| 69 | + } |
| 70 | + |
| 71 | + Future<void> _expectComposerViewVisible() => expectViewVisible($(ComposerView)); |
| 72 | + |
| 73 | + Future<void> _expectSendEmailSuccessToast(AppLocalizations appLocalizations) async { |
| 74 | + await expectViewVisible( |
| 75 | + $(find.text(appLocalizations.message_has_been_sent_successfully)), |
| 76 | + ); |
| 77 | + } |
| 78 | +} |
0 commit comments