Skip to content

Commit

Permalink
TF-3260 Add integration test for app grid
Browse files Browse the repository at this point in the history
  • Loading branch information
dab246 committed Dec 12, 2024
1 parent 321df46 commit ef40045
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 6 deletions.
3 changes: 2 additions & 1 deletion backend-docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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
- ./jwt_privatekey:/root/conf/jwt_privatekey
- ./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:
Expand Down
11 changes: 11 additions & 0 deletions backend-docker/linagora-ecosystem.properties
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions backend-docker/mailetcontainer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
<name>bcc</name>
<onMailetException>ignore</onMailetException>
</mailet>
<mailet match="All" class="RemoveMimeHeader">
<name>X-SMIME-Status</name>
<onMailetException>ignore</onMailetException>
</mailet>
<mailet match="All" class="RecipientRewriteTable">
<errorProcessor>rrt-error</errorProcessor>
</mailet>
Expand All @@ -88,9 +92,6 @@
<mailet match="All" class="Sieve"/>
<mailet match="All" class="AddDeliveredToHeader"/>
<mailet match="All" class="org.apache.james.jmap.mailet.filter.JMAPFiltering"/>
<mailet match="SenderIsLocal" class="com.linagora.tmail.mailets.ContactsCollection">
<attribute>ContactAttribute1</attribute>
</mailet>
<mailet match="All" class="com.linagora.tmail.mailets.TmailLocalDelivery"/>
</processor>

Expand Down Expand Up @@ -151,5 +152,4 @@

</processors>

</mailetcontainer>

</mailetcontainer>
4 changes: 4 additions & 0 deletions integration_test/base/base_scenario.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ abstract class BaseScenario {
await $.waitUntilVisible(patrolFinder);
expect(patrolFinder, findsWidgets);
}

Future<void> expectViewInVisible(PatrolFinder patrolFinder) async {
expect(patrolFinder, findsNothing);
}
}
12 changes: 12 additions & 0 deletions integration_test/robots/app_grid_robot.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

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();
}
}
10 changes: 10 additions & 0 deletions integration_test/robots/mailbox_menu_robot.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import '../base/core_robot.dart';

class MailboxMenuRobot extends CoreRobot {
MailboxMenuRobot(super.$);

Future<void> openAppGrid() async {
await $(#toggle_app_grid_button).tap();
}
}
4 changes: 4 additions & 0 deletions integration_test/robots/thread_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ class ThreadRobot extends CoreRobot {
Future<void> tapOnSearchField() async {
await $(ThreadView).$(SearchBarView).tap();
}

Future<void> openMailbox() async {
await $(#mobile_mailbox_menu_button).tap();
}
}
88 changes: 88 additions & 0 deletions integration_test/scenarios/app_grid_scenario.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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<void> _expectMailboxViewVisible() => expectViewVisible($(MailboxView));

Future<void> _expectAppGridViewVisible() => expectViewVisible($(AppGridView));

Future<void> _expectListViewAppGridVisible() => expectViewVisible($(#list_view_app_grid));

Future<void> _expectAllAppInAppGridDisplayedIsFull() async {
int totalApp = PlatformInfo.isIOS ? 2 : 3;
expect(find.byType(AppListDashboardItem), findsNWidgets(totalApp));

final listAppItem = $.tester
.widgetList<AppListDashboardItem>(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<void> _expectMailboxViewInVisible() => expectViewInVisible($(MailboxView));
}
24 changes: 24 additions & 0 deletions integration_test/tests/app_grid/app_grid_test.dart
Original file line number Diff line number Diff line change
@@ -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();
}
);
}
2 changes: 2 additions & 0 deletions lib/features/mailbox/presentation/widgets/app_grid_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class _AppGridViewState extends State<AppGridView> {
valueListenable: _isCollapsedNotifier,
builder: (context, isCollapsed, child) {
return TMailButtonWidget.fromIcon(
key: const Key('toggle_app_grid_button'),
icon: _getCollapseIcon(context, isCollapsed),
iconColor: isCollapsed
? AppColor.colorIconUnSubscribedMailbox
Expand Down Expand Up @@ -94,6 +95,7 @@ class _AppGridViewState extends State<AppGridView> {
}
},
child: ListView.builder(
key: const Key('list_view_app_grid'),
shrinkWrap: true,
primary: false,
padding: const EdgeInsetsDirectional.only(
Expand Down

0 comments on commit ef40045

Please sign in to comment.