diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index d3d0a9b0..4ec6aa1d 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -39,29 +39,23 @@ void main() { //init integration test IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - setUp(() {}); - tearDown(() async { - // await StorageHelper().clean(Storage.databaseStorage); - // await StorageHelper().clean(Storage.secureStorage); - // - // DatabaseService.isInitialized = false; - // await DatabaseService.instance.init(); - }); + setUp(() async {}); + tearDown(() async {}); - // WelcomeTest.signInToSignUp(); - // WelcomeTest.signUpToSignIn(); - // - // AuthenticationTest.signIn(); - // AuthenticationTest.signUp(); - // AuthenticationTest.signOut(); - // - // ModularizationTest.switchLicense(); - // ModularizationTest.containLicense(); + WelcomeTest.signInToSignUp(); + WelcomeTest.signUpToSignIn(); - // MenuTest.navToEntries(); - // MenuTest.containEntries(); + AuthenticationTest.signIn(); + AuthenticationTest.signUp(); + AuthenticationTest.signOut(); + + ModularizationTest.switchLicense(); + ModularizationTest.containLicense(); + + MenuTest.navToEntries(); + MenuTest.containEntries(); MenuTest.labels2AppbarConsistency(); - // LocalsTest.setLocal(); - // LocalsTest.unlinkLocal(); + LocalsTest.setLocal(); + LocalsTest.unlinkLocal(); } diff --git a/integration_test/locals_test.dart b/integration_test/locals_test.dart index 661c6bc1..924dbe49 100644 --- a/integration_test/locals_test.dart +++ b/integration_test/locals_test.dart @@ -8,7 +8,7 @@ class LocalsTest { $ = tester; $.tester.printToConsole('Locals Test - Selecionar um local disponível'); - await _logged(); + await _logged(false); await $.pumpWidgetAndSettle(const App()); await $.waitUntilVisible($(MenuStaggeredView)); await $.waitUntilVisible($(LocalProfileComponentWidget)); diff --git a/integration_test/menu_test.dart b/integration_test/menu_test.dart index 9966318f..a56129f5 100644 --- a/integration_test/menu_test.dart +++ b/integration_test/menu_test.dart @@ -11,8 +11,43 @@ class MenuTest { await _logged(); await $.pumpWidgetAndSettle(const App()); + await $.waitUntilVisible($(MenuStaggeredView)); - Future.delayed(const Duration(milliseconds: 500)); + await $.waitUntilVisible($(LocalProfileComponentWidget)); + + final PatrolFinder profileFinder = + await $(#AsyncLocalProfileComponentWidget_InkWell) + .waitUntilVisible(); + expect(profileFinder, findsOneWidget); + + await $(profileFinder) // + .waitUntilVisible() + .tap(); + + final PatrolFinder bottomSheetFinder = + await $(BottomArrowLinkedLocalsComponentWidget) // + .waitUntilVisible(); + expect(bottomSheetFinder, findsOneWidget); + + final PatrolFinder listViewFinder = await $(bottomSheetFinder) // + .$(ListView) + .waitUntilVisible(); + expect(listViewFinder, findsOneWidget); + + final PatrolFinder entriesFinder = await $(listViewFinder) // + .$(CardItemTemplateComponentWidget) + .waitUntilVisible(); + expect(entriesFinder, findsWidgets); + + if (entriesFinder.evaluate().isNotEmpty) { + await $(entriesFinder.first) // + .waitUntilVisible() + .tap(settlePolicy: SettlePolicy.noSettle); + // await $.pumpAndSettle(); + } + + await $.waitUntilVisible($(MenuStaggeredView)); + await $.waitUntilVisible($(LocalProfileComponentWidget)); final List routes = MenuEntry.entries .where((entry) => entry.key != 'FRE-HUB-LOGOUT') @@ -38,6 +73,12 @@ class MenuTest { if (route == '/petsPage') continue; if (route == '/fastPassPage') continue; if (route == '/reservation') continue; + if (route == '/petsOnThePropertyPage') continue; + if (route == '/registerVisitorPage') continue; + if (route == '/messageHistoryPage') continue; + if (route == '/packageOrder') continue; + if (route == '/provisionalHistoryPage') continue; + if (route == '/scheduleCompleteVisitPage') continue; ff.navigatorKey.currentContext!.go(route); diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 9073368f..f69abdee 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -332,13 +332,13 @@ class _LiberationHistoryWidgetState extends State { Future _fetchRequests() async { try { - setState(() => _loading = true); + safeSetState(() => _loading = true); var response = await PhpGroup.getLiberationsCall.call().first; final List requests = response.jsonBody['solicitacoes'] ?? []; if (requests.isNotEmpty) { - setState(() { + safeSetState(() { _requestWrap.addAll(requests); _hasData = true; _loading = false; @@ -349,7 +349,7 @@ class _LiberationHistoryWidgetState extends State { _showNoMoreDataSnackBar(context); - setState(() { + safeSetState(() { _hasData = false; _loading = false; }); @@ -359,7 +359,7 @@ class _LiberationHistoryWidgetState extends State { await DialogUtil.errorDefault(context); LogUtil.requestAPIFailed( "proccessRequest.php", "", "Consulta de Solicitações", e, s); - setState(() { + safeSetState(() { _hasData = false; _loading = false; }); diff --git a/lib/test/test.dart b/lib/test/test.dart deleted file mode 100644 index 7c24d49d..00000000 --- a/lib/test/test.dart +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -/// Flutter code sample for [PageView]. - -void main() => runApp(const PageViewExampleApp()); - -class PageViewExampleApp extends StatelessWidget { - const PageViewExampleApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar(title: const Text('PageView Sample')), - body: const PageViewExample(), - ), - ); - } -} - -class PageViewExample extends StatefulWidget { - const PageViewExample({super.key}); - - @override - State createState() => _PageViewExampleState(); -} - -class _PageViewExampleState extends State - with TickerProviderStateMixin { - late PageController _pageViewController; - late TabController _tabController; - int _currentPageIndex = 0; - - @override - void initState() { - super.initState(); - _pageViewController = PageController(); - _tabController = TabController(length: 3, vsync: this); - } - - @override - void dispose() { - super.dispose(); - _pageViewController.dispose(); - _tabController.dispose(); - } - - @override - Widget build(BuildContext context) { - final TextTheme textTheme = Theme.of(context).textTheme; - - return Stack( - alignment: Alignment.bottomCenter, - children: [ - PageView( - /// [PageView.scrollDirection] defaults to [Axis.horizontal]. - /// Use [Axis.vertical] to scroll vertically. - controller: _pageViewController, - onPageChanged: _handlePageViewChanged, - children: [ - Center(child: Text('First Page', style: textTheme.titleLarge)), - Center(child: Text('Second Page', style: textTheme.titleLarge)), - Center(child: Text('Third Page', style: textTheme.titleLarge)), - ], - ), - PageIndicator( - tabController: _tabController, - currentPageIndex: _currentPageIndex, - onUpdateCurrentPageIndex: _updateCurrentPageIndex, - isOnDesktopAndWeb: _isOnDesktopAndWeb, - ), - ], - ); - } - - void _handlePageViewChanged(int currentPageIndex) { - if (!_isOnDesktopAndWeb) { - return; - } - _tabController.index = currentPageIndex; - setState(() { - _currentPageIndex = currentPageIndex; - }); - } - - void _updateCurrentPageIndex(int index) { - _tabController.index = index; - _pageViewController.animateToPage( - index, - duration: const Duration(milliseconds: 400), - curve: Curves.easeInOut, - ); - } - - bool get _isOnDesktopAndWeb => - kIsWeb || - switch (defaultTargetPlatform) { - TargetPlatform.macOS || - TargetPlatform.linux || - TargetPlatform.windows => - true, - TargetPlatform.android || - TargetPlatform.iOS || - TargetPlatform.fuchsia => - false, - }; -} - -/// Page indicator for desktop and web platforms. -/// -/// On Desktop and Web, drag gesture for horizontal scrolling in a PageView is disabled by default. -/// You can defined a custom scroll behavior to activate drag gestures, -/// see https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag. -/// -/// In this sample, we use a TabPageSelector to navigate between pages, -/// in order to build natural behavior similar to other desktop applications. -class PageIndicator extends StatelessWidget { - const PageIndicator({ - super.key, - required this.tabController, - required this.currentPageIndex, - required this.onUpdateCurrentPageIndex, - required this.isOnDesktopAndWeb, - }); - - final int currentPageIndex; - final TabController tabController; - final void Function(int) onUpdateCurrentPageIndex; - final bool isOnDesktopAndWeb; - - @override - Widget build(BuildContext context) { - if (!isOnDesktopAndWeb) { - return const SizedBox.shrink(); - } - final ColorScheme colorScheme = Theme.of(context).colorScheme; - - return Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - IconButton( - splashRadius: 16.0, - padding: EdgeInsets.zero, - onPressed: () { - if (currentPageIndex == 0) { - return; - } - onUpdateCurrentPageIndex(currentPageIndex - 1); - }, - icon: const Icon(Icons.arrow_left_rounded, size: 32.0), - ), - TabPageSelector( - controller: tabController, - color: colorScheme.surface, - selectedColor: colorScheme.primary, - ), - IconButton( - splashRadius: 16.0, - padding: EdgeInsets.zero, - onPressed: () { - if (currentPageIndex == 2) { - return; - } - onUpdateCurrentPageIndex(currentPageIndex + 1); - }, - icon: const Icon(Icons.arrow_right_rounded, size: 32.0), - ), - ], - ), - ); - } -}