diff --git a/integration_test/robots/confirm_dialog_robot.dart b/integration_test/robots/confirm_dialog_robot.dart new file mode 100644 index 000000000..f660fcd26 --- /dev/null +++ b/integration_test/robots/confirm_dialog_robot.dart @@ -0,0 +1,12 @@ +import 'package:core/presentation/views/dialog/confirm_dialog_button.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import '../base/core_robot.dart'; + +class ConfirmDialogRobot extends CoreRobot { + ConfirmDialogRobot(super.$); + + Future selectActionByName(String name) async { + await $(ConfirmDialogButton).$(name).tap(); + } +} diff --git a/integration_test/scenarios/labels/delete_a_tag_scenario.dart b/integration_test/scenarios/labels/delete_a_tag_scenario.dart new file mode 100644 index 000000000..3df70a8a2 --- /dev/null +++ b/integration_test/scenarios/labels/delete_a_tag_scenario.dart @@ -0,0 +1,63 @@ +import 'package:core/utils/platform_info.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tmail_ui_user/features/mailbox/presentation/widgets/labels/label_list_view.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; + +import '../../base/base_test_scenario.dart'; +import '../../mixin/provisioning_label_scenario_mixin.dart'; +import '../../robots/confirm_dialog_robot.dart'; +import '../../robots/labels/label_action_type_context_menu_robot.dart'; +import '../../robots/labels/label_robot.dart'; +import '../../robots/thread_robot.dart'; + +class DeleteATagScenario extends BaseTestScenario + with ProvisioningLabelScenarioMixin { + const DeleteATagScenario(super.$); + + @override + Future setupPreLogin() async { + PlatformInfo.isIntegrationTesting = true; + } + + @override + Future runTestLogic() async { + final threadRobot = ThreadRobot($); + final labelRobot = LabelRobot($); + final labelActionTypeContextMenuRobot = LabelActionTypeContextMenuRobot($); + final confirmDialogRobot = ConfirmDialogRobot($); + final appLocalizations = AppLocalizations(); + + await provisionLabelsByDisplayNames(['Delete Tag 1', 'Delete Tag 2']); + await $.pumpAndSettle(duration: const Duration(seconds: 2)); + + await threadRobot.openMailbox(); + await labelRobot.longPressLabelWithName('Delete Tag 1'); + await _expectLabelActionTypeContextMenuVisible(); + + await labelActionTypeContextMenuRobot.selectActionByName( + appLocalizations.delete, + ); + await _expectDeleteLabelConfirmDialogVisible(); + + await confirmDialogRobot.selectActionByName(appLocalizations.delete); + await $.pumpAndSettle(duration: const Duration(seconds: 1)); + await _expectLabelDeletedByName('Delete Tag 1'); + } + + Future _expectLabelActionTypeContextMenuVisible() async { + await expectViewVisible($(#label_action_type_context_menu)); + } + + Future _expectDeleteLabelConfirmDialogVisible() async { + await expectViewVisible($(#confirm_dialog_delete_label)); + } + + Future _expectLabelDeletedByName(String name) async { + await expectViewInvisible($(LabelListView).$(name)); + } + + @override + Future disposeAfterTest() async { + PlatformInfo.isIntegrationTesting = false; + } +} diff --git a/integration_test/tests/labels/delete_a_tag_test.dart b/integration_test/tests/labels/delete_a_tag_test.dart new file mode 100644 index 000000000..2eddfbc3c --- /dev/null +++ b/integration_test/tests/labels/delete_a_tag_test.dart @@ -0,0 +1,10 @@ +import '../../base/test_base.dart'; +import '../../scenarios/labels/delete_a_tag_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: + 'Should delete label in label list when delete a label successfully', + scenarioBuilder: ($) => DeleteATagScenario($), + ); +}