games_app/prediqo_mobile/integration_test/app_e2e_test.dart
2026-07-25 22:48:54 +02:00

99 lines
3.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:prediqo_mobile/app.dart';
import 'package:prediqo_mobile/core/config/app_config.dart';
import 'package:prediqo_mobile/core/di/injection.dart';
import '../test/support/e2e_fixtures.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('Prediqo mobile E2E', () {
tearDown(() async {
if (sl.isRegistered<AppConfig>()) {
await sl.reset();
}
});
testWidgets('unauthenticated user sees public welcome after splash', (tester) async {
await setupE2eDependencies(loggedIn: false);
await tester.pumpWidget(const PrediqoApp());
await e2ePumpPastSplash(tester);
expect(find.byKey(const Key('welcome_screen')), findsOneWidget);
expect(find.byKey(const Key('welcome_get_started')), findsOneWidget);
expect(find.byKey(const Key('login_screen')), findsNothing);
});
testWidgets('login flow reaches dashboard', (tester) async {
await setupE2eDependencies(loggedIn: false);
await tester.pumpWidget(const PrediqoApp());
await e2ePumpPastSplash(tester);
await tester.tap(find.byKey(const Key('welcome_get_started')));
await e2ePump(tester, frames: 5);
await tester.enterText(find.byKey(const Key('login_email')), 'e2e@prediqo.test');
await tester.enterText(find.byKey(const Key('login_password')), 'password123');
await tester.tap(find.byKey(const Key('login_submit')));
await e2ePump(tester, frames: 8);
expect(find.byKey(const Key('nav_home')), findsOneWidget);
expect(find.byKey(const Key('login_screen')), findsNothing);
});
testWidgets('authenticated user navigates predict catalog and wallet tabs', (tester) async {
await setupE2eDependencies(loggedIn: true);
await tester.pumpWidget(const PrediqoApp());
await e2ePumpPastSplash(tester);
await tester.tap(find.byKey(const Key('nav_predict')));
await e2ePump(tester, frames: 20);
expect(find.byKey(const Key('prediction_games_screen')), findsOneWidget);
expect(find.byKey(const Key('game_card_candle-predict')), findsOneWidget);
await tester.tap(find.byKey(const Key('nav_wallet')));
await e2ePump(tester, frames: 5);
expect(find.text('Wallet'), findsWidgets);
await tester.tap(find.byKey(const Key('nav_profile')));
await e2ePump(tester, frames: 5);
expect(find.text('Account'), findsOneWidget);
});
testWidgets('forgot password link opens reset screen', (tester) async {
await setupE2eDependencies(loggedIn: false);
await tester.pumpWidget(const PrediqoApp());
await e2ePumpPastSplash(tester);
await tester.tap(find.byKey(const Key('welcome_get_started')));
await e2ePump(tester, frames: 5);
await tester.tap(find.byKey(const Key('forgot_password_link')));
await e2ePump(tester, frames: 5);
expect(find.text('Forgot password?'), findsWidgets);
expect(find.text('Send reset link'), findsOneWidget);
});
testWidgets('prediction screen shows single and multi mode controls', (tester) async {
await setupE2eDependencies(loggedIn: true);
await tester.pumpWidget(const PrediqoApp());
await e2ePumpPastSplash(tester);
await tester.tap(find.byKey(const Key('nav_predict')));
await e2ePump(tester, frames: 20);
await tester.tap(find.byKey(const Key('game_card_candle-predict')));
await e2ePump(tester, frames: 20);
expect(find.text('Single'), findsOneWidget);
expect(find.text('Multi'), findsOneWidget);
expect(find.text('Auto'), findsOneWidget);
expect(find.text('Long'), findsOneWidget);
expect(find.text('Short'), findsOneWidget);
});
});
}