forked from eatvio/eatvio_app
feat(tests): added 2 e2e tests
This commit is contained in:
38
integration_test/auth_screen/auth_login_test.dart
Normal file
38
integration_test/auth_screen/auth_login_test.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:eatvio_app/main.dart' as app;
|
||||
|
||||
import '../common_cases/skip_welcome_screen.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUpAll(() async {
|
||||
await AppInitializer.initialize(buildType: AppBuildType.tests);
|
||||
});
|
||||
|
||||
testWidgets('Signs in successfully with valid credentials', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const app.MyApp());
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
await skipWelcomeScreen(tester);
|
||||
final emailFieldFinder = find.byKey(AppKeys.emailTextFieldAuthScreen);
|
||||
final passwordFieldFinder = find.byKey(AppKeys.passwordTextFieldAuthScreen);
|
||||
final signInButtonFinder = find.byKey(AppKeys.signInButtonAuthScreen);
|
||||
|
||||
expect(emailFieldFinder, findsOneWidget, reason: 'Email text field should be found.');
|
||||
expect(passwordFieldFinder, findsOneWidget, reason: 'Password text field should be found.');
|
||||
expect(signInButtonFinder, findsOneWidget, reason: 'Sign In button should be found.');
|
||||
|
||||
await tester.enterText(emailFieldFinder, 'reshetnik.n+user3@gmail.com');
|
||||
await tester.enterText(passwordFieldFinder, '1234567890');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(signInButtonFinder);
|
||||
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
|
||||
expect(signInButtonFinder, findsNothing, reason: 'Sign-in button should not be visible after successful login and navigation.');
|
||||
});
|
||||
}
|
||||
32
integration_test/auth_screen/auth_logo_button_test.dart
Normal file
32
integration_test/auth_screen/auth_logo_button_test.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:eatvio_app/core/app_initializer.dart';
|
||||
import 'package:eatvio_app/features/dev_tools/presentation/dev_tools_screen.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:eatvio_app/main.dart' as app;
|
||||
|
||||
import '../common_cases/skip_welcome_screen.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUpAll(() async {
|
||||
await AppInitializer.initialize(buildType: AppBuildType.tests);
|
||||
});
|
||||
|
||||
testWidgets('tapping logo 7 times opens dev tools', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const app.MyApp());
|
||||
await tester.pumpAndSettle(const Duration(seconds: 3));
|
||||
await skipWelcomeScreen(tester);
|
||||
final logoButtonFinder = find.byKey(AppKeys.hiddenLogoButtonAuthScreen);
|
||||
expect(logoButtonFinder, findsOneWidget, reason: 'The logo GestureDetector should be found in auth screen');
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
await tester.tap(logoButtonFinder);
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(DevToolsScreen), findsOneWidget, reason: 'DevToolsScreen should be visible after tapping the logo 7 times.');
|
||||
});
|
||||
}
|
||||
8
integration_test/common_cases/skip_welcome_screen.dart
Normal file
8
integration_test/common_cases/skip_welcome_screen.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
import 'package:eatvio_app/app_keys.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Future<void> skipWelcomeScreen(WidgetTester tester) async {
|
||||
final welcomeScreenButtonFinder = find.byKey(AppKeys.welcomeScreenButton);
|
||||
await tester.tap(welcomeScreenButtonFinder);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
Reference in New Issue
Block a user