Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/images/ic_move_folder_content.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/lib/presentation/resources/image_paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class ImagePaths {
String get icMessage => _getImagePath('ic_message.svg');
String get icNavigation => _getImagePath('ic_navigation.svg');
String get icReading => _getImagePath('ic_reading.svg');
String get icMoveFolderContent => _getImagePath('ic_move_folder_content.svg');

String _getImagePath(String imageName) {
return AssetsPaths.images + imageName;
Expand Down
8 changes: 8 additions & 0 deletions integration_test/robots/mailbox_menu_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,12 @@ class MailboxMenuRobot extends CoreRobot {
await $(AppLocalizations().mark_as_read).tap();
await $.pumpAndSettle();
}

Future<void> tapMoveFolderContentAction(String mailboxName) async {
await $(AppLocalizations().moveFolderContent).tap();
await $.pumpAndTrySettle();

await $(mailboxName).tap();
await $.pumpAndTrySettle();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';

import '../../base/base_test_scenario.dart';
import '../../models/provisioning_email.dart';
import '../../robots/mailbox_menu_robot.dart';
import '../../robots/thread_robot.dart';

class MoveFolderContentScenario extends BaseTestScenario {
const MoveFolderContentScenario(super.$);

@override
Future<void> runTestLogic() async {
const email = String.fromEnvironment('BASIC_AUTH_EMAIL');
const emailSubject = 'Move folder content';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have other emails in Inbox ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible if we run multiple tests simultaneously.


final threadRobot = ThreadRobot($);
final mailboxMenuRobot = MailboxMenuRobot($);
final appLocalizations = AppLocalizations();

final listEmails = List.generate(
40,
(_) => ProvisioningEmail(
toEmail: email,
subject: emailSubject,
content: '',
),
);

await provisionEmail(listEmails);
await $.pumpAndTrySettle(duration: const Duration(seconds: 2));
await _expectEmptyViewInVisibleInInboxFolder();

await threadRobot.openMailbox();
await $.pumpAndTrySettle();

await mailboxMenuRobot.longPressMailboxWithName(
appLocalizations.inboxMailboxDisplayName,
);
await mailboxMenuRobot.tapMoveFolderContentAction(
appLocalizations.templatesMailboxDisplayName,
);
await $.pumpAndTrySettle(duration: const Duration(seconds: 3));

await threadRobot.openMailbox();
await $.pumpAndTrySettle();
await mailboxMenuRobot.openFolderByName(
appLocalizations.templatesMailboxDisplayName,
);
await $.pumpAndTrySettle();
await _expectEmailWithSubjectVisible(emailSubject);

await threadRobot.openMailbox();
await $.pumpAndTrySettle();
await mailboxMenuRobot.openFolderByName(
appLocalizations.inboxMailboxDisplayName,
);
await $.pumpAndTrySettle();
await _expectEmailWithSubjectInVisible(emailSubject);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about verify also empty widget in Inbox?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just need to verify if the widget is displayed. I have updated the E2E expect.

πŸ§ͺ Should see all Inbox emails in the Templates folder when perform move folder content action successfully
        βœ…   1. waitUntilVisible widgets with type "TwakeWelcomeView".
        βœ…   2. tap widgets with text "Use company server".
        βœ…   3. waitUntilVisible widgets with type "LoginView".
        βœ…   4. tap widgets with type "TextField" descending from widgets with key [<'dns_lookup_input_form'>].
        βœ…   5. enterText widgets with type "TextField" descending from widgets with key [<'dns_lookup_input_form'>].
        βœ…   6. waitUntilVisible widgets with text "bob".
        βœ…   7. tap widgets with text "Next".
        βœ…   8. waitUntilVisible widgets with key [<'base_url_form'>] descending from widgets with type "LoginView".
        βœ…   9. enterText widgets with type "TextField" descending from widgets with key [<'base_url_form'>].
        βœ…  10. waitUntilVisible widgets with text containing 016e14f5ac71.ngrok-free.app.
        βœ…  11. tap widgets with text "Next".
        βœ…  12. waitUntilVisible widgets with key [<'credential_input_form'>] descending from widgets with type "LoginView".
        βœ…  13. enterText widgets with type "TextField" descending from widgets with key [<'login_username_input'>].
        βœ…  14. waitUntilVisible widgets with text "bob@example.com".
βœ… Should see all Inbox emails in the Templates folder when perform move folder content action successfully (integration_test/tests/mailbox/move_folder_content_test.dart) (25s)

Test summary:
πŸ“ Total: 1
βœ… Successful: 1
❌ Failed: 0
⏩ Skipped: 0
πŸ“Š Report: file:///Users/datvu/WorkingSpace/tmail-flutter/build/app/reports/androidTests/connected/index.html
⏱️  Duration: 91s

await _expectEmptyViewVisibleInInboxFolder();
}

Future<void> _expectEmailWithSubjectVisible(String subject) async {
await expectViewVisible($(subject));
}

Future<void> _expectEmailWithSubjectInVisible(String subject) async {
await expectViewInvisible($(subject));
}

Future<void> _expectEmptyViewVisibleInInboxFolder() async {
await expectViewVisible($(#empty_thread_view));
}

Future<void> _expectEmptyViewInVisibleInInboxFolder() async {
await expectViewInvisible($(#empty_thread_view));
}
}
9 changes: 9 additions & 0 deletions integration_test/tests/mailbox/move_folder_content_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import '../../base/test_base.dart';
import '../../scenarios/mailbox/move_folder_content_scenario.dart';

void main() {
TestBase().runPatrolTest(
description: 'Should see all Inbox emails in the Templates folder when perform move folder content action successfully',
scenarioBuilder: ($) => MoveFolderContentScenario($),
);
}
35 changes: 35 additions & 0 deletions lib/features/base/base_mailbox_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';

typedef RenameMailboxActionCallback = void Function(PresentationMailbox mailbox, MailboxName newMailboxName);
typedef MovingMailboxActionCallback = void Function(PresentationMailbox mailboxSelected, PresentationMailbox? destinationMailbox);
typedef OnMoveFolderContentActionCallback = void Function(
PresentationMailbox currentMailbox,
PresentationMailbox destinationMailbox,
String destinationMailboxName,
);
typedef DeleteMailboxActionCallback = void Function(PresentationMailbox mailbox);
typedef AllowSubaddressingActionCallback = void Function(MailboxId, Map<String, List<String>?>?, MailboxActions);

Expand Down Expand Up @@ -637,4 +642,34 @@ abstract class BaseMailboxController extends BaseController
triggerScrollWhenExpandFolder(newExpandMode, itemKey, scrollController);
}
}

void moveFolderContentAction({
required AppLocalizations appLocalizations,
required AccountId accountId,
required Session session,
required PresentationMailbox mailboxSelected,
required OnMoveFolderContentActionCallback onMoveFolderContentAction,
}) async {
final arguments = DestinationPickerArguments(
accountId,
MailboxActions.moveFolderContent,
session,
mailboxIdSelected: mailboxSelected.id,
);

final destinationMailbox = PlatformInfo.isWeb
? await DialogRouter.pushGeneralDialog(
routeName: AppRoutes.destinationPicker,
arguments: arguments,
)
: await push(AppRoutes.destinationPicker, arguments: arguments);
if (destinationMailbox is PresentationMailbox) {
log('$runtimeType::moveFolderContentAction: DestinationMailbox is ${destinationMailbox.name?.name}');
onMoveFolderContentAction(
mailboxSelected,
destinationMailbox,
destinationMailbox.getDisplayNameWithoutContext(appLocalizations),
);
}
}
}
2 changes: 1 addition & 1 deletion lib/features/base/mixin/handle_error_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:core/core.dart';
import 'package:core/utils/app_logger.dart';
import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
Expand Down
Loading
Loading