2022-05-25 15:53:49 +02:00
|
|
|
import 'dart:developer';
|
|
|
|
|
2022-04-17 08:58:52 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/main.dart' as app;
|
|
|
|
|
2022-05-25 15:53:49 +02:00
|
|
|
import 'users.dart';
|
|
|
|
|
2022-04-17 08:58:52 +02:00
|
|
|
void main() {
|
|
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
group('Integration Test', () {
|
|
|
|
testWidgets('Test if the app starts', (WidgetTester tester) async {
|
|
|
|
app.main();
|
|
|
|
await tester.pumpAndSettle();
|
2022-05-25 15:53:49 +02:00
|
|
|
|
|
|
|
await Future.delayed(const Duration(seconds: 10));
|
|
|
|
|
2022-04-17 08:58:52 +02:00
|
|
|
await tester.pumpAndSettle();
|
2022-05-25 15:53:49 +02:00
|
|
|
|
|
|
|
expect(find.text('Connect'), 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);
|
2022-04-17 08:58:52 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|