feat: include Synapse into integration test

Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
TheOneWithTheBraid 2022-05-25 15:53:49 +02:00
commit 50bdb6a646
11 changed files with 2893 additions and 4 deletions

1
integration_test/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
synapse/data/homeserver.db

View file

@ -1,19 +1,55 @@
import 'package:fluffychat/pages/homeserver_picker/homeserver_picker.dart';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart';
import 'package:integration_test/integration_test.dart';
import 'package:fluffychat/main.dart' as app;
import 'users.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('Integration Test', () {
test('Check server availability', () async {
final response = await get(Uri.parse('$homeserver/_matrix/static/'));
expect(response.statusCode, 200);
}, timeout: const Timeout(Duration(seconds: 10)));
testWidgets('Test if the app starts', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
find.byWidgetPredicate((widget) => Widget is HomeserverPicker);
await Future.delayed(const Duration(seconds: 10));
await tester.pumpAndSettle();
expect(find.text('Connect'), findsOneWidget);
expect(find.text('Homeserver'), findsOneWidget);
final input = find.byType(TextField);
expect(input, findsOneWidget);
await tester.enterText(input, homeserver);
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();
// in case registration is allowed
try {
await tester.tap(find.text('Login'));
await tester.pumpAndSettle();
} catch (e) {
log('Registration is not allowed. Proceeding with login...');
}
await tester.pumpAndSettle();
final inputs = find.byType(TextField);
await tester.enterText(inputs.first, Users.alice.name);
await tester.enterText(inputs.last, Users.alice.password);
await tester.testTextInput.receiveAction(TextInputAction.done);
});
});
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,27 @@
version: 1
formatters:
precise:
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
handlers:
console:
class: logging.StreamHandler
formatter: precise
loggers:
synapse.storage.SQL:
# beware: increasing this to DEBUG will make synapse log sensitive
# information such as access tokens.
level: INFO
root:
level: INFO
handlers: [console]
disable_existing_loggers: false

View file

@ -0,0 +1 @@
ed25519 a_SLrz 0Ho/81rZZve88zdRxhaXWHUT6K3OqzmP35rNMZBUr6I

View file

@ -0,0 +1,16 @@
abstract class Users {
const Users._();
static const alice = User('alice', 'AliceInWonderland');
static const bob = User('bob', 'JoWirSchaffenDas');
static const trudy = User('trudy', 'HaveIBeenPwned');
}
class User {
final String name;
final String password;
const User(this.name, this.password);
}
// https://stackoverflow.com/a/33088657
const homeserver = 'http://10.0.2.2:8008';