chore: Split up tests even more
This commit is contained in:
parent
e959c24a05
commit
bb188724ae
6 changed files with 51 additions and 27 deletions
|
|
@ -1,9 +1,13 @@
|
||||||
import 'package:fluffychat/pages/sign_in/view_model/model/public_homeserver_data.dart';
|
import 'package:fluffychat/pages/sign_in/view_model/model/public_homeserver_data.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import '../data/environment_constants.dart';
|
import '../data/environment_constants.dart';
|
||||||
import '../utils/fluffy_chat_tester.dart';
|
import '../utils/fluffy_chat_tester.dart';
|
||||||
|
|
||||||
|
Future<void> finalLogout(WidgetTester widgetTester) =>
|
||||||
|
widgetTester.startFluffyChatTest().then((tester) => tester.logout());
|
||||||
|
|
||||||
extension AuthFlows on FluffyChatTester {
|
extension AuthFlows on FluffyChatTester {
|
||||||
Future<void> login() async {
|
Future<void> login() async {
|
||||||
await waitFor('Sign in');
|
await waitFor('Sign in');
|
||||||
|
|
@ -18,6 +22,7 @@ extension AuthFlows on FluffyChatTester {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> logout() async {
|
Future<void> logout() async {
|
||||||
|
await ensureLoggedIn();
|
||||||
await tapOn(Key('accounts_and_settings_buttons'));
|
await tapOn(Key('accounts_and_settings_buttons'));
|
||||||
await tapOn('Settings');
|
await tapOn('Settings');
|
||||||
await scrollUntilVisible('Logout');
|
await scrollUntilVisible('Logout');
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
|
||||||
import 'package:fluffychat/widgets/chat_settings_popup_menu.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import '../utils/fluffy_chat_tester.dart';
|
import '../utils/fluffy_chat_tester.dart';
|
||||||
import 'auth_flows.dart';
|
import 'auth_flows.dart';
|
||||||
|
import 'chat_flows.dart';
|
||||||
|
|
||||||
Future<void> basicMessaging(WidgetTester widgetTester) => widgetTester
|
Future<void> basicMessaging(WidgetTester widgetTester) => widgetTester
|
||||||
.startFluffyChatTest()
|
.startFluffyChatTest()
|
||||||
|
|
@ -12,31 +11,13 @@ Future<void> basicMessaging(WidgetTester widgetTester) => widgetTester
|
||||||
|
|
||||||
extension on FluffyChatTester {
|
extension on FluffyChatTester {
|
||||||
Future<void> _basicMessaging() async {
|
Future<void> _basicMessaging() async {
|
||||||
final shouldLogout = await ensureLoggedIn();
|
await ensureLoggedIn();
|
||||||
|
await ensureGroupChatCreated();
|
||||||
|
|
||||||
// Create a new group chat
|
await tapOn(ChatFlows.groupChatName);
|
||||||
await tapOn(FloatingActionButton);
|
|
||||||
await tapOn('Create group');
|
|
||||||
await enterText(TextField, 'Test Group 01');
|
|
||||||
await tapOn('Create a group and invite users');
|
|
||||||
await waitFor('Invite contact');
|
|
||||||
await goBack();
|
|
||||||
|
|
||||||
// Send a message
|
|
||||||
const testMessage = 'Hello from integration test!';
|
const testMessage = 'Hello from integration test!';
|
||||||
await enterText(Key('chat_input_field'), testMessage);
|
await enterText(Key('chat_input_field'), testMessage);
|
||||||
await tapOn(Key('send_button'));
|
await tapOn(Key('send_button'));
|
||||||
|
|
||||||
// Ensure message is visible
|
|
||||||
await waitFor(testMessage);
|
await waitFor(testMessage);
|
||||||
|
|
||||||
// Archive the chat
|
|
||||||
await tapOn(ChatSettingsPopupMenu);
|
|
||||||
await tapOn('Leave');
|
|
||||||
await waitFor('Are you sure?');
|
|
||||||
await tapOn('Leave');
|
|
||||||
await waitFor(ChatList);
|
|
||||||
|
|
||||||
if (shouldLogout) await logout();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
integration_test/flows/chat_flows.dart
Normal file
35
integration_test/flows/chat_flows.dart
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||||
|
import 'package:fluffychat/widgets/chat_settings_popup_menu.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import '../utils/fluffy_chat_tester.dart';
|
||||||
|
import 'auth_flows.dart';
|
||||||
|
|
||||||
|
Future<void> archiveChats(WidgetTester widgetTester) =>
|
||||||
|
widgetTester.startFluffyChatTest().then((tester) => tester._archiveChats());
|
||||||
|
|
||||||
|
extension ChatFlows on FluffyChatTester {
|
||||||
|
static const String groupChatName = 'Test Group 01';
|
||||||
|
|
||||||
|
Future<void> ensureGroupChatCreated() async {
|
||||||
|
if (await isVisible(groupChatName)) return;
|
||||||
|
await tapOn(FloatingActionButton);
|
||||||
|
await tapOn('Create group');
|
||||||
|
await enterText(TextField, groupChatName);
|
||||||
|
await tapOn('Create a group and invite users');
|
||||||
|
await waitFor('Invite contact');
|
||||||
|
await goBack();
|
||||||
|
await goBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _archiveChats() async {
|
||||||
|
await ensureLoggedIn();
|
||||||
|
await ensureGroupChatCreated();
|
||||||
|
await tapOn(ChatSettingsPopupMenu);
|
||||||
|
await tapOn('Leave');
|
||||||
|
await waitFor('Are you sure?');
|
||||||
|
await tapOn('Leave');
|
||||||
|
await waitFor(ChatList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
|
import 'flows/auth_flows.dart';
|
||||||
import 'flows/basic_messaging.dart';
|
import 'flows/basic_messaging.dart';
|
||||||
|
import 'flows/chat_flows.dart';
|
||||||
import 'flows/login_and_chat_backup.dart';
|
import 'flows/login_and_chat_backup.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
@ -10,5 +12,7 @@ void main() {
|
||||||
group('FluffyChat Integration Tests', () {
|
group('FluffyChat Integration Tests', () {
|
||||||
testWidgets('Login and logout flow', loginAndChatBackup);
|
testWidgets('Login and logout flow', loginAndChatBackup);
|
||||||
testWidgets('Basic Messaging', basicMessaging);
|
testWidgets('Basic Messaging', basicMessaging);
|
||||||
|
testWidgets('Archive chats', archiveChats);
|
||||||
|
testWidgets('Final logout', finalLogout);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,7 @@ extension type FluffyChatTester(WidgetTester tester) {
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> goBack() async {
|
Future<void> goBack() => tapOn(find.byTooltip('Back'));
|
||||||
_print('🔙 Going a page back');
|
|
||||||
await tester.pageBack();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> enterText(Object object, String text, {int? index}) async {
|
Future<void> enterText(Object object, String text, {int? index}) async {
|
||||||
final finder = await _ensureVisible(object, index: index);
|
final finder = await _ensureVisible(object, index: index);
|
||||||
|
|
|
||||||
|
|
@ -553,6 +553,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
timeline?.cancelSubscriptions();
|
timeline?.cancelSubscriptions();
|
||||||
timeline = null;
|
timeline = null;
|
||||||
inputFocus.removeListener(_inputFocusListener);
|
inputFocus.removeListener(_inputFocusListener);
|
||||||
|
if (currentlyTyping) room.setTyping(false);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1289,6 +1290,7 @@ class ChatController extends State<ChatPageWithRoom>
|
||||||
if (AppSettings.sendTypingNotifications.value) {
|
if (AppSettings.sendTypingNotifications.value) {
|
||||||
typingCoolDown?.cancel();
|
typingCoolDown?.cancel();
|
||||||
typingCoolDown = Timer(const Duration(seconds: 2), () {
|
typingCoolDown = Timer(const Duration(seconds: 2), () {
|
||||||
|
if (!mounted) return;
|
||||||
typingCoolDown = null;
|
typingCoolDown = null;
|
||||||
currentlyTyping = false;
|
currentlyTyping = false;
|
||||||
room.setTyping(false);
|
room.setTyping(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue