Merge pull request #91 from FRE-Informatica/fix/fd-1131

FIX/FD-1131 - Erro na Auto-Seleção de Locais
This commit is contained in:
Ivan Antunes 2025-01-30 08:39:57 -03:00 committed by GitHub
commit beafda67cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 67 additions and 73 deletions

View File

@ -25,16 +25,15 @@ import 'package:hub/flutter_flow/index.dart';
import 'package:hub/initialization.dart'; import 'package:hub/initialization.dart';
import 'package:hub/main.dart'; import 'package:hub/main.dart';
import 'package:hub/pages/forgot_password_page/forgot_password_screen.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:material_symbols_icons/symbols.dart';
import 'package:patrol/patrol.dart';
import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:flutter_web_plugins/url_strategy.dart';
import 'package:patrol_finders/patrol_finders.dart'; import 'package:patrol/patrol.dart';
// import 'package:patrol_finders/patrol_finders.dart';
import 'app_test.dart'; import 'app_test.dart';
import 'fuzzer/fuzzer.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:flutter_test/flutter_test.dart';
export 'package:patrol/patrol.dart'; export 'package:patrol/patrol.dart';
@ -61,21 +60,22 @@ void main() {
// setUp(() async {}); // setUp(() async {});
// tearDown(() async {}); // tearDown(() async {});
// WelcomeTest.signInToSignUp(); WelcomeTest.signInToSignUp();
// WelcomeTest.signUpToSignIn(); WelcomeTest.signUpToSignIn();
// AuthenticationTest.signIn(); AuthenticationTest.signIn();
// AuthenticationTest.signUp(); AuthenticationTest.signUp();
// AuthenticationTest.signOut(); AuthenticationTest.signOut();
AuthenticationTest.recovery(); // AuthenticationTest.recovery();
// ModularizationTest.switchLicense(); ModularizationTest.switchLicense();
// ModularizationTest.containLicense(); ModularizationTest.containLicense();
// MenuTest.navToEntries(); MenuTest.navToEntries();
// MenuTest.containEntries(); MenuTest.containEntries();
// MenuTest.labels2AppbarConsistency(); MenuTest.labels2AppbarConsistency();
// LocalsTest.setLocal(); LocalsTest.setLocal();
// LocalsTest.unlinkLocal(); LocalsTest.unlinkLocal();
LocalsTest.attachLocal();
} }

View File

@ -303,73 +303,61 @@ class LocalsTest {
static Future attachLocal() async { static Future attachLocal() async {
patrolWidgetTest( patrolWidgetTest(
'Selecionar um local disponível com multíplos locais disponíveis', // 'Auto-Validação de Locais com Multiplos Locais', //
(PatrolTester tester) async { (PatrolTester tester) async {
$ = tester; $ = tester;
await _loggedWithMultiLocalsAccount(); $.tester.printToConsole('Locals Test - Vincular um local desvinculado');
await _loggedWithMultiLocalsAccount(false);
await $.pumpWidget(const App()); await $.pumpWidget(const App());
late Map<String, String> credentials;
final PatrolFinder throwsException = $('');
var name = ff.randomString(7, 7, true, true, true); final PatrolFinder bottomSheetFinder =
var email = '$name@example.com'; await $(BottomArrowLinkedLocalsComponentWidget) //
var password = '12345678'; .waitUntilVisible();
credentials = { expect(bottomSheetFinder, findsOneWidget);
'nameTextFormField': name,
'emailTextFormField': email,
'passwordTextFormField': password
};
await $.pumpWidget(const App()); await $.pump(const Duration(milliseconds: 500));
await _navigateToSignUp($);
await _auth(credentials, $, throwsException); final PatrolFinder listViewFinder = $(bottomSheetFinder) //
credentials = { .$(ListView);
'emailTextFormField': email, expect(listViewFinder, findsOneWidget);
'passwordTextFormField': password
}; await $.pump(const Duration(milliseconds: 500));
await _auth(credentials, $, throwsException);
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)); await Future.delayed(const Duration(milliseconds: 500));
return;
}, },
); );
patrolWidgetTest( patrolWidgetTest(
'Selecionar um local disponível com somente um local disponível', // 'Auto-Validação de Locais com local unico', //
(PatrolTester tester) async { (PatrolTester tester) async {
$ = tester; $ = tester;
await _loggedWithSomeoneLocalAccount(); $.tester.printToConsole('Locals Test - Vincular um local desvinculado');
await _loggedWithSomeoneLocalAccount(false);
await $.pumpWidget(const App()); await $.pumpWidget(const App());
late Map<String, String> credentials;
final PatrolFinder throwsException = $('');
var name = ff.randomString(7, 7, true, true, true); final PatrolFinder bottomSheetFinder =
var email = '$name@example.com'; await $(BottomArrowLinkedLocalsComponentWidget) //
var password = '12345678'; .waitUntilVisible();
credentials = { expect(bottomSheetFinder, findsOneWidget);
'nameTextFormField': name,
'emailTextFormField': email,
'passwordTextFormField': password
};
await $.pumpWidget(const App()); await $.pump(const Duration(milliseconds: 500));
await _navigateToSignUp($);
await _auth(credentials, $, throwsException); final PatrolFinder listViewFinder = $(bottomSheetFinder) //
credentials = { .$(ListView);
'emailTextFormField': email, expect(listViewFinder, findsOneWidget);
'passwordTextFormField': password
}; await $.pump(const Duration(milliseconds: 500));
await _auth(credentials, $, throwsException);
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)); await Future.delayed(const Duration(milliseconds: 500));
return;
}, },
); );
} }

View File

@ -151,11 +151,13 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource {
@override @override
Future<bool> checkLocals(BuildContext context) async { Future<bool> checkLocals(BuildContext context) async {
String cliUUID = final String? cliUUID =
(await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; await StorageHelper().get(ProfileStorageKey.clientUUID.key);
String cliName = final String? cliName =
(await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; await StorageHelper().get(ProfileStorageKey.clientName.key);
return cliUUID.isEmpty && cliName.isEmpty; final haveCli = cliUUID != null && cliUUID.isNotEmpty;
final haveName = cliName != null && cliName.isNotEmpty;
return haveCli && haveName;
} }
@override @override

View File

@ -56,6 +56,7 @@ class LocalsRepositoryImpl implements LocalsRepository {
final bool haveCli = cliUUID != null && cliUUID.isNotEmpty; final bool haveCli = cliUUID != null && cliUUID.isNotEmpty;
final bool haveOwner = ownerUUID != null && ownerUUID.isNotEmpty; final bool haveOwner = ownerUUID != null && ownerUUID.isNotEmpty;
if (!haveCli && !haveOwner) { if (!haveCli && !haveOwner) {
log('No client or owner selected');
await update(context); await update(context);
await FirebaseMessagingService().updateDeviceToken(); await FirebaseMessagingService().updateDeviceToken();
} }
@ -64,7 +65,8 @@ class LocalsRepositoryImpl implements LocalsRepository {
Future<bool> _handleLocal(BuildContext context) async { Future<bool> _handleLocal(BuildContext context) async {
bool response = false; bool response = false;
final bool isUnselected = await remoteDataSource.checkLocals(context); final bool isUnselected = await remoteDataSource.checkLocals(context);
if (isUnselected) { if (!isUnselected) {
log('_handleLocal -> No local selected');
while (!response) { while (!response) {
try { try {
response = await remoteDataSource.processLocals(context); response = await remoteDataSource.processLocals(context);
@ -77,6 +79,8 @@ class LocalsRepositoryImpl implements LocalsRepository {
} }
} }
} else { } else {
log('_handleLocal -> Local selected');
return true; return true;
} }