49 lines
1.4 KiB
Dart
49 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hub/main.dart';
|
|
import 'package:integration_test/integration_test.dart';
|
|
|
|
void main() {
|
|
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
group('Authentication Tests', () {
|
|
setUp(() async {
|
|
await initializeApp();
|
|
});
|
|
|
|
testWidgets('Test MyApp', (WidgetTester tester) async {
|
|
await tester.pumpWidget(const App());
|
|
await _navToSignIn(tester);
|
|
await _enterCredentialsAndSignIn(tester);
|
|
await _login(tester);
|
|
});
|
|
});
|
|
}
|
|
|
|
Future<void> _navToSignIn(WidgetTester tester) async {
|
|
final navToSignIn = find.byKey(const Key('toggleSignInPage'));
|
|
if (navToSignIn.evaluate().isNotEmpty) {
|
|
await tester.tap(navToSignIn);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
}
|
|
|
|
Future<void> _enterCredentialsAndSignIn(WidgetTester tester) async {
|
|
final emailField = find.byKey(const ValueKey('emailField'));
|
|
await tester.enterText(emailField, 'test@example.com');
|
|
await tester.pumpAndSettle();
|
|
|
|
final passwordField = find.byKey(const ValueKey('passwordField'));
|
|
await tester.enterText(passwordField, 'password123');
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
Future<void> _login(WidgetTester tester) async {
|
|
// Encontre o botão de login e clique nele
|
|
final signInButton = find.byKey(const Key('loginCallback'));
|
|
// expect(signInButton, findsOneWidget);
|
|
tester.press(signInButton);
|
|
|
|
await tester.pumpAndSettle();
|
|
}
|