mirror of
https://github.com/linagora/tmail-flutter.git
synced 2026-12-06 16:04:20 +00:00
Patrol Web App grid
This commit is contained in:
1 parent
987746fefa
commit
0f51f2ef41
14 files changed
+166
-83
No files matched your search
@@ -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($);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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($);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
abstract class AbstractAppGridRobot {
|
||||
List<String> get appNames;
|
||||
Future<void> expectListViewAppGridVisible();
|
||||
Future<void> expectAllAppInAppGridDisplayedIsFull();
|
||||
Future<void> openAppInAppGrid();
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
abstract class AbstractThreadRobot {
|
||||
Future<void> openComposer();
|
||||
Future<void> expectAppGridVisible();
|
||||
Future<void> openAppGrid();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../base/core_robot.dart';
|
||||
|
||||
class AppGridRobot extends CoreRobot {
|
||||
AppGridRobot(super.$);
|
||||
|
||||
Future<void> openAppInAppGridByAppName(String appName) async {
|
||||
await $(find.text(appName)).tap();
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,6 @@ import '../exceptions/mailbox/null_quota_exception.dart';
|
||||
class MailboxMenuRobot extends CoreRobot {
|
||||
MailboxMenuRobot(super.$);
|
||||
|
||||
Future<void> openAppGrid() async {
|
||||
await $(#toggle_app_grid_button).tap();
|
||||
}
|
||||
|
||||
Future<void> openFolderByName(String name) async {
|
||||
final mailboxItem = $(MailboxItemWidget).$(LabelMailboxItemWidget).$(name);
|
||||
await $(mailboxItem).waitUntilExists();
|
||||
|
||||
@@ -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<String> get appNames => [
|
||||
'Twake Drive',
|
||||
'Twake Chat',
|
||||
if (PlatformInfo.isAndroid) 'Twake Sync',
|
||||
];
|
||||
|
||||
@override
|
||||
Future<void> expectAllAppInAppGridDisplayedIsFull() async {
|
||||
await $(#list_view_app_grid).waitUntilVisible();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> expectListViewAppGridVisible() async {
|
||||
int totalApp = PlatformInfo.isIOS ? 2 : 3;
|
||||
await $(AppShortcut).waitUntilVisible();
|
||||
expect(find.byType(AppShortcut), findsNWidgets(totalApp));
|
||||
|
||||
final listAppItem =
|
||||
$.tester.widgetList<AppShortcut>(find.byType(AppShortcut));
|
||||
|
||||
final listAppNames = listAppItem.map((item) => item.label).toList();
|
||||
|
||||
expect(listAppNames, equals(appNames));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> openAppInAppGrid() async {
|
||||
for (var appName in appNames) {
|
||||
await _open(appName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _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'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,15 @@ import 'package:patrol/patrol.dart';
|
||||
|
||||
class MobileThreadRobot extends ThreadRobot implements AbstractThreadRobot {
|
||||
MobileThreadRobot(PatrolIntegrationTester $) : super($);
|
||||
|
||||
@override
|
||||
Future<void> expectAppGridVisible() async {
|
||||
await openMailbox();
|
||||
await $(#toggle_app_grid_button).waitUntilVisible();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> openAppGrid() async {
|
||||
await $(#toggle_app_grid_button).tap();
|
||||
}
|
||||
}
|
||||
@@ -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<String> get appNames => [
|
||||
'Twake',
|
||||
'Contacts',
|
||||
'Calendar',
|
||||
'TMail',
|
||||
'TDrive',
|
||||
'Teleskop',
|
||||
];
|
||||
|
||||
@override
|
||||
Future<void> expectListViewAppGridVisible() async {
|
||||
int totalApp = 6;
|
||||
await $(AppGridDashboardItem).waitUntilVisible();
|
||||
expect(find.byType(AppGridDashboardItem), findsNWidgets(totalApp));
|
||||
|
||||
final listAppItem = $.tester
|
||||
.widgetList<AppGridDashboardItem>(find.byType(AppGridDashboardItem));
|
||||
|
||||
final listAppNames = listAppItem.map((item) => item.app.appName).toList();
|
||||
|
||||
expect(listAppNames, equals(appNames));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> openAppInAppGrid() async {
|
||||
for (var appName in appNames) {
|
||||
await _open(appName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _open(String appName) async {
|
||||
await $(appName).tap();
|
||||
// close tab
|
||||
await $.platformAutomator.web.pressKeyCombo(keys: ['Control', 'w']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import '../mobile/mobile_thread_robot.dart';
|
||||
|
||||
class WebThreadRobot extends MobileThreadRobot {
|
||||
WebThreadRobot(super.$);
|
||||
|
||||
@override
|
||||
Future<void> expectAppGridVisible() async {
|
||||
await $(#toggle_app_grid_button).waitUntilVisible();
|
||||
}
|
||||
}
|
||||
@@ -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<void> 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<void> _expectMailboxViewVisible() => expectViewVisible($(MailboxView));
|
||||
|
||||
Future<void> _expectAppGridViewVisible() => expectViewVisible($(AppGridIcon));
|
||||
|
||||
Future<void> _expectListViewAppGridVisible() => expectViewVisible($(#list_view_app_grid));
|
||||
|
||||
Future<void> _expectAllAppInAppGridDisplayedIsFull() async {
|
||||
int totalApp = PlatformInfo.isIOS ? 2 : 3;
|
||||
expect(find.byType(AppShortcut), findsNWidgets(totalApp));
|
||||
|
||||
final listAppItem = $.tester
|
||||
.widgetList<AppShortcut>(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<void> _expectMailboxViewInVisible() => expectViewInvisible($(MailboxView));
|
||||
}
|
||||
+8
-3
@@ -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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
+1
@@ -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,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user