diff --git a/integration_test/robots/composer_robot.dart b/integration_test/robots/composer_robot.dart index 4c60bdace..c1b372eca 100644 --- a/integration_test/robots/composer_robot.dart +++ b/integration_test/robots/composer_robot.dart @@ -193,4 +193,8 @@ class ComposerRobot extends CoreRobot { ); controller?.handleSuccessViewState(LocalImagePickerSuccess(fileInfo)); } + + Future tapDiscardChanges() async { + await $(AppLocalizations().discardChanges).tap(); + } } 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 index 01b500398..c5995b1ec 100644 --- a/integration_test/scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart +++ b/integration_test/scenarios/email_detailed/forwarding_email_lost_attachments_scenario.dart @@ -2,7 +2,7 @@ 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 'package:tmail_ui_user/features/email/presentation/widgets/attachment_item_widget.dart'; import '../../base/base_test_scenario.dart'; import '../../models/provisioning_email.dart'; @@ -56,9 +56,6 @@ class ForwardingEmailLostAttachmentsScenario extends BaseTestScenario { await composerRobot.grantContactPermission(); - await composerRobot.expandRecipientsFields(); - await $.pumpAndSettle(); - await composerRobot.addRecipientIntoField( prefixEmailAddress: PrefixEmailAddress.to, email: emailUser, @@ -75,5 +72,8 @@ class ForwardingEmailLostAttachmentsScenario extends BaseTestScenario { Future _expectComposerViewVisible() => expectViewVisible($(ComposerView)); - Future _expectAttachmentListVisible() => expectViewVisible($(EmailAttachmentsWidget)); + Future _expectAttachmentListVisible() async { + await $.waitUntilVisible($(AttachmentItemWidget)); + expect($(AttachmentItemWidget), findsNWidgets(2)); + } } \ No newline at end of file diff --git a/integration_test/scenarios/save_as_template_scenario.dart b/integration_test/scenarios/save_as_template_scenario.dart index 368573f8b..19a5b6342 100644 --- a/integration_test/scenarios/save_as_template_scenario.dart +++ b/integration_test/scenarios/save_as_template_scenario.dart @@ -1,8 +1,10 @@ +import 'package:core/presentation/resources/image_paths.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; import '../base/base_test_scenario.dart'; import '../robots/composer_robot.dart'; +import '../robots/mailbox_menu_robot.dart'; import '../robots/thread_robot.dart'; class SaveAsTemplateScenario extends BaseTestScenario { @@ -10,37 +12,40 @@ class SaveAsTemplateScenario extends BaseTestScenario { @override Future runTestLogic() async { + final imagePaths = ImagePaths(); + final appLocalizations = AppLocalizations(); + final mailboxMenuRobot = MailboxMenuRobot($); final threadRobot = ThreadRobot($); final composerRobot = ComposerRobot($); + + await threadRobot.openMailbox(); + await mailboxMenuRobot.openFolderByName( + appLocalizations.templatesMailboxDisplayName, + ); await threadRobot.openComposer(); await composerRobot.grantContactPermission(); + await composerRobot.addSubject('test subject'); await composerRobot.saveAsTemplate(); await $.pumpAndTrySettle(); - await _expectSaveToastSuccessVisible(); + await composerRobot.tapCloseComposer(imagePaths); + await composerRobot.tapDiscardChanges(); + await _expectTemplateVisible('test subject'); - await composerRobot.addSubject('test subject'); + await threadRobot.openEmailWithSubject('test subject'); + await composerRobot.addSubject('test subject updated'); hideKeyboard(); await $.pumpAndTrySettle(duration: const Duration(seconds: 1)); await composerRobot.saveAsTemplate(); - - await _expectUpdateToastSuccessVisible(); + await $.pumpAndTrySettle(); + await composerRobot.tapCloseComposer(imagePaths); + await composerRobot.tapDiscardChanges(); + await _expectTemplateVisible('test subject updated'); } - Future _expectSaveToastSuccessVisible() async { - await $(AppLocalizations().saveMessageToTemplateSuccess).waitUntilVisible(); - expect( - $(AppLocalizations().saveMessageToTemplateSuccess).visible, - isTrue, - ); - } - - Future _expectUpdateToastSuccessVisible() async { - await $(AppLocalizations().updateMessageToTemplateSuccess).waitUntilVisible(); - expect( - $(AppLocalizations().updateMessageToTemplateSuccess).visible, - isTrue, - ); + Future _expectTemplateVisible(String subject) async { + await $(subject).waitUntilVisible(); + expect($(subject).visible, isTrue); } } \ No newline at end of file diff --git a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart index be30dafdb..2b771be04 100644 --- a/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart +++ b/lib/features/composer/presentation/controller/rich_text_mobile_tablet_controller.dart @@ -5,6 +5,7 @@ import 'package:core/utils/html/html_utils.dart'; import 'package:core/utils/platform_info.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; import 'package:get/get.dart'; import 'package:rich_text_composer/rich_text_composer.dart'; import 'package:tmail_ui_user/features/composer/presentation/model/header_style_type.dart'; @@ -75,7 +76,15 @@ class RichTextMobileTabletController extends GetxController { @override void onClose() { richTextController.dispose(); - htmlEditorApi?.webViewController.dispose(); + if (kDebugMode) { + try { + htmlEditorApi?.webViewController.dispose(); + } catch (e) { + logWarning('Dispose error: $e'); + } + } else { + htmlEditorApi?.webViewController.dispose(); + } htmlEditorApi = null; super.onClose(); }