Files
unionflow-client-quarkus-pr…/unionflow-mobile-apps/test/widget_test.dart
DahoudG f89f6167cc feat(mobile): Implement Keycloak WebView authentication with HTTP callback
- Replace flutter_appauth with custom WebView implementation to resolve deep link issues
- Add KeycloakWebViewAuthService with integrated WebView for seamless authentication
- Configure Android manifest for HTTP cleartext traffic support
- Add network security config for development environment (192.168.1.11)
- Update Keycloak client to use HTTP callback endpoint (http://192.168.1.11:8080/auth/callback)
- Remove obsolete keycloak_auth_service.dart and temporary scripts
- Clean up dependencies and regenerate injection configuration
- Tested successfully on multiple Android devices (Xiaomi 2201116TG, SM A725F)

BREAKING CHANGE: Authentication flow now uses WebView instead of external browser
- Users will see Keycloak login page within the app instead of browser redirect
- Resolves ERR_CLEARTEXT_NOT_PERMITTED and deep link state management issues
- Maintains full OIDC compliance with PKCE flow and secure token storage

Technical improvements:
- WebView with custom navigation delegate for callback handling
- Automatic token extraction and user info parsing from JWT
- Proper error handling and user feedback
- Consistent authentication state management across app lifecycle
2025-09-15 01:44:16 +00:00

93 lines
3.1 KiB
Dart

// Tests pour l'application UnionFlow Mobile
//
// Tests de base pour vérifier le bon fonctionnement des fonctionnalités principales
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get_it/get_it.dart';
import 'package:unionflow_mobile_apps/main.dart';
import 'package:unionflow_mobile_apps/core/di/injection.dart';
import 'package:unionflow_mobile_apps/features/members/presentation/pages/membre_create_page.dart';
import 'package:unionflow_mobile_apps/shared/widgets/permission_widget.dart';
void main() {
group('UnionFlow Mobile App Tests', () {
setUpAll(() async {
// Initialiser les dépendances pour les tests
await configureDependencies();
});
tearDownAll(() {
// Nettoyer les dépendances après les tests
GetIt.instance.reset();
});
testWidgets('App should launch successfully', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const UnionFlowApp());
await tester.pumpAndSettle();
// Verify that the app launches and shows the main interface
expect(find.byType(MaterialApp), findsOneWidget);
});
testWidgets('FloatingActionButton should be present in members list', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const UnionFlowApp());
await tester.pumpAndSettle();
// Navigate to members tab if needed
// This test assumes the members page is accessible
// Look for FloatingActionButton with add icon
expect(find.byType(FloatingActionButton), findsWidgets);
expect(find.byIcon(Icons.add), findsWidgets);
});
testWidgets('PermissionFAB should handle permissions correctly', (WidgetTester tester) async {
// Test the PermissionFAB widget in isolation
bool wasPressed = false;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
floatingActionButton: PermissionFAB(
permission: () => true, // Mock permission granted
onPressed: () => wasPressed = true,
tooltip: 'Test Button',
child: const Icon(Icons.add),
),
),
),
);
// Find and tap the FAB
await tester.tap(find.byType(FloatingActionButton));
await tester.pump();
// Verify the callback was called
expect(wasPressed, isTrue);
});
testWidgets('MembreCreatePage should have required form fields', (WidgetTester tester) async {
// Test the member creation page in isolation
await tester.pumpWidget(
const MaterialApp(
home: MembreCreatePage(),
),
);
await tester.pumpAndSettle();
// Verify that essential form fields are present
expect(find.byType(TextFormField), findsWidgets);
expect(find.byType(AppBar), findsOneWidget);
// Look for key form elements
expect(find.text('Nom'), findsWidgets);
expect(find.text('Prénom'), findsWidgets);
expect(find.text('Email'), findsWidgets);
});
});
}