This commit is contained in:
2025-09-23 11:19:14 +03:30
parent ce4290dc87
commit d2c495bfb1
14 changed files with 1821 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:rasadyar_inspection/presentation/pages/auth/view.dart';
import 'package:rasadyar_inspection/presentation/pages/auth/logic.dart';
import 'package:rasadyar_core/core.dart';
class MockAuthLogic extends GetxController with Mock implements AuthLogic {}
class MockTokenStorageService extends Mock implements TokenStorageService {}
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('Inspection Module Integration Tests', () {
late MockAuthLogic mockAuthLogic;
late MockTokenStorageService mockTokenService;
setUp(() {
mockAuthLogic = MockAuthLogic();
mockTokenService = MockTokenStorageService();
// Setup mock behaviors
mockAuthLogic.textAnimation = AlwaysStoppedAnimation(1.0);
mockAuthLogic.isLoading = false.obs;
mockAuthLogic.usernameController = TextEditingController().obs;
mockAuthLogic.passwordController = TextEditingController().obs;
Get.put<AuthLogic>(mockAuthLogic);
Get.put<TokenStorageService>(mockTokenService);
});
tearDown(() {
Get.reset();
});
testWidgets('should complete authentication flow', (WidgetTester tester) async {
// Act
await tester.pumpWidget(
MaterialApp(
home: AuthPage(),
),
);
// Assert - Verify auth page loads correctly
expect(find.text('به سامانه رصدیار خوش آمدید!'), findsOneWidget);
expect(find.text('سامانه رصد و پایش زنجیره تامین، تولید و توزیع کالا های اساسی'), findsOneWidget);
// Test page navigation and UI interactions
await tester.pumpAndSettle();
expect(find.byType(Scaffold), findsOneWidget);
expect(find.byType(FadeTransition), findsOneWidget);
});
testWidgets('should handle back navigation correctly', (WidgetTester tester) async {
// Act
await tester.pumpWidget(
MaterialApp(
home: AuthPage(),
),
);
// Verify PopScope behavior
final popScope = tester.widget<PopScope>(find.byType(PopScope));
expect(popScope.canPop, false);
// Test that back button handling works
await tester.pump();
expect(find.byType(AuthPage), findsOneWidget);
});
testWidgets('should display welcome animation correctly', (WidgetTester tester) async {
// Act
await tester.pumpWidget(
MaterialApp(
home: AuthPage(),
),
);
// Assert - Check animation components
expect(find.byType(FadeTransition), findsOneWidget);
expect(find.byType(Column), findsOneWidget);
// Verify text styling
final welcomeText = tester.widget<Text>(
find.text('به سامانه رصدیار خوش آمدید!')
);
expect(welcomeText.style?.color, Colors.white);
});
});
}