From ef40045fe345372619fb8e03f528fa129bffba79 Mon Sep 17 00:00:00 2001 From: dab246 Date: Thu, 12 Dec 2024 16:18:20 +0700 Subject: [PATCH] TF-3260 Add integration test for app grid --- backend-docker/docker-compose.yaml | 3 +- backend-docker/linagora-ecosystem.properties | 11 +++ backend-docker/mailetcontainer.xml | 10 +-- integration_test/base/base_scenario.dart | 4 + integration_test/robots/app_grid_robot.dart | 12 +++ .../robots/mailbox_menu_robot.dart | 10 +++ integration_test/robots/thread_robot.dart | 4 + .../scenarios/app_grid_scenario.dart | 88 +++++++++++++++++++ .../tests/app_grid/app_grid_test.dart | 24 +++++ .../presentation/widgets/app_grid_view.dart | 2 + 10 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 backend-docker/linagora-ecosystem.properties create mode 100644 integration_test/robots/app_grid_robot.dart create mode 100644 integration_test/robots/mailbox_menu_robot.dart create mode 100644 integration_test/scenarios/app_grid_scenario.dart create mode 100644 integration_test/tests/app_grid/app_grid_test.dart diff --git a/backend-docker/docker-compose.yaml b/backend-docker/docker-compose.yaml index c42db448ca..74acc5279b 100644 --- a/backend-docker/docker-compose.yaml +++ b/backend-docker/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3" services: tmail-backend: - image: linagora/tmail-backend:memory-1.0.0 + image: linagora/tmail-backend:memory-1.0.1-rc1 container_name: tmail-backend volumes: - ./jwt_publickey:/root/conf/jwt_publickey @@ -10,6 +10,7 @@ services: - ./mailetcontainer.xml:/root/conf/mailetcontainer.xml - ./imapserver.xml:/root/conf/imapserver.xml - ./jmap.properties:/root/conf/jmap.properties + - ./linagora-ecosystem.properties:/root/conf/linagora-ecosystem.properties - ../provisioning/integration_test/search_email_with_sort_order/provisioning.sh:/root/conf/integration_test/search_email_with_sort_order/provisioning.sh - ../provisioning/integration_test/search_email_with_sort_order/eml:/root/conf/integration_test/search_email_with_sort_order/eml ports: diff --git a/backend-docker/linagora-ecosystem.properties b/backend-docker/linagora-ecosystem.properties new file mode 100644 index 0000000000..3ca4d78ce5 --- /dev/null +++ b/backend-docker/linagora-ecosystem.properties @@ -0,0 +1,11 @@ +Twake_Drive.appName=Twake Drive +Twake_Drive.logoURL=https://sign-up.stg.lin-saas.com/images/tdrive.svg +Twake_Drive.webLink=https://drive.stg.lin-saas.com/ +mobileApps.Twake_Chat.appName=Twake Chat +mobileApps.Twake_Chat.logoURL=https://sign-up.stg.lin-saas.com/images/twakechat.svg +mobileApps.Twake_Chat.androidPackageId=app.twake.android.chat +mobileApps.Twake_Chat.iosUrlScheme=twake.chat +mobileApps.Twake_Chat.iosAppStoreLink=itms-apps://itunes.apple.com/us/app/twake-chat/id6473384641 +mobileApps.Twake_Sync.appName=Twake Sync +mobileApps.Twake_Sync.logoURL=https://twake.app/tild3364-6130-4763-b634-343435643861__twp-logo_1.svg +mobileApps.Twake_Sync.androidPackageId=com.twake.android.sync \ No newline at end of file diff --git a/backend-docker/mailetcontainer.xml b/backend-docker/mailetcontainer.xml index 383173ef8b..a0c694fd62 100644 --- a/backend-docker/mailetcontainer.xml +++ b/backend-docker/mailetcontainer.xml @@ -65,6 +65,10 @@ bcc ignore + + X-SMIME-Status + ignore + rrt-error @@ -88,9 +92,6 @@ - - ContactAttribute1 - @@ -151,5 +152,4 @@ - - + \ No newline at end of file diff --git a/integration_test/base/base_scenario.dart b/integration_test/base/base_scenario.dart index 1bd8e923f5..7422522c16 100644 --- a/integration_test/base/base_scenario.dart +++ b/integration_test/base/base_scenario.dart @@ -12,4 +12,8 @@ abstract class BaseScenario { await $.waitUntilVisible(patrolFinder); expect(patrolFinder, findsWidgets); } + + Future expectViewInVisible(PatrolFinder patrolFinder) async { + expect(patrolFinder, findsNothing); + } } \ No newline at end of file diff --git a/integration_test/robots/app_grid_robot.dart b/integration_test/robots/app_grid_robot.dart new file mode 100644 index 0000000000..724f87b04c --- /dev/null +++ b/integration_test/robots/app_grid_robot.dart @@ -0,0 +1,12 @@ + +import 'package:flutter_test/flutter_test.dart'; + +import '../base/core_robot.dart'; + +class AppGridRobot extends CoreRobot { + AppGridRobot(super.$); + + Future openAppInAppGridByAppName(String appName) async { + await $(find.text(appName)).tap(); + } +} \ No newline at end of file diff --git a/integration_test/robots/mailbox_menu_robot.dart b/integration_test/robots/mailbox_menu_robot.dart new file mode 100644 index 0000000000..f2a7a1a512 --- /dev/null +++ b/integration_test/robots/mailbox_menu_robot.dart @@ -0,0 +1,10 @@ + +import '../base/core_robot.dart'; + +class MailboxMenuRobot extends CoreRobot { + MailboxMenuRobot(super.$); + + Future openAppGrid() async { + await $(#toggle_app_grid_button).tap(); + } +} \ No newline at end of file diff --git a/integration_test/robots/thread_robot.dart b/integration_test/robots/thread_robot.dart index 8789a7af76..cc2f9c595c 100644 --- a/integration_test/robots/thread_robot.dart +++ b/integration_test/robots/thread_robot.dart @@ -19,4 +19,8 @@ class ThreadRobot extends CoreRobot { Future tapOnSearchField() async { await $(ThreadView).$(SearchBarView).tap(); } + + Future openMailbox() async { + await $(#mobile_mailbox_menu_button).tap(); + } } \ No newline at end of file diff --git a/integration_test/scenarios/app_grid_scenario.dart b/integration_test/scenarios/app_grid_scenario.dart new file mode 100644 index 0000000000..2dd6f65b83 --- /dev/null +++ b/integration_test/scenarios/app_grid_scenario.dart @@ -0,0 +1,88 @@ + +import 'package:core/utils/platform_info.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:tmail_ui_user/features/mailbox/presentation/mailbox_view.dart'; +import 'package:tmail_ui_user/features/mailbox/presentation/widgets/app_grid_view.dart'; +import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/app_dashboard/app_list_dashboard_item.dart'; + +import '../base/base_scenario.dart'; +import '../robots/app_grid_robot.dart'; +import '../robots/mailbox_menu_robot.dart'; +import '../robots/thread_robot.dart'; +import 'login_with_basic_auth_scenario.dart'; + +class AppGridScenario extends BaseScenario { + + final LoginWithBasicAuthScenario loginWithBasicAuthScenario; + + AppGridScenario( + super.$, + { + required this.loginWithBasicAuthScenario + } + ); + + @override + Future execute() async { + final threadRobot = ThreadRobot($); + final mailboxMenuRobot = MailboxMenuRobot($); + final appGridRobot = AppGridRobot($); + + await loginWithBasicAuthScenario.execute(); + + await threadRobot.openMailbox(); + await _expectMailboxViewVisible(); + await _expectAppGridViewVisible(); + + await Future.delayed(const Duration(seconds: 2)); + + await mailboxMenuRobot.openAppGrid(); + await _expectListViewAppGridVisible(); + await _expectAllAppInAppGridDisplayedIsFull(); + + await appGridRobot.openAppInAppGridByAppName('Twake Drive'); + await Future.delayed(const Duration(seconds: 2)); + + if (PlatformInfo.isAndroid) { + await $.native.pressBack(); + + await appGridRobot.openAppInAppGridByAppName('Twake Sync'); + await Future.delayed(const Duration(seconds: 2)); + + await $.native.pressBack(); + + await appGridRobot.openAppInAppGridByAppName('Twake Chat'); + await Future.delayed(const Duration(seconds: 2)); + + await $.native.pressBack(); + + await _expectMailboxViewVisible(); + } else if (PlatformInfo.isIOS) { + await _expectMailboxViewInVisible(); + } + } + + Future _expectMailboxViewVisible() => expectViewVisible($(MailboxView)); + + Future _expectAppGridViewVisible() => expectViewVisible($(AppGridView)); + + Future _expectListViewAppGridVisible() => expectViewVisible($(#list_view_app_grid)); + + Future _expectAllAppInAppGridDisplayedIsFull() async { + int totalApp = PlatformInfo.isIOS ? 2 : 3; + expect(find.byType(AppListDashboardItem), findsNWidgets(totalApp)); + + final listAppItem = $.tester + .widgetList(find.byType(AppListDashboardItem)); + + final listAppNames = listAppItem.map((item) => item.app.appName).toList(); + + if (PlatformInfo.isIOS) { + expect(listAppNames, equals(['Twake Drive', 'Twake Chat'])); + } else { + expect(listAppNames, equals(['Twake Drive', 'Twake Chat', 'Twake Sync'])); + } + } + + Future _expectMailboxViewInVisible() => expectViewInVisible($(MailboxView)); +} \ No newline at end of file diff --git a/integration_test/tests/app_grid/app_grid_test.dart b/integration_test/tests/app_grid/app_grid_test.dart new file mode 100644 index 0000000000..3ea0b7a692 --- /dev/null +++ b/integration_test/tests/app_grid/app_grid_test.dart @@ -0,0 +1,24 @@ +import '../../base/test_base.dart'; +import '../../scenarios/app_grid_scenario.dart'; +import '../../scenarios/login_with_basic_auth_scenario.dart'; + +void main() { + TestBase().runPatrolTest( + description: 'Should display and navigate app grid correctly when clicked', + test: ($) async { + final loginWithBasicAuthScenario = LoginWithBasicAuthScenario($, + username: const String.fromEnvironment('USERNAME'), + hostUrl: const String.fromEnvironment('BASIC_AUTH_URL'), + email: const String.fromEnvironment('BASIC_AUTH_EMAIL'), + password: const String.fromEnvironment('PASSWORD'), + ); + + final appGridScenario = AppGridScenario( + $, + loginWithBasicAuthScenario: loginWithBasicAuthScenario, + ); + + await appGridScenario.execute(); + } + ); +} \ No newline at end of file diff --git a/lib/features/mailbox/presentation/widgets/app_grid_view.dart b/lib/features/mailbox/presentation/widgets/app_grid_view.dart index 313575121e..3603e210a1 100644 --- a/lib/features/mailbox/presentation/widgets/app_grid_view.dart +++ b/lib/features/mailbox/presentation/widgets/app_grid_view.dart @@ -67,6 +67,7 @@ class _AppGridViewState extends State { valueListenable: _isCollapsedNotifier, builder: (context, isCollapsed, child) { return TMailButtonWidget.fromIcon( + key: const Key('toggle_app_grid_button'), icon: _getCollapseIcon(context, isCollapsed), iconColor: isCollapsed ? AppColor.colorIconUnSubscribedMailbox @@ -94,6 +95,7 @@ class _AppGridViewState extends State { } }, child: ListView.builder( + key: const Key('list_view_app_grid'), shrinkWrap: true, primary: false, padding: const EdgeInsetsDirectional.only(