diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index f1caa621..30dd64b8 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -25,16 +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_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'; @@ -61,21 +60,22 @@ void main() { // setUp(() async {}); // tearDown(() async {}); - // WelcomeTest.signInToSignUp(); - // WelcomeTest.signUpToSignIn(); + WelcomeTest.signInToSignUp(); + WelcomeTest.signUpToSignIn(); - // AuthenticationTest.signIn(); - // AuthenticationTest.signUp(); - // AuthenticationTest.signOut(); - AuthenticationTest.recovery(); + AuthenticationTest.signIn(); + AuthenticationTest.signUp(); + AuthenticationTest.signOut(); + // AuthenticationTest.recovery(); - // ModularizationTest.switchLicense(); - // ModularizationTest.containLicense(); + ModularizationTest.switchLicense(); + ModularizationTest.containLicense(); - // MenuTest.navToEntries(); - // MenuTest.containEntries(); - // MenuTest.labels2AppbarConsistency(); + MenuTest.navToEntries(); + MenuTest.containEntries(); + MenuTest.labels2AppbarConsistency(); - // LocalsTest.setLocal(); - // LocalsTest.unlinkLocal(); + LocalsTest.setLocal(); + LocalsTest.unlinkLocal(); + LocalsTest.attachLocal(); } 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; }