From 3115fb2e1ba79691194eb0d3392f011ab21b3d98 Mon Sep 17 00:00:00 2001 From: Arnau Date: Thu, 25 Jan 2024 14:47:39 +0100 Subject: [PATCH 1/6] fix: make tests pass --- lib/ui/router/app_router.dart | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/ui/router/app_router.dart b/lib/ui/router/app_router.dart index 0aa8021..6941357 100644 --- a/lib/ui/router/app_router.dart +++ b/lib/ui/router/app_router.dart @@ -54,19 +54,27 @@ final GoRouter router = GoRouter( ), GoRoute( path: '/forgot-password/confirm', - pageBuilder: (context, state) => platformPage( - ForgotPasswordConfirmPage( - data: state.extra as ForgotPasswordConfirmPageData, - ), - fullscreenDialog: true, - ), + pageBuilder: (context, state) { + final data = state.extra; + return platformPage( + data is ForgotPasswordConfirmPageData + ? ForgotPasswordConfirmPage(data: data) + : const SizedBox(), + fullscreenDialog: true, + ); + }, ), GoRoute( path: '/change-password', - pageBuilder: (context, GoRouterState state) => platformPage( - ChangePasswordPage(data: state.extra as ChangePasswordPageData), - fullscreenDialog: true, - ), + pageBuilder: (context, GoRouterState state) { + final data = state.extra; + return platformPage( + data is ChangePasswordPageData + ? ChangePasswordPage(data: data) + : const SizedBox(), + fullscreenDialog: true, + ); + }, ), GoRoute( path: '/change-password/success', From 5d91c13dfded18aab9609bbee1a38f09ef75e1c2 Mon Sep 17 00:00:00 2001 From: Arnau Date: Thu, 25 Jan 2024 14:56:56 +0100 Subject: [PATCH 2/6] chore: format --- lib/ui/features/misc/components/scaffold_with_navigation.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ui/features/misc/components/scaffold_with_navigation.dart b/lib/ui/features/misc/components/scaffold_with_navigation.dart index bde1bee..dba83c9 100644 --- a/lib/ui/features/misc/components/scaffold_with_navigation.dart +++ b/lib/ui/features/misc/components/scaffold_with_navigation.dart @@ -55,6 +55,7 @@ class ScaffoldWithNavigation extends StatelessWidget { initialLocation: index == navigationShell.currentIndex, ); } + @override Widget build(BuildContext context) { return SizedBox.expand( From c92fce13b49c0eeefacfcc18b6f13b8adba3988f Mon Sep 17 00:00:00 2001 From: Arnau Date: Thu, 25 Jan 2024 15:11:47 +0100 Subject: [PATCH 3/6] feat: make all tests pass --- test/ui/features/auth/change_password/change_password_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/test/ui/features/auth/change_password/change_password_test.dart b/test/ui/features/auth/change_password/change_password_test.dart index ffbacbc..adebf40 100644 --- a/test/ui/features/auth/change_password/change_password_test.dart +++ b/test/ui/features/auth/change_password/change_password_test.dart @@ -59,6 +59,7 @@ void main() { '/change-password', extra: const ChangePasswordPageData(token: 'token', uid: 'uid'), ); + await tester.pumpAndSettle(); when(() => getIt().changePassword(any())) .thenAnswer((_) async {}); From 7efeadddf86690cda19176a039c1ae8c418ace9c Mon Sep 17 00:00:00 2001 From: Arnau Date: Thu, 25 Jan 2024 15:12:33 +0100 Subject: [PATCH 4/6] feat: make tests pass --- .../auth/forgot_password/forgot_password_confirm_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart b/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart index 2a2c580..8aca375 100644 --- a/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart +++ b/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart @@ -28,6 +28,7 @@ void main() { '/forgot-password/confirm', extra: ForgotPasswordConfirmPageData(email: fakeEmail), ); + tester.pumpAndSettle(); expect(find.byType(ForgotPasswordConfirmPage), findsOneWidget); final button = find.byKey(const Key('forgot-pass-confirm-button')); expectButtonEnabled(tester, button, isEnabled: false); From b5858a0ebf44eba8c1be6853175705da185f4b84 Mon Sep 17 00:00:00 2001 From: Arnau Date: Thu, 25 Jan 2024 15:21:52 +0100 Subject: [PATCH 5/6] feat: await pump and settle method --- .../auth/forgot_password/forgot_password_confirm_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart b/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart index 8aca375..39b4a2c 100644 --- a/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart +++ b/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart @@ -28,7 +28,7 @@ void main() { '/forgot-password/confirm', extra: ForgotPasswordConfirmPageData(email: fakeEmail), ); - tester.pumpAndSettle(); + await tester.pumpAndSettle(); expect(find.byType(ForgotPasswordConfirmPage), findsOneWidget); final button = find.byKey(const Key('forgot-pass-confirm-button')); expectButtonEnabled(tester, button, isEnabled: false); From 84d8d5cd9162af3886e88e1717d553744a5260ae Mon Sep 17 00:00:00 2001 From: Arnau Date: Mon, 29 Jan 2024 10:36:06 +0100 Subject: [PATCH 6/6] fix: go router error when running tests --- .../auth/forgot_password/forgot_password_confirm_test.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart b/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart index 39b4a2c..eb2bc3e 100644 --- a/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart +++ b/test/ui/features/auth/forgot_password/forgot_password_confirm_test.dart @@ -8,6 +8,7 @@ import 'package:flutter_base/ui/features/auth/views/change_password/change_passw import 'package:flutter_base/ui/features/auth/views/forgot_password/forgot_password_confirm_page.dart'; import 'package:flutter_base/ui/i18n/locale_keys.g.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:go_router/go_router.dart'; import 'package:mocktail/mocktail.dart'; import '../../../../helpers/expects.dart'; @@ -19,6 +20,9 @@ void main() { setUpAll(() { configureMockDependencies(); }); + setUp(() { + getIt().go('/home'); + }); group('Forgot Password Confirm Page Test', () { testWidgets(