From dd6b1ede9d711aaa4947e86848805170509b606e Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 18 Apr 2025 00:38:56 +0700 Subject: [PATCH] TF-3670 Add integration test for case forward email lost attachments Signed-off-by: dab246 --- ...rding_email_lost_attachments_scenario.dart | 75 +++++++++++++++++++ ...orwarding_email_lost_attachments_test.dart | 9 +++ 2 files changed, 84 insertions(+) create mode 100644 integration_test/scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart create mode 100644 integration_test/tests/email_detailed/forwarding_email_lost_attachments_test.dart diff --git a/integration_test/scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart b/integration_test/scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart new file mode 100644 index 000000000..2b107f58a --- /dev/null +++ b/integration_test/scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart @@ -0,0 +1,75 @@ +import 'package:core/presentation/resources/image_paths.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/features/email/presentation/widgets/email_attachments_widget.dart'; + +import '../../base/base_test_scenario.dart'; +import '../../models/provisioning_email.dart'; +import '../../robots/composer_robot.dart'; +import '../../robots/email_robot.dart'; +import '../../robots/thread_robot.dart'; + +class ForwardingEmailLostAttachmentsScenario extends BaseTestScenario { + + const ForwardingEmailLostAttachmentsScenario(super.$); + + @override + Future runTestLogic() async { + const subject = 'Forwarding email lost attachments'; + final List attachmentContents = ['file1', 'file2']; + const emailUser = String.fromEnvironment('BASIC_AUTH_EMAIL'); + + final threadRobot = ThreadRobot($); + final emailRobot = EmailRobot($); + final composerRobot = ComposerRobot($); + final imagePaths = ImagePaths(); + + // Prepare attachment files + final attachmentFiles = await Future.wait( + attachmentContents.map( + (attachmentContent) => preparingTxtFile(attachmentContent), + ), + ); + + // Provisioning email + await provisionEmail( + [ + ProvisioningEmail( + toEmail: emailUser, + subject: subject, + content: subject, + attachmentPaths: attachmentFiles.map((file) => file.path).toList(), + ), + ], + requestReadReceipt: false, + ); + await $.pumpAndSettle(); + + await threadRobot.openEmailWithSubject(subject); + await $.pumpAndSettle(); + await _expectForwardEmailButtonVisible(); + await _expectAttachmentListVisible(); + + await emailRobot.onTapForwardEmail(); + await _expectComposerViewVisible(); + + await composerRobot.grantContactPermission(); + await composerRobot.addRecipientIntoField( + prefixEmailAddress: PrefixEmailAddress.to, + email: emailUser, + ); + await composerRobot.sendEmail(imagePaths); + await $.pumpAndSettle(duration: const Duration(seconds: 3)); + + await _expectAttachmentListVisible(); + } + + Future _expectForwardEmailButtonVisible() async { + await expectViewVisible($(#forward_email_button)); + } + + Future _expectComposerViewVisible() => expectViewVisible($(ComposerView)); + + Future _expectAttachmentListVisible() => expectViewVisible($(EmailAttachmentsWidget)); +} \ No newline at end of file diff --git a/integration_test/tests/email_detailed/forwarding_email_lost_attachments_test.dart b/integration_test/tests/email_detailed/forwarding_email_lost_attachments_test.dart new file mode 100644 index 000000000..16664cc82 --- /dev/null +++ b/integration_test/tests/email_detailed/forwarding_email_lost_attachments_test.dart @@ -0,0 +1,9 @@ +import '../../base/test_base.dart'; +import '../../scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: 'Should see attachment list in email view after forward email successfully', + scenarioBuilder: ($) => ForwardingEmailLostAttachmentsScenario($), + ); +} \ No newline at end of file