Initial commit
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2026-09-11 15:59:56 -03:00
commit 0037b0b9cf
651 changed files with 199705 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:tatchat/pages/sign_in/view_model/model/public_homeserver_data.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';
import '../data/environment_constants.dart';
import '../utils/tatu_chat_tester.dart';
Future<void> finalLogout(WidgetTester widgetTester) =>
widgetTester.startTatuChatTest().then((tester) => tester.logout());
extension AuthFlows on TatuChatTester {
Future<void> initCryptoIdentity({String username = user1Name}) async {
final passphrase = userPassphrases[username];
if (passphrase != null) {
await waitFor('Restore Crypto Identity');
await enterText(TextField, passphrase);
await tapOn('Unlock');
} else {
await waitFor('Set Up Crypto Identity');
await enterText(TextField, passphrase1, index: 0);
await enterText(TextField, passphrase1, index: 1);
await tapOn('Continue');
await tapOn('Continue');
userPassphrases[username] = passphrase1;
}
}
Future<void> login({
String username = user1Name,
String password = user1Pw,
}) async {
await waitFor('Sign in');
await tapOn('Sign in');
await enterText(TextField, 'http://$homeserver', index: 0);
await tapOn(RadioListTile<PublicHomeserverData>, index: 0);
await tapOn('Continue');
await waitFor('Log in to http://$homeserver');
await enterText(TextField, username, index: 0);
await enterText(TextField, password, index: 1);
await tapOn('Login');
}
Future<void> logout() async {
await ensureLoggedIn();
await tapOn(Key('accounts_and_settings_buttons'));
await tapOn('Settings');
await scrollUntilVisible('Logout');
await tapOn('Logout');
await tapOn(Key('ok_cancel_alert_dialog_ok_button'));
await waitFor('Sign in');
}
Future<void> skipNoNotificationsDialog() async {
if (await isVisible('Push notifications not available')) {
await tapOn('Do not show again');
}
}
static final Map<String, String> userPassphrases = {};
Future<bool> ensureLoggedIn() async {
if (await isVisible('Sign in') == false) return false;
await login();
await initCryptoIdentity();
await skipNoNotificationsDialog();
return true;
}
}

View File

@@ -0,0 +1,29 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';
import '../utils/tatu_chat_tester.dart';
import 'auth_flows.dart';
import 'chat_flows.dart';
Future<void> basicMessaging(WidgetTester widgetTester) => widgetTester
.startTatuChatTest()
.then((tester) => tester._basicMessaging());
extension on TatuChatTester {
Future<void> _basicMessaging() async {
await ensureLoggedIn();
await ensureGroupChatCreated();
await tapOn(ChatFlows.groupChatName);
const testMessage = 'Hello from integration test!';
await enterText(Key('chat_input_field'), testMessage);
await tapOn(Key('send_button'));
await waitFor(testMessage);
await goBack();
}
}

View File

@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:tatchat/pages/chat_list/chat_list.dart';
import 'package:tatchat/widgets/chat_settings_popup_menu.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';
import '../utils/tatu_chat_tester.dart';
import 'auth_flows.dart';
Future<void> archiveChats(WidgetTester widgetTester) =>
widgetTester.startTatuChatTest().then((tester) => tester._archiveChats());
extension ChatFlows on TatuChatTester {
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 scrollUntilVisible('Create a group and invite users');
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(groupChatName);
await tapOn(ChatSettingsPopupMenu);
await tapOn('Leave');
await waitFor('Are you sure?');
await tapOn('Leave');
await waitFor(ChatList);
}
}

View File

@@ -0,0 +1,64 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:tatchat/widgets/adaptive_dialogs/dialog_text_field.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';
import '../data/environment_constants.dart';
import '../utils/tatu_chat_tester.dart';
import 'auth_flows.dart';
Future<void> loginAndChatBackup(WidgetTester widgetTester) => widgetTester
.startTatuChatTest()
.then((tester) => tester._loginAndChatBackup());
extension on TatuChatTester {
Future<void> _loginAndChatBackup() async {
// Set up with only recovery key:
await login();
await tapOn('Skip', pumpAndSettle: false);
await tapOn('Store in Android KeyStore');
await tapOn('Continue');
await skipNoNotificationsDialog();
await logout();
// Restore with recovery key from keystore:
await login();
await tapOn('Unlock');
await skipNoNotificationsDialog();
await logout();
// Reset with passphrase:
await login();
await waitFor('Restore Crypto Identity');
await tapOn('Reset account');
await tapOn('Reset account', index: 1);
await enterText(TextField, passphrase1, index: 0);
await enterText(TextField, passphrase1, index: 1);
await tapOn('Continue', pumpAndSettle: false);
await waitFor('Please enter your password');
await enterText(DialogTextField, user1Pw, pumpAndSettle: false);
await tapOn('Ok');
await tapOn('Continue');
AuthFlows.userPassphrases[user1Name] = passphrase1;
await logout();
// Restore with passphrase:
await ensureLoggedIn();
// Reset passphrase
await tapOn(Key('accounts_and_settings_buttons'));
await tapOn('Settings');
await tapOn('Chat backup');
await tapOn('Reset recovery key');
await enterText(TextField, passphrase1, index: 0);
await enterText(TextField, passphrase1, index: 1);
await tapOn('Continue', pumpAndSettle: false);
await waitFor('You are ready to start!');
await tapOn('Continue');
AuthFlows.userPassphrases[user1Name] = passphrase1;
}
}

View File

@@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart';
import '../data/environment_constants.dart';
import '../utils/tatu_chat_tester.dart';
import 'auth_flows.dart';
Future<void> multiAccount(WidgetTester widgetTester) => widgetTester
.startTatuChatTest()
.then((tester) => tester._multiAccountAndNotifications());
extension on TatuChatTester {
Future<void> _multiAccountAndNotifications() async {
await ensureLoggedIn();
// Login user 2
await tapOn(Key('accounts_and_settings_buttons'));
await tapOn('Add account');
await login(username: user2Name, password: user2Pw);
await initCryptoIdentity(username: user2Name);
// Logout user 2
await tapOn(Key('accounts_and_settings_buttons'));
await tapOn(user2Name);
await tapOn(Key('accounts_and_settings_buttons'));
await tapOn('Settings');
await scrollUntilVisible('Logout');
await tapOn('Logout');
await tapOn(Key('ok_cancel_alert_dialog_ok_button'));
await waitFor('One of your clients has been logged out');
}
}