diff --git a/test/app_test.dart b/integration_test/app_test.dart similarity index 100% rename from test/app_test.dart rename to integration_test/app_test.dart diff --git a/integration_test/features/provisional_history_test.dart b/integration_test/features/provisional_history_test.dart new file mode 100644 index 00000000..a95362d5 --- /dev/null +++ b/integration_test/features/provisional_history_test.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/initialization.dart'; +import 'package:hub/main.dart' as app; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:integration_test/integration_test.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + group('ProvisionalHistoryPage Integration Test', () { + setUpAll(() async => await initializeApp().then((_) async { + await StorageHelper().set(SecureStorageKey.isLogged.value, 'true'); + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true'); + await StorageHelper().set(KeychainStorageKey.devUUID.value, 'b5c3818753e76d85'); + await StorageHelper().set(KeychainStorageKey.userUUID.value, '649c45d7514a28.85876308'); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, '7'); + })); + + testWidgets('Filter Provisional History', (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + + final Finder menuButton = find.byIcon(Icons.person_search_outlined); + await tester.tap(menuButton); + await tester.pumpAndSettle(); + + final Finder filterButton = find.byIcon(Icons.filter_list); + await tester.tap(filterButton); + await tester.pumpAndSettle(); + + final Finder activeFilterOption = find.text('Active'); + await tester.tap(activeFilterOption); + await tester.pumpAndSettle(); + + final Finder applyFilterButton = find.text('Apply'); + await tester.tap(applyFilterButton); + await tester.pumpAndSettle(); + + expect(find.byType(CardItemTemplateComponentWidget), findsWidgets); + }); + }); +} diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index f781e839..06f7bf5b 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -1380,7 +1380,7 @@ class GetDadosCall { cache: false, isStreamingApi: false, alwaysAllowBody: false, - ); + ).timeout(const Duration(seconds: 30)); } bool? errorBolean(dynamic response) => castToType(getJsonField( diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart index 8ec62766..95937bac 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart @@ -11,7 +11,7 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel { Widget _historyCardMoleculeWidget(BuildContext context, dynamic historyItem) { return CardItemTemplateComponentWidget( - imagePath: _imageUrlAtomWidget(historyItem['AGP_NOME'], 'P'), + imagePath: null, labelsHashMap: _buildLabelsHashMap(context, historyItem), statusHashMap: _buildStatusHashMap(context, historyItem), onTapCardItemAction: () async {}, diff --git a/lib/pages/visits_on_the_property/model.dart b/lib/pages/visits_on_the_property/model.dart index 8a317179..357ab6dd 100644 --- a/lib/pages/visits_on_the_property/model.dart +++ b/lib/pages/visits_on_the_property/model.dart @@ -43,6 +43,11 @@ class VisitsModel extends FlutterFlowModel { return DetailsComponentWidget( buttons: [], labelsHashMap: Map.from({ + if (item['VTA_NOME'] != null && item['VTA_NOME'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Nome", + enText: "Name", + )}:': item['VTA_NOME'].toString().toUpperCase(), if (item['MOT_DESCRICAO'] != null && item['MOT_DESCRICAO'] != '') '${FFLocalizations.of(context).getVariableText( ptText: "Motivo", diff --git a/test/features/provisional_history_test.dart b/test/features/provisional_history_test.dart deleted file mode 100644 index badecc75..00000000 --- a/test/features/provisional_history_test.dart +++ /dev/null @@ -1,99 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:hub/features/history/index.dart'; -import 'package:hub/initialization.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:mockito/annotations.dart'; -import 'package:rxdart/rxdart.dart'; - -@GenerateMocks([ProvisionalHistoryPage]) -void main() { - group('ProvisionalHistoryPage Tests', () { - late BehaviorSubject> selectedTypeSubject; - setUpAll(() async => await initializeApp().then((_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'true'))); - - setUp(() { - selectedTypeSubject = BehaviorSubject.seeded({'AGP_STATUS': '.*'}); - }); - - tearDown(() { - selectedTypeSubject.close(); - }); - - testWidgets('should display the app bar with title', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp(home: ProvisionalHistoryPage())); - - expect(find.text('Provisional History'), findsOneWidget); - }); - - testWidgets('should display the filter button', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: ProvisionalHistoryPage(), - )); - - expect(find.byIcon(Icons.filter_list), findsOneWidget); - }); - - testWidgets('should display the back button', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: ProvisionalHistoryPage(), - )); - - expect(find.byIcon(Icons.keyboard_arrow_left), findsOneWidget); - }); - - testWidgets('should display no history found message when no data', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: ProvisionalHistoryPage(), - )); - - expect(find.text('No history found!'), findsOneWidget); - }); - - testWidgets('should display loading indicator when fetching data', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: ProvisionalHistoryPage(), - )); - - expect(find.byType(CircularProgressIndicator), findsOneWidget); - }); - - testWidgets('should display history items when data is available', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: ProvisionalHistoryPage(), - )); - - final historyItem = { - 'AGP_NOME': 'John Doe', - 'AGP_DT_VISITA': '2023-10-01', - 'AGP_STATUS': 'AT', - }; - - final provisionalHistoryState = tester.state(find.byType(ProvisionalHistoryPage)) as ProvisionalHistoryState; - provisionalHistoryState.wrap.add(historyItem); - provisionalHistoryState.hasData = true; - - await tester.pump(); - - expect(find.text('John Doe'), findsOneWidget); - expect(find.text('2023-10-01'), findsOneWidget); - }); - - testWidgets('should update history when filter is applied', (WidgetTester tester) async { - await tester.pumpWidget(MaterialApp( - home: ProvisionalHistoryPage(), - )); - - await tester.tap(find.byIcon(Icons.filter_list)); - await tester.pumpAndSettle(); - - await tester.tap(find.text('Active')); - await tester.tap(find.text('Apply')); - await tester.pumpAndSettle(); - - final provisionalHistoryState = tester.state(find.byType(ProvisionalHistoryPage)) as ProvisionalHistoryState; - expect(provisionalHistoryState.status, 'AT'); - }); - }); -}