-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
266cecf
commit 4e574a4
Showing
1 changed file
with
13 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,28 @@ | ||
// test/widget_test.dart | ||
|
||
import 'package:WorkoutAI/models/exercise_completion_model.dart'; | ||
import 'package:WorkoutAI/models/exercise_stats_model.dart'; | ||
import 'package:WorkoutAI/models/push_up_model.dart'; | ||
import 'package:WorkoutAI/models/sit_up_model.dart'; | ||
import 'package:WorkoutAI/models/user_manager.dart'; | ||
import 'package:WorkoutAI/models/weight_manager.dart'; | ||
import 'package:WorkoutAI/main.dart'; | ||
import 'package:WorkoutAI/views/auth/login_screen.dart'; | ||
import 'package:WorkoutAI/views/splash_screen.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:WorkoutAI/main.dart'; | ||
import 'package:WorkoutAI/models/auth_state.dart'; | ||
import 'package:WorkoutAI/services/auth_service.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('App initialization test', (WidgetTester tester) async { | ||
// Initialize auth service | ||
final authService = AuthService(); | ||
final isAuthenticated = await authService.initializeAuth(); | ||
|
||
// Build app with authentication state | ||
await tester.pumpWidget(MyApp(isAuthenticated: isAuthenticated)); | ||
await tester.pumpWidget(const MyApp(isAuthenticated: false)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify basic app structure | ||
expect(find.byType(MaterialApp), findsOneWidget); | ||
expect(find.byType(MultiBlocProvider), findsOneWidget); | ||
expect(find.byType(AppWithAuth), findsOneWidget); | ||
|
||
// Verify bloc providers are initialized | ||
final context = tester.element(find.byType(AppWithAuth)); | ||
expect(context.read<AuthCubit>(), isNotNull); | ||
expect(context.read<UserManager>(), isNotNull); | ||
expect(context.read<WeightManager>(), isNotNull); | ||
expect(context.read<PushUpCounter>(), isNotNull); | ||
expect(context.read<SitUpCounter>(), isNotNull); | ||
expect(context.read<ExerciseCompletion>(), isNotNull); | ||
expect(context.read<ExerciseStatsModel>(), isNotNull); | ||
// Verify initial route shows login screen when not authenticated | ||
expect(find.byType(LoginScreen), findsOneWidget); | ||
}); | ||
|
||
testWidgets('App shows LoginScreen when unauthenticated', | ||
(WidgetTester tester) async { | ||
await tester.pumpWidget(const MyApp(isAuthenticated: false)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify initial route based on auth state | ||
final authState = context.read<AuthCubit>().state; | ||
if (authState.status == AuthStatus.authenticated) { | ||
expect(find.byType(SplashScreen), findsOneWidget); | ||
} else { | ||
expect(find.byType(LoginScreen), findsOneWidget); | ||
} | ||
expect(find.byType(LoginScreen), findsOneWidget); | ||
}); | ||
} |