92 lines
3.0 KiB
Dart
92 lines
3.0 KiB
Dart
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);
|
|
});
|
|
});
|
|
}
|