diff --git a/integration_test/factories/mobile_robot_factory.dart b/integration_test/factories/mobile_robot_factory.dart index 60257726f..95020ece2 100644 --- a/integration_test/factories/mobile_robot_factory.dart +++ b/integration_test/factories/mobile_robot_factory.dart @@ -1,5 +1,7 @@ import 'package:patrol/patrol.dart'; +import '../robots/abstract/abstract_app_grid_robot.dart'; +import '../robots/mobile/mobile_app_grid_robot.dart'; import 'robot_factory.dart'; import '../robots/abstract/abstract_login_robot.dart'; import '../robots/abstract/abstract_thread_robot.dart'; @@ -21,4 +23,7 @@ class MobileRobotFactory implements RobotFactory { @override AbstractComposerRobot composerRobot() => MobileComposerRobot($); + + @override + AbstractAppGridRobot appGridRobot() => MobileAppGridRobot($); } diff --git a/integration_test/factories/robot_factory.dart b/integration_test/factories/robot_factory.dart index 1bde8462b..79cf681a6 100644 --- a/integration_test/factories/robot_factory.dart +++ b/integration_test/factories/robot_factory.dart @@ -1,3 +1,4 @@ +import '../robots/abstract/abstract_app_grid_robot.dart'; import '../robots/abstract/abstract_login_robot.dart'; import '../robots/abstract/abstract_thread_robot.dart'; import '../robots/abstract/abstract_composer_robot.dart'; @@ -6,4 +7,5 @@ abstract class RobotFactory { AbstractLoginRobot loginRobot(); AbstractThreadRobot threadRobot(); AbstractComposerRobot composerRobot(); + AbstractAppGridRobot appGridRobot(); } diff --git a/integration_test/factories/web_robot_factory.dart b/integration_test/factories/web_robot_factory.dart index f303c917d..5acdce8f2 100644 --- a/integration_test/factories/web_robot_factory.dart +++ b/integration_test/factories/web_robot_factory.dart @@ -1,11 +1,13 @@ import 'package:patrol/patrol.dart'; +import '../robots/abstract/abstract_app_grid_robot.dart'; +import '../robots/web/web_app_grid_robot.dart'; import '../robots/web/web_login_robot.dart'; +import '../robots/web/web_thread_robot.dart'; import 'robot_factory.dart'; import '../robots/abstract/abstract_login_robot.dart'; import '../robots/abstract/abstract_thread_robot.dart'; import '../robots/abstract/abstract_composer_robot.dart'; -import '../robots/mobile/mobile_thread_robot.dart'; import '../robots/web/web_composer_robot.dart'; class WebRobotFactory implements RobotFactory { @@ -18,8 +20,11 @@ class WebRobotFactory implements RobotFactory { @override // Thread interaction is identical on web — reuse mobile robot - AbstractThreadRobot threadRobot() => MobileThreadRobot($); + AbstractThreadRobot threadRobot() => WebThreadRobot($); @override AbstractComposerRobot composerRobot() => WebComposerRobot($); + + @override + AbstractAppGridRobot appGridRobot() => WebAppGridRobot($); } diff --git a/integration_test/robots/abstract/abstract_app_grid_robot.dart b/integration_test/robots/abstract/abstract_app_grid_robot.dart new file mode 100644 index 000000000..25b7deb49 --- /dev/null +++ b/integration_test/robots/abstract/abstract_app_grid_robot.dart @@ -0,0 +1,6 @@ +abstract class AbstractAppGridRobot { + List get appNames; + Future expectListViewAppGridVisible(); + Future expectAllAppInAppGridDisplayedIsFull(); + Future openAppInAppGrid(); +} \ No newline at end of file diff --git a/integration_test/robots/abstract/abstract_thread_robot.dart b/integration_test/robots/abstract/abstract_thread_robot.dart index 139b0320b..3707a4ac0 100644 --- a/integration_test/robots/abstract/abstract_thread_robot.dart +++ b/integration_test/robots/abstract/abstract_thread_robot.dart @@ -1,3 +1,5 @@ abstract class AbstractThreadRobot { Future openComposer(); + Future expectAppGridVisible(); + Future openAppGrid(); } diff --git a/integration_test/robots/app_grid_robot.dart b/integration_test/robots/app_grid_robot.dart deleted file mode 100644 index 724f87b04..000000000 --- a/integration_test/robots/app_grid_robot.dart +++ /dev/null @@ -1,12 +0,0 @@ - -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 index 32da9ae38..82f31a901 100644 --- a/integration_test/robots/mailbox_menu_robot.dart +++ b/integration_test/robots/mailbox_menu_robot.dart @@ -21,10 +21,6 @@ import '../exceptions/mailbox/null_quota_exception.dart'; class MailboxMenuRobot extends CoreRobot { MailboxMenuRobot(super.$); - Future openAppGrid() async { - await $(#toggle_app_grid_button).tap(); - } - Future openFolderByName(String name) async { final mailboxItem = $(MailboxItemWidget).$(LabelMailboxItemWidget).$(name); await $(mailboxItem).waitUntilExists(); diff --git a/integration_test/robots/mobile/mobile_app_grid_robot.dart b/integration_test/robots/mobile/mobile_app_grid_robot.dart new file mode 100644 index 000000000..c2b482868 --- /dev/null +++ b/integration_test/robots/mobile/mobile_app_grid_robot.dart @@ -0,0 +1,60 @@ +import 'package:core/utils/platform_info.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:patrol/patrol.dart'; +import 'package:tmail_ui_user/features/mailbox/presentation/widgets/app_grid/app_shortcut.dart'; + +import '../abstract/abstract_app_grid_robot.dart'; + +class MobileAppGridRobot implements AbstractAppGridRobot { + const MobileAppGridRobot(this.$); + + final PatrolIntegrationTester $; + + @override + List get appNames => [ + 'Twake Drive', + 'Twake Chat', + if (PlatformInfo.isAndroid) 'Twake Sync', + ]; + + @override + Future expectAllAppInAppGridDisplayedIsFull() async { + await $(#list_view_app_grid).waitUntilVisible(); + } + + @override + Future expectListViewAppGridVisible() async { + int totalApp = PlatformInfo.isIOS ? 2 : 3; + await $(AppShortcut).waitUntilVisible(); + expect(find.byType(AppShortcut), findsNWidgets(totalApp)); + + final listAppItem = + $.tester.widgetList(find.byType(AppShortcut)); + + final listAppNames = listAppItem.map((item) => item.label).toList(); + + expect(listAppNames, equals(appNames)); + } + + @override + Future openAppInAppGrid() async { + for (var appName in appNames) { + await _open(appName); + } + } + + Future _open(String appName) async { + await $(appName).tap(); + await Future.delayed(const Duration(seconds: 2)); + await $.platformAutomator.mobile.pressHome(); + await $.platformAutomator.mobile.openApp(); + await $.platformAutomator.mobile.waitUntilVisible( + MobileSelector( + android: AndroidSelector( + applicationPackage: 'com.linagora.android.teammail', + ), + ios: IOSSelector(identifier: 'com.linagora.ios.teammail'), + ), + ); + } +} diff --git a/integration_test/robots/mobile/mobile_thread_robot.dart b/integration_test/robots/mobile/mobile_thread_robot.dart index c3146668e..d93b306c4 100644 --- a/integration_test/robots/mobile/mobile_thread_robot.dart +++ b/integration_test/robots/mobile/mobile_thread_robot.dart @@ -4,4 +4,15 @@ import 'package:patrol/patrol.dart'; class MobileThreadRobot extends ThreadRobot implements AbstractThreadRobot { MobileThreadRobot(PatrolIntegrationTester $) : super($); + + @override + Future expectAppGridVisible() async { + await openMailbox(); + await $(#toggle_app_grid_button).waitUntilVisible(); + } + + @override + Future openAppGrid() async { + await $(#toggle_app_grid_button).tap(); + } } diff --git a/integration_test/robots/web/web_app_grid_robot.dart b/integration_test/robots/web/web_app_grid_robot.dart new file mode 100644 index 000000000..efbcce160 --- /dev/null +++ b/integration_test/robots/web/web_app_grid_robot.dart @@ -0,0 +1,45 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/app_dashboard/app_grid_dashboard_item.dart'; + +import '../mobile/mobile_app_grid_robot.dart'; + +class WebAppGridRobot extends MobileAppGridRobot { + const WebAppGridRobot(super.$); + + @override + List get appNames => [ + 'Twake', + 'Contacts', + 'Calendar', + 'TMail', + 'TDrive', + 'Teleskop', + ]; + + @override + Future expectListViewAppGridVisible() async { + int totalApp = 6; + await $(AppGridDashboardItem).waitUntilVisible(); + expect(find.byType(AppGridDashboardItem), findsNWidgets(totalApp)); + + final listAppItem = $.tester + .widgetList(find.byType(AppGridDashboardItem)); + + final listAppNames = listAppItem.map((item) => item.app.appName).toList(); + + expect(listAppNames, equals(appNames)); + } + + @override + Future openAppInAppGrid() async { + for (var appName in appNames) { + await _open(appName); + } + } + + Future _open(String appName) async { + await $(appName).tap(); + // close tab + await $.platformAutomator.web.pressKeyCombo(keys: ['Control', 'w']); + } +} diff --git a/integration_test/robots/web/web_thread_robot.dart b/integration_test/robots/web/web_thread_robot.dart new file mode 100644 index 000000000..e9b0b6a0c --- /dev/null +++ b/integration_test/robots/web/web_thread_robot.dart @@ -0,0 +1,10 @@ +import '../mobile/mobile_thread_robot.dart'; + +class WebThreadRobot extends MobileThreadRobot { + WebThreadRobot(super.$); + + @override + Future expectAppGridVisible() async { + await $(#toggle_app_grid_button).waitUntilVisible(); + } +} \ No newline at end of file diff --git a/integration_test/scenarios/app_grid_scenario.dart b/integration_test/scenarios/app_grid_scenario.dart index 3523de68f..8d6f9c008 100644 --- a/integration_test/scenarios/app_grid_scenario.dart +++ b/integration_test/scenarios/app_grid_scenario.dart @@ -1,14 +1,7 @@ - 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/app_grid_icon.dart'; -import 'package:tmail_ui_user/features/mailbox/presentation/widgets/app_grid/app_shortcut.dart'; import '../base/base_test_scenario.dart'; -import '../robots/app_grid_robot.dart'; -import '../robots/mailbox_menu_robot.dart'; -import '../robots/thread_robot.dart'; class AppGridScenario extends BaseTestScenario { @@ -17,65 +10,19 @@ class AppGridScenario extends BaseTestScenario { @override Future runTestLogic() async { PlatformInfo.isIntegrationTesting = true; - final threadRobot = ThreadRobot($); - final mailboxMenuRobot = MailboxMenuRobot($); - final appGridRobot = AppGridRobot($); + final threadRobot = robots.threadRobot(); + final appGridRobot = robots.appGridRobot(); - await threadRobot.openMailbox(); - await _expectMailboxViewVisible(); - await _expectAppGridViewVisible(); + await threadRobot.expectAppGridVisible(); + await threadRobot.openAppGrid(); - await Future.delayed(const Duration(seconds: 2)); + await appGridRobot.expectListViewAppGridVisible(); + await appGridRobot.expectAllAppInAppGridDisplayedIsFull(); - await mailboxMenuRobot.openAppGrid(); - await _expectListViewAppGridVisible(); - await _expectAllAppInAppGridDisplayedIsFull(); + await appGridRobot.openAppInAppGrid(); + + await appGridRobot.expectListViewAppGridVisible(); - await appGridRobot.openAppInAppGridByAppName('Twake Drive'); - await Future.delayed(const Duration(seconds: 2)); - - if (PlatformInfo.isAndroid) { - final native = $.platformAutomator.android; - await native.pressHome(); - await native.openApp(); - - 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 _expectListViewAppGridVisible(); - } else if (PlatformInfo.isIOS) { - await _expectMailboxViewInVisible(); - } PlatformInfo.isIntegrationTesting = false; } - - Future _expectMailboxViewVisible() => expectViewVisible($(MailboxView)); - - Future _expectAppGridViewVisible() => expectViewVisible($(AppGridIcon)); - - Future _expectListViewAppGridVisible() => expectViewVisible($(#list_view_app_grid)); - - Future _expectAllAppInAppGridDisplayedIsFull() async { - int totalApp = PlatformInfo.isIOS ? 2 : 3; - expect(find.byType(AppShortcut), findsNWidgets(totalApp)); - - final listAppItem = $.tester - .widgetList(find.byType(AppShortcut)); - - final listAppNames = listAppItem.map((item) => item.label).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/lib/features/mailbox_dashboard/presentation/widgets/app_dashboard/app_grid_dashboard_overlay.dart b/lib/features/mailbox_dashboard/presentation/widgets/app_dashboard/app_grid_dashboard_overlay.dart index 9b0407078..f16098e4d 100644 --- a/lib/features/mailbox_dashboard/presentation/widgets/app_dashboard/app_grid_dashboard_overlay.dart +++ b/lib/features/mailbox_dashboard/presentation/widgets/app_dashboard/app_grid_dashboard_overlay.dart @@ -26,9 +26,14 @@ class AppDashboardOverlay extends StatelessWidget { boxShadow: AppGridDashboardStyle.cardShadow ), padding: AppGridDashboardStyle.padding, - child: Wrap(children: listLinagoraApp - .map((app) => AppGridDashboardItem(app: app, imagePaths: imagePaths)) - .toList()), + child: Wrap( + key: const ValueKey('list_view_app_grid'), + children: listLinagoraApp + .map( + (app) => AppGridDashboardItem(app: app, imagePaths: imagePaths), + ) + .toList(), + ), ), ); } diff --git a/lib/features/mailbox_dashboard/presentation/widgets/navigation_bar/navigation_bar_widget.dart b/lib/features/mailbox_dashboard/presentation/widgets/navigation_bar/navigation_bar_widget.dart index 824f2386e..c41bf974f 100644 --- a/lib/features/mailbox_dashboard/presentation/widgets/navigation_bar/navigation_bar_widget.dart +++ b/lib/features/mailbox_dashboard/presentation/widgets/navigation_bar/navigation_bar_widget.dart @@ -88,6 +88,7 @@ class NavigationBarWidget extends StatelessWidget { Obx(() { if (appGridController!.listLinagoraApp.isNotEmpty) { return AppGridDashboardIcon( + key: const ValueKey('toggle_app_grid_button'), imagePaths: imagePaths, linagoraApps: appGridController!.listLinagoraApp, );