mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 03:05:14 +00:00
feat: include Synapse into integration test
Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
parent
a9c68c9384
commit
50bdb6a646
11 changed files with 2893 additions and 4 deletions
|
@ -34,12 +34,34 @@ test:
|
||||||
integration_test:
|
integration_test:
|
||||||
image: registry.gitlab.com/famedly/company/frontend/flutter-dockerimages/integration/stable:${FLUTTER_VERSION}
|
image: registry.gitlab.com/famedly/company/frontend/flutter-dockerimages/integration/stable:${FLUTTER_VERSION}
|
||||||
stage: coverage
|
stage: coverage
|
||||||
|
services:
|
||||||
|
- name: docker:dind
|
||||||
|
alias: docker
|
||||||
|
variables:
|
||||||
|
# activate container-to-container networking
|
||||||
|
FF_NETWORK_PER_BUILD: "true"
|
||||||
|
# Tell docker CLI how to talk to Docker daemon.
|
||||||
|
DOCKER_HOST: tcp://docker:2375/
|
||||||
|
# Use the overlayfs driver for improved performance.
|
||||||
|
DOCKER_DRIVER: overlay2
|
||||||
|
# Disable TLS since we're running inside local network.
|
||||||
|
DOCKER_TLS_CERTDIR: ""
|
||||||
before_script:
|
before_script:
|
||||||
- chmod 777 -R /dev/kvm
|
- chmod 777 -R /dev/kvm
|
||||||
- adb start-server
|
- adb start-server
|
||||||
- emulator -avd test -no-audio -no-boot-anim -no-window -accel on -gpu swiftshader_indirect &
|
- emulator -avd test -no-audio -no-boot-anim -no-window -accel on -gpu swiftshader_indirect &
|
||||||
- sleep 10
|
- apk update && apk add docker drill grep
|
||||||
|
- chown -R 991:991 integration_test/synapse
|
||||||
|
- docker run -d --name synapse --user 991:991 --network=host --volume="$(pwd)/integration_test/synapse/data":/data:rw -p 8008:8008 matrixdotorg/synapse:latest
|
||||||
|
- sleep 20
|
||||||
|
# create three test user
|
||||||
|
- docker exec -i synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml --user alice --password AliceInWonderland --admin
|
||||||
|
- docker exec -i synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml --user bob --password JoWirSchaffenDas --admin
|
||||||
|
- docker exec -i synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml --user trudy --password HaveIBeenPwned --admin
|
||||||
script:
|
script:
|
||||||
|
# properly set the homeserver IP for the test
|
||||||
|
- sed -i "s/10.0.2.2/$(drill docker | grep -m 1 -P "\d+\.\d+\.\d+.\d+" | awk -F ' ' '{print $NF}')/g" integration_test/users.dart
|
||||||
|
- curl docker:8008/_matrix/static/ 2> /dev/null | grep "It works! Synapse is running"
|
||||||
- git apply ./scripts/enable-android-google-services.patch
|
- git apply ./scripts/enable-android-google-services.patch
|
||||||
- flutter pub get
|
- flutter pub get
|
||||||
- flutter test integration_test
|
- flutter test integration_test
|
||||||
|
|
1
integration_test/.gitignore
vendored
Normal file
1
integration_test/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
synapse/data/homeserver.db
|
|
@ -1,19 +1,55 @@
|
||||||
import 'package:fluffychat/pages/homeserver_picker/homeserver_picker.dart';
|
import 'dart:developer';
|
||||||
|
|
||||||
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 'package:http/http.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
import 'package:fluffychat/main.dart' as app;
|
import 'package:fluffychat/main.dart' as app;
|
||||||
|
|
||||||
|
import 'users.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
group('Integration Test', () {
|
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 {
|
testWidgets('Test if the app starts', (WidgetTester tester) async {
|
||||||
app.main();
|
app.main();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
find.byWidgetPredicate((widget) => Widget is HomeserverPicker);
|
|
||||||
|
await Future.delayed(const Duration(seconds: 10));
|
||||||
|
|
||||||
await tester.pumpAndSettle();
|
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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
2781
integration_test/synapse/data/homeserver.yaml
Normal file
2781
integration_test/synapse/data/homeserver.yaml
Normal file
File diff suppressed because it is too large
Load diff
27
integration_test/synapse/data/localhost.log.config
Normal file
27
integration_test/synapse/data/localhost.log.config
Normal 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
|
1
integration_test/synapse/data/localhost.signing.key
Normal file
1
integration_test/synapse/data/localhost.signing.key
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ed25519 a_SLrz 0Ho/81rZZve88zdRxhaXWHUT6K3OqzmP35rNMZBUr6I
|
16
integration_test/users.dart
Normal file
16
integration_test/users.dart
Normal 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';
|
|
@ -28,6 +28,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
String? error;
|
String? error;
|
||||||
List<HomeserverBenchmarkResult>? benchmarkResults;
|
List<HomeserverBenchmarkResult>? benchmarkResults;
|
||||||
bool displayServerList = false;
|
bool displayServerList = false;
|
||||||
|
|
||||||
bool get loadingHomeservers =>
|
bool get loadingHomeservers =>
|
||||||
AppConfig.allowOtherHomeservers && benchmarkResults == null;
|
AppConfig.allowOtherHomeservers && benchmarkResults == null;
|
||||||
String searchTerm = '';
|
String searchTerm = '';
|
||||||
|
|
|
@ -811,7 +811,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
|
|
|
@ -95,6 +95,7 @@ dev_dependencies:
|
||||||
flutter_native_splash: ^2.0.3+1
|
flutter_native_splash: ^2.0.3+1
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
http: ^0.13.4
|
||||||
import_sorter: ^4.6.0
|
import_sorter: ^4.6.0
|
||||||
integration_test:
|
integration_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
3
test_driver/integration_test.dart
Normal file
3
test_driver/integration_test.dart
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import 'package:integration_test/integration_test_driver.dart';
|
||||||
|
|
||||||
|
Future<void> main() => integrationDriver();
|
Loading…
Reference in a new issue