From df53ce1821315510bbb2917351697cb6f38a69b4 Mon Sep 17 00:00:00 2001 From: DatDang Date: Wed, 26 Feb 2025 10:31:12 +0700 Subject: [PATCH] TF-3515 Integration test save email as template --- integration_test/robots/composer_robot.dart | 11 +++++ .../scenarios/save_as_template_scenario.dart | 45 +++++++++++++++++++ .../tests/composer/save_as_template_test.dart | 9 ++++ 3 files changed, 65 insertions(+) create mode 100644 integration_test/scenarios/save_as_template_scenario.dart create mode 100644 integration_test/tests/composer/save_as_template_test.dart diff --git a/integration_test/robots/composer_robot.dart b/integration_test/robots/composer_robot.dart index ddb82e8f2..e248d22ad 100644 --- a/integration_test/robots/composer_robot.dart +++ b/integration_test/robots/composer_robot.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:model/email/prefix_email_address.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'; @@ -111,4 +112,14 @@ class ComposerRobot extends CoreRobot { Future tapFromFieldPopupMenu() async { await $(FromComposerMobileWidget).$(InkWell).tap(); } + + Future saveAsTemplate() async { + await $(AppBarComposerWidget) + .$(TMailButtonWidget) + .which((widget) => widget.icon == ImagePaths().icMore) + .tap(); + await $(PopupItemWidget) + .$(AppLocalizations().saveAsTemplate) + .tap(); + } } \ 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 new file mode 100644 index 000000000..cd53f19f4 --- /dev/null +++ b/integration_test/scenarios/save_as_template_scenario.dart @@ -0,0 +1,45 @@ +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/thread_robot.dart'; + +class SaveAsTemplateScenario extends BaseTestScenario { + const SaveAsTemplateScenario(super.$); + + @override + Future runTestLogic() async { + final threadRobot = ThreadRobot($); + final composerRobot = ComposerRobot($); + + await threadRobot.openComposer(); + await composerRobot.grantContactPermission(); + + await composerRobot.saveAsTemplate(); + + await _expectSaveToastSuccessVisible(); + + await composerRobot.addSubject('test subject'); + + await composerRobot.saveAsTemplate(); + + await _expectUpdateToastSuccessVisible(); + } + + Future _expectSaveToastSuccessVisible() async { + await $(AppLocalizations().saveMessageToTemplateSuccess).waitUntilVisible(); + expect( + $(AppLocalizations().saveMessageToTemplateSuccess).visible, + isTrue, + ); + } + + Future _expectUpdateToastSuccessVisible() async { + await $(AppLocalizations().updateMessageToTemplateSuccess).waitUntilVisible(); + expect( + $(AppLocalizations().updateMessageToTemplateSuccess).visible, + isTrue, + ); + } +} \ No newline at end of file diff --git a/integration_test/tests/composer/save_as_template_test.dart b/integration_test/tests/composer/save_as_template_test.dart new file mode 100644 index 000000000..37b4bd533 --- /dev/null +++ b/integration_test/tests/composer/save_as_template_test.dart @@ -0,0 +1,9 @@ +import '../../base/test_base.dart'; +import '../../scenarios/save_as_template_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: 'Should save email as template successfully', + scenarioBuilder: ($) => SaveAsTemplateScenario($), + ); +} \ No newline at end of file