2023-06-23 12:12:02 +02:00
|
|
|
import 'package:cpd_ss23/jobs/jobs_screen.dart';
|
|
|
|
import 'package:cpd_ss23/login_page/login_screen.dart';
|
2023-06-25 23:17:47 +02:00
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
2023-05-31 20:04:38 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
2023-06-25 23:17:47 +02:00
|
|
|
|
2023-06-23 12:12:02 +02:00
|
|
|
import './mock.dart';
|
2023-05-31 20:04:38 +02:00
|
|
|
|
|
|
|
void main() {
|
2023-06-23 12:12:02 +02:00
|
|
|
setupFirebaseAuthMocks();
|
|
|
|
|
|
|
|
setUpAll(() async {
|
|
|
|
await Firebase.initializeApp();
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('Firebase Initialization Test', (WidgetTester tester) async {
|
|
|
|
// Initialize Firebase
|
|
|
|
|
|
|
|
// Check if Firebase is initialized
|
|
|
|
final isFirebaseInitialized = Firebase.apps.isNotEmpty;
|
|
|
|
|
|
|
|
// Perform your test assertions
|
|
|
|
expect(isFirebaseInitialized, isTrue);
|
|
|
|
});
|
2023-05-31 20:04:38 +02:00
|
|
|
|
2023-06-23 12:12:02 +02:00
|
|
|
testWidgets('UserState Widget - User not logged in',
|
|
|
|
(WidgetTester tester) async {
|
2023-06-25 23:17:47 +02:00
|
|
|
await tester.pumpWidget(MaterialApp(home: Login()));
|
2023-05-31 20:04:38 +02:00
|
|
|
|
2023-06-23 12:12:02 +02:00
|
|
|
// Überprüfen, ob das Login-Widget angezeigt wird
|
|
|
|
expect(find.byType(Login), findsOneWidget);
|
2023-05-31 20:04:38 +02:00
|
|
|
|
2023-06-25 23:17:47 +02:00
|
|
|
// Überprüfen, ob das Login-Widget nicht angezeigt wird
|
2023-06-23 12:12:02 +02:00
|
|
|
expect(find.byType(JobScreen), findsNothing);
|
2023-05-31 20:04:38 +02:00
|
|
|
});
|
2023-06-25 23:17:47 +02:00
|
|
|
|
|
|
|
testWidgets('UserState Widget - User logged in', (WidgetTester tester) async {
|
|
|
|
await tester.pumpWidget(MaterialApp(home: Login()));
|
|
|
|
|
|
|
|
// Überprüfen, ob das Login-Widget angezeigt wird
|
|
|
|
expect(find.byType(Login), findsOneWidget);
|
|
|
|
|
|
|
|
// Texteingabe in die E-Mail- und Passwortfelder
|
|
|
|
final textFormFields = find.byType(TextFormField);
|
|
|
|
if (textFormFields.evaluate().isEmpty) {
|
|
|
|
fail('TextFormFields not found');
|
|
|
|
} else {
|
|
|
|
await tester.enterText(textFormFields.at(0), 'davidwinterhalter@gmx.de');
|
|
|
|
await tester.enterText(textFormFields.at(1), '123456');
|
|
|
|
|
|
|
|
// 'Login'-Button drücken
|
|
|
|
await tester.tap(find.text('Login'));
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
// Überprüfen, ob das Login-Widget nicht angezeigt wird
|
|
|
|
expect(find.byType(Login), findsNothing);
|
|
|
|
|
|
|
|
// Überprüfen, ob das JobScreen-Widget angezeigt wird
|
|
|
|
expect(find.byType(JobScreen), findsOneWidget);
|
|
|
|
}
|
|
|
|
});
|
2023-05-31 20:04:38 +02:00
|
|
|
}
|