6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 406a5bd0
Changed files
comwell_key_app/lib/presentation/app/app_cubit.dart | 2 +- .../lib/presentation/app/app_event_listener.dart | 6 +++--- .../authentication_test/authentication_bloc_test.dart | 15 +++++++++------ 3 files changed, 13 insertions(+), 10 deletions(-)
Diff
diff --git a/comwell_key_app/lib/presentation/app/app_cubit.dart b/comwell_key_app/lib/presentation/app/app_cubit.dart
index 23dc1f9f..ec368dff 100644
--- a/comwell_key_app/lib/presentation/app/app_cubit.dart
+++ b/comwell_key_app/lib/presentation/app/app_cubit.dart
@@ -16,7 +16,7 @@ class AppCubit extends BaseCubit<AppState> {
void _init() {
_appLinksSubscription = AppLinks().uriLinkStream.listen((uri) async {
if (uri.isDeeplink) {
- safeEmit(state.copyWith(event: Navigate(uri)));
+ navigate(uri);
}
});
}
diff --git a/comwell_key_app/lib/presentation/app/app_event_listener.dart b/comwell_key_app/lib/presentation/app/app_event_listener.dart
index d90d5db8..83094ae8 100644
--- a/comwell_key_app/lib/presentation/app/app_event_listener.dart
+++ b/comwell_key_app/lib/presentation/app/app_event_listener.dart
@@ -36,17 +36,17 @@ class AppEventListener extends StatelessWidget {
_goToRoute(context, route);
break;
default:
- _pushRoute(context, routeWithData);
+ _pushRoute(context, uri, routeWithData);
}
}
- Future<void> _pushRoute(BuildContext context, String route) async {
+ Future<void> _pushRoute(BuildContext context, Uri uri, String route) async {
final authRepo = locator<AuthenticationRepository>();
await Future<void>.delayed(const Duration(milliseconds: 500)); // UX delay
if (authRepo.isLoggedIn) {
if (context.mounted) await context.push(route);
} else {
- final loginRoute = LoginRoute(redirectAfterLogin: route);
+ final loginRoute = LoginRoute(redirectAfterLogin: uri.toString());
if (context.mounted) loginRoute.go(context);
}
}
diff --git a/comwell_key_app/test/authentication_test/authentication_bloc_test.dart b/comwell_key_app/test/authentication_test/authentication_bloc_test.dart
index 79b3aed1..e31ac432 100644
--- a/comwell_key_app/test/authentication_test/authentication_bloc_test.dart
+++ b/comwell_key_app/test/authentication_test/authentication_bloc_test.dart
@@ -25,8 +25,8 @@ void main() {
blocTest<AuthenticationBloc, AuthenticationState>(
'emits [unauthenticated] when status is unauthenticated',
setUp: () {
- when(() => authenticationRepository.isLoggedIn()).thenAnswer(
- (_) => Future.value(false),
+ when(() => authenticationRepository.isLoggedIn).thenAnswer(
+ (_) => false,
);
},
build: buildBloc,
@@ -37,8 +37,8 @@ void main() {
blocTest<AuthenticationBloc, AuthenticationState>(
'emits [authenticated] when status is authenticated',
setUp: () {
- when(() => authenticationRepository.isLoggedIn()).thenAnswer(
- (_) => Future.value(false),
+ when(() => authenticationRepository.isLoggedIn).thenAnswer(
+ (_) => false,
);
},
build: buildBloc,
@@ -50,8 +50,11 @@ void main() {
'adds error when status stream emits an error',
setUp: () {
when(
- () => authenticationRepository.isLoggedIn(),
- ).thenAnswer((_) => Future.error(Exception()));
+ () => authenticationRepository.isLoggedIn,
+ ).thenAnswer((_) {
+ throw Exception();
+ return false;
+ });
},
build: buildBloc,
act: (bloc) => bloc.add(AuthenticationSubscriptionRequested()),