diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index e242bdd3..30dd64b8 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -25,15 +25,15 @@ import 'package:hub/flutter_flow/index.dart'; import 'package:hub/initialization.dart'; import 'package:hub/main.dart'; import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart'; -import 'package:integration_test/integration_test.dart'; import 'package:material_symbols_icons/symbols.dart'; -import 'package:patrol/patrol.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; -import 'package:patrol_finders/patrol_finders.dart'; +import 'package:patrol/patrol.dart'; import 'app_test.dart'; import 'fuzzer/fuzzer.dart'; +import 'package:patrol_finders/patrol_finders.dart'; +import 'package:integration_test/integration_test.dart'; export 'package:flutter_test/flutter_test.dart'; export 'package:patrol/patrol.dart'; @@ -66,7 +66,7 @@ void main() { AuthenticationTest.signIn(); AuthenticationTest.signUp(); AuthenticationTest.signOut(); - AuthenticationTest.recovery(); + // AuthenticationTest.recovery(); ModularizationTest.switchLicense(); ModularizationTest.containLicense(); @@ -77,4 +77,5 @@ void main() { LocalsTest.setLocal(); LocalsTest.unlinkLocal(); + LocalsTest.attachLocal(); } diff --git a/integration_test/auth_test.dart b/integration_test/auth_test.dart index 0cd24882..4045cfc3 100644 --- a/integration_test/auth_test.dart +++ b/integration_test/auth_test.dart @@ -195,7 +195,28 @@ class AuthenticationTest { ); } - static void recovery() async {} + static void recovery() async { + patrol('Open url in the app', ($) async { + await _loggedWithMultiLocalsAccount(); + await $.pumpWidget(const App()); + + await $.waitUntilVisible($(MenuStaggeredView)); + + // await $.native.pressHome(); + // final String browserId = 'com.android.chrome'; + // await $.native.openApp(appId: browserId); + await $.native.openUrl(// + 'https://freaccess.com.br/freaccess/alterarSenha.php?email=freaccesshub@gmail.com&token=67939240e12c31.10412525'); + + await $.pumpAndSettle(); + Future.delayed(Duration(seconds: 3)); + await $.pump(Duration(seconds: 3)); + await $.pumpAndSettle(); + final PatrolFinder forgotPassword = + await $(#ForgotPasswordScreen).waitUntilVisible(); + expect(forgotPassword, findsOneWidget); + }); + } } Future _auth( diff --git a/integration_test/common.dart b/integration_test/common.dart index f91d2506..9de14e48 100644 --- a/integration_test/common.dart +++ b/integration_test/common.dart @@ -12,7 +12,7 @@ final _nativeAutomatorConfig = NativeAutomatorConfig( void patrol( String description, - Future Function(PatrolTester) callback, { + Future Function(PatrolIntegrationTester) callback, { bool? skip, List tags = const [], NativeAutomatorConfig? nativeAutomatorConfig, diff --git a/integration_test/locals_test.dart b/integration_test/locals_test.dart index e2e605c9..4faba845 100644 --- a/integration_test/locals_test.dart +++ b/integration_test/locals_test.dart @@ -303,73 +303,61 @@ class LocalsTest { static Future attachLocal() async { patrolWidgetTest( - 'Selecionar um local disponível com multíplos locais disponíveis', // + 'Auto-Validação de Locais com Multiplos Locais', // (PatrolTester tester) async { $ = tester; - await _loggedWithMultiLocalsAccount(); + $.tester.printToConsole('Locals Test - Vincular um local desvinculado'); + + await _loggedWithMultiLocalsAccount(false); await $.pumpWidget(const App()); - late Map credentials; - final PatrolFinder throwsException = $(''); - var name = ff.randomString(7, 7, true, true, true); - var email = '$name@example.com'; - var password = '12345678'; - credentials = { - 'nameTextFormField': name, - 'emailTextFormField': email, - 'passwordTextFormField': password - }; + final PatrolFinder bottomSheetFinder = + await $(BottomArrowLinkedLocalsComponentWidget) // + .waitUntilVisible(); + expect(bottomSheetFinder, findsOneWidget); - await $.pumpWidget(const App()); - await _navigateToSignUp($); - await _auth(credentials, $, throwsException); - credentials = { - 'emailTextFormField': email, - 'passwordTextFormField': password - }; - await _auth(credentials, $, throwsException); + await $.pump(const Duration(milliseconds: 500)); + + final PatrolFinder listViewFinder = $(bottomSheetFinder) // + .$(ListView); + expect(listViewFinder, findsOneWidget); + + await $.pump(const Duration(milliseconds: 500)); + + final PatrolFinder entriesFinder = $(listViewFinder) // + .$(CardItemTemplateComponentWidget); + expect(entriesFinder, findsWidgets); - await $.pumpAndSettle(); - await StorageHelper() // - .set(ProfileStorageKey.clientUUID.key, '7'); - await $.pumpAndSettle(); await Future.delayed(const Duration(milliseconds: 500)); - return; }, ); patrolWidgetTest( - 'Selecionar um local disponível com somente um local disponível', // + 'Auto-Validação de Locais com local unico', // (PatrolTester tester) async { $ = tester; - await _loggedWithSomeoneLocalAccount(); + $.tester.printToConsole('Locals Test - Vincular um local desvinculado'); + + await _loggedWithSomeoneLocalAccount(false); await $.pumpWidget(const App()); - late Map credentials; - final PatrolFinder throwsException = $(''); - var name = ff.randomString(7, 7, true, true, true); - var email = '$name@example.com'; - var password = '12345678'; - credentials = { - 'nameTextFormField': name, - 'emailTextFormField': email, - 'passwordTextFormField': password - }; + final PatrolFinder bottomSheetFinder = + await $(BottomArrowLinkedLocalsComponentWidget) // + .waitUntilVisible(); + expect(bottomSheetFinder, findsOneWidget); - await $.pumpWidget(const App()); - await _navigateToSignUp($); - await _auth(credentials, $, throwsException); - credentials = { - 'emailTextFormField': email, - 'passwordTextFormField': password - }; - await _auth(credentials, $, throwsException); + await $.pump(const Duration(milliseconds: 500)); + + final PatrolFinder listViewFinder = $(bottomSheetFinder) // + .$(ListView); + expect(listViewFinder, findsOneWidget); + + await $.pump(const Duration(milliseconds: 500)); + + final PatrolFinder entriesFinder = $(listViewFinder) // + .$(CardItemTemplateComponentWidget); + expect(entriesFinder, findsWidgets); - await $.pumpAndSettle(); - await StorageHelper() // - .set(ProfileStorageKey.clientUUID.key, '7'); - await $.pumpAndSettle(); await Future.delayed(const Duration(milliseconds: 500)); - return; }, ); } diff --git a/lib/features/local/data/data_sources/locals_remote_data_source.dart b/lib/features/local/data/data_sources/locals_remote_data_source.dart index fd91b648..a40883cf 100644 --- a/lib/features/local/data/data_sources/locals_remote_data_source.dart +++ b/lib/features/local/data/data_sources/locals_remote_data_source.dart @@ -151,11 +151,13 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @override Future checkLocals(BuildContext context) async { - String cliUUID = - (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; - String cliName = - (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; - return cliUUID.isEmpty && cliName.isEmpty; + final String? cliUUID = + await StorageHelper().get(ProfileStorageKey.clientUUID.key); + final String? cliName = + await StorageHelper().get(ProfileStorageKey.clientName.key); + final haveCli = cliUUID != null && cliUUID.isNotEmpty; + final haveName = cliName != null && cliName.isNotEmpty; + return haveCli && haveName; } @override diff --git a/lib/features/local/data/repositories/locals_repository_impl.dart b/lib/features/local/data/repositories/locals_repository_impl.dart index 232e511e..d171256e 100644 --- a/lib/features/local/data/repositories/locals_repository_impl.dart +++ b/lib/features/local/data/repositories/locals_repository_impl.dart @@ -56,6 +56,7 @@ class LocalsRepositoryImpl implements LocalsRepository { final bool haveCli = cliUUID != null && cliUUID.isNotEmpty; final bool haveOwner = ownerUUID != null && ownerUUID.isNotEmpty; if (!haveCli && !haveOwner) { + log('No client or owner selected'); await update(context); await FirebaseMessagingService().updateDeviceToken(); } @@ -64,7 +65,8 @@ class LocalsRepositoryImpl implements LocalsRepository { Future _handleLocal(BuildContext context) async { bool response = false; final bool isUnselected = await remoteDataSource.checkLocals(context); - if (isUnselected) { + if (!isUnselected) { + log('_handleLocal -> No local selected'); while (!response) { try { response = await remoteDataSource.processLocals(context); @@ -77,6 +79,8 @@ class LocalsRepositoryImpl implements LocalsRepository { } } } else { + log('_handleLocal -> Local selected'); + return true; }