diff --git a/integration_test/mixin/scenario_utils_mixin.dart b/integration_test/mixin/scenario_utils_mixin.dart index c64df2e078..d685a96026 100644 --- a/integration_test/mixin/scenario_utils_mixin.dart +++ b/integration_test/mixin/scenario_utils_mixin.dart @@ -10,6 +10,7 @@ import 'package:jmap_dart_client/jmap/identities/identity.dart'; import 'package:jmap_dart_client/jmap/jmap_request.dart'; import 'package:jmap_dart_client/jmap/mail/email/email_address.dart'; import 'package:jmap_dart_client/jmap/mail/email/set/set_email_method.dart'; +import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; import 'package:model/model.dart'; import 'package:path_provider/path_provider.dart'; import 'package:tmail_ui_user/features/composer/domain/state/upload_attachment_state.dart'; @@ -31,6 +32,7 @@ mixin ScenarioUtilsMixin { List provisioningEmails, { bool refreshEmailView = true, bool requestReadReceipt = true, + Role? sentLocation, }) async { ComposerBindings().dependencies(); @@ -56,7 +58,9 @@ mixin ScenarioUtilsMixin { emailContent: provisioningEmail.content, toRecipients: {EmailAddress(null, provisioningEmail.toEmail)}, outboxMailboxId: mailboxDashBoardController.outboxMailbox?.mailboxId, - sentMailboxId: mailboxDashBoardController.mapDefaultMailboxIdByRole[PresentationMailbox.roleSent], + sentMailboxId: mailboxDashBoardController.mapDefaultMailboxIdByRole[ + sentLocation ?? PresentationMailbox.roleSent + ], identity: identity, attachments: attachments, hasRequestReadReceipt: requestReadReceipt, diff --git a/integration_test/robots/thread_robot.dart b/integration_test/robots/thread_robot.dart index c8e085c907..56c22bac0d 100644 --- a/integration_test/robots/thread_robot.dart +++ b/integration_test/robots/thread_robot.dart @@ -33,4 +33,19 @@ class ThreadRobot extends CoreRobot { Future openMailbox() async { await $(#mobile_mailbox_menu_button).tap(); } + + Future pullToRefreshByEmailSubject(String subject) async { + await $(subject).waitUntilVisible(); + await $.tester.fling( + $(subject), + const Offset(0, 300), + 1000, + ); + await $.pumpAndSettle(); + } + + Future tapOnMailboxWithName(String name) async { + await $(name).tap(); + await $.pumpAndSettle(); + } } \ No newline at end of file diff --git a/integration_test/scenarios/mailbox/pull_to_refresh_scenario.dart b/integration_test/scenarios/mailbox/pull_to_refresh_scenario.dart new file mode 100644 index 0000000000..0a9fd8a556 --- /dev/null +++ b/integration_test/scenarios/mailbox/pull_to_refresh_scenario.dart @@ -0,0 +1,50 @@ +import 'package:flutter_test/flutter_test.dart'; + +import '../../base/base_test_scenario.dart'; +import '../../models/provisioning_email.dart'; +import '../../robots/thread_robot.dart'; + +class PullToRefreshScenario extends BaseTestScenario { + const PullToRefreshScenario(super.$); + + @override + Future runTestLogic() async { + const toEmail = String.fromEnvironment('BASIC_AUTH_EMAIL'); + const visibleBeforePullToRefresh = 'before pull to refresh'; + const visibleAfterPullToRefresh = 'after pull to refresh'; + + final threadRobot = ThreadRobot($); + + await provisionEmail( + [ProvisioningEmail( + toEmail: toEmail, + subject: visibleBeforePullToRefresh, + content: '', + )], + ); + await $.pumpAndSettle(); + _expectEmailWithSubjectVisible(visibleBeforePullToRefresh); + + await provisionEmail( + [ProvisioningEmail( + toEmail: toEmail, + subject: visibleAfterPullToRefresh, + content: '', + )], + refreshEmailView: false, + ); + await $.pumpAndSettle(); + _expectEmailWithSubjectInvisible(visibleAfterPullToRefresh); + + await threadRobot.pullToRefreshByEmailSubject(visibleBeforePullToRefresh); + _expectEmailWithSubjectVisible(visibleAfterPullToRefresh); + } + + _expectEmailWithSubjectVisible(String subject) { + expect($(subject), findsOneWidget); + } + + _expectEmailWithSubjectInvisible(String subject) { + expect($(subject), findsNothing); + } +} \ No newline at end of file diff --git a/integration_test/scenarios/mailbox/switch_mailbox_scenario.dart b/integration_test/scenarios/mailbox/switch_mailbox_scenario.dart new file mode 100644 index 0000000000..7ce1eb100b --- /dev/null +++ b/integration_test/scenarios/mailbox/switch_mailbox_scenario.dart @@ -0,0 +1,50 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:model/mailbox/presentation_mailbox.dart'; +import 'package:tmail_ui_user/main/localizations/app_localizations.dart'; + +import '../../base/base_test_scenario.dart'; +import '../../models/provisioning_email.dart'; +import '../../robots/thread_robot.dart'; + +class SwitchMailboxScenario extends BaseTestScenario { + const SwitchMailboxScenario(super.$); + + @override + Future runTestLogic() async { + const toEmail = String.fromEnvironment('BASIC_AUTH_EMAIL'); + const sentEmailSubject = 'sent subject'; + const trashEmailSubject = 'trash subject'; + + final threadRobot = ThreadRobot($); + final appLocalizations = AppLocalizations(); + + await provisionEmail( + [ProvisioningEmail( + toEmail: toEmail, + subject: sentEmailSubject, + content: '', + )], + ); + await provisionEmail( + [ProvisioningEmail( + toEmail: toEmail, + subject: trashEmailSubject, + content: '', + )], + sentLocation: PresentationMailbox.roleTrash, + ); + + await threadRobot.openMailbox(); + await threadRobot.tapOnMailboxWithName(appLocalizations.sentMailboxDisplayName); + await _expectEmailWithSubjectVisible(sentEmailSubject); + + await threadRobot.openMailbox(); + await threadRobot.tapOnMailboxWithName(appLocalizations.trashMailboxDisplayName); + await _expectEmailWithSubjectVisible(trashEmailSubject); + } + + Future _expectEmailWithSubjectVisible(String subject) async { + await $.pumpAndSettle(duration: const Duration(seconds: 2)); + expect($(subject), findsOneWidget); + } +} \ No newline at end of file diff --git a/integration_test/tests/mailbox/pull_to_refresh_test.dart b/integration_test/tests/mailbox/pull_to_refresh_test.dart new file mode 100644 index 0000000000..77aa136242 --- /dev/null +++ b/integration_test/tests/mailbox/pull_to_refresh_test.dart @@ -0,0 +1,9 @@ +import '../../base/test_base.dart'; +import '../../scenarios/mailbox/pull_to_refresh_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: 'Should refresh email list when pull to refresh', + scenarioBuilder: ($) => PullToRefreshScenario($), + ); +} \ No newline at end of file diff --git a/integration_test/tests/mailbox/switch_mailbox_test.dart b/integration_test/tests/mailbox/switch_mailbox_test.dart new file mode 100644 index 0000000000..6c788e1853 --- /dev/null +++ b/integration_test/tests/mailbox/switch_mailbox_test.dart @@ -0,0 +1,9 @@ +import '../../base/test_base.dart'; +import '../../scenarios/mailbox/switch_mailbox_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: 'Should switch and see emails in mailboxes', + scenarioBuilder: ($) => SwitchMailboxScenario($), + ); +} \ No newline at end of file