6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 05c48b8d
Changed files
.../lib/authentication/authentication_repository.dart | 9 +++------ .../lib/authentication/bloc/authentication_bloc.dart | 8 -------- .../lib/booking_details/bloc/booking_details_bloc.dart | 17 +++++++++++------ comwell_key_app/lib/check_in/bloc/check_in_cubit.dart | 2 +- comwell_key_app/lib/comwell_app.dart | 7 +++---- comwell_key_app/lib/overview/cubit/overview_cubit.dart | 2 +- comwell_key_app/lib/routing/app_router.dart | 2 ++ .../lib/tracking/trackers/firebase_tracker.dart | 7 +++---- .../booking_details_test/booking_details_bloc_test.dart | 14 ++++++++++++-- 9 files changed, 36 insertions(+), 32 deletions(-)
Diff
diff --git a/comwell_key_app/lib/authentication/authentication_repository.dart b/comwell_key_app/lib/authentication/authentication_repository.dart
index f5a18089..e2fe791f 100644
--- a/comwell_key_app/lib/authentication/authentication_repository.dart
+++ b/comwell_key_app/lib/authentication/authentication_repository.dart
@@ -4,6 +4,7 @@ import 'package:comwell_key_app/authentication/enum/authentication_status.dart';
import 'package:comwell_key_app/services/api.dart';
import 'package:comwell_key_app/utils/secure_storage.dart';
import 'package:comwell_key_app/common/const.dart' as constants;
+import 'package:flutter/foundation.dart';
import '../utils/seos_repository.dart';
@@ -28,17 +29,13 @@ class AuthenticationRepository {
try {
if (status == AuthenticationStatus.authenticated) {
final isEndpointSetup = await seos.startMobilePlugin();
- if (isEndpointSetup) {
- print("qqq endpoint updated");
- } else {
+ if (!isEndpointSetup) {
final invitationCode = await api.createEndpointRegistration();
- print("qqq invitationCode=$invitationCode");
await seos.setupEndpoint(invitationCode);
- print("qqq endpoint setup");
}
}
} catch (e, st) {
- print("qqq e=$e");
+ if(kDebugMode) print("e=$e, $st");
}
}
diff --git a/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart b/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
index 6a24d1fe..20a36366 100644
--- a/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
+++ b/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
@@ -16,7 +16,6 @@ class AuthenticationBloc
required AuthenticationRepository authenticationRepository,
}) : _authenticationRepository = authenticationRepository,
super(const AuthenticationState.unknown()) {
- print("qqq AuthenticationBloc");
on<AuthenticationSubscriptionRequested>(_onSubscriptionRequested);
on<AuthenticationLogoutPressed>(_onLogoutPressed);
on<AuthenticationLoginPressed>(_onLoginPressed);
@@ -25,11 +24,6 @@ class AuthenticationBloc
final AuthenticationRepository _authenticationRepository;
- void post(){
- print("qqq add");
- add(AuthenticationSubscriptionRequested());
- }
-
void _onLogoutPressed(
AuthenticationLogoutPressed event,
Emitter<AuthenticationState> emit,
@@ -41,11 +35,9 @@ class AuthenticationBloc
AuthenticationSubscriptionRequested event,
Emitter<AuthenticationState> emit,
) {
- print("qqq _onSubscriptionRequested");
return emit.onEach(
_authenticationRepository.status.asBroadcastStream(),
onData: (status) async {
- print("qqq ondata $status");
switch (status) {
case AuthenticationStatus.unauthenticated:
await FirebaseAnalytics.instance.setUserProperty(
diff --git a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
index 199ff650..163ca79d 100644
--- a/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
+++ b/comwell_key_app/lib/booking_details/bloc/booking_details_bloc.dart
@@ -1,6 +1,6 @@
-
import 'package:bloc/bloc.dart';
import 'package:comwell_key_app/database/comwell_db.dart';
+import 'package:comwell_key_app/utils/seos_repository.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart';
import 'package:seos_mobile_keys_plugin/app_usage_api.dart';
@@ -13,15 +13,18 @@ part 'booking_details_event.dart';
part 'booking_details_state.dart';
-class BookingDetailsBloc extends Bloc<BookingDetailsEvent, BookingDetailsState> {
+class BookingDetailsBloc
+ extends Bloc<BookingDetailsEvent, BookingDetailsState> {
final Booking booking;
final BookingDetailsRepository bookingDetailsRepository;
+ final SeosRepository seosRepository;
final ComwellDatabase database = locator<ComwellDatabase>();
BookingDetailsBloc(
this.booking, {
required this.bookingDetailsRepository,
+ required this.seosRepository,
}) : super(BookingDetailsState.initial()) {
on<InitialEvent>((event, emit) async {
emit(state.setupStarted());
@@ -31,7 +34,7 @@ class BookingDetailsBloc extends Bloc<BookingDetailsEvent, BookingDetailsState>
emit(state.setupComplete());
return;
}
- final isEndPointSetup = true; //await bookingDetailsRepository.startMobilePlugin();
+ final isEndPointSetup = await seosRepository.isEndpointSetup();
if (isEndPointSetup) {
emit(state.setupComplete());
} else {
@@ -39,7 +42,7 @@ class BookingDetailsBloc extends Bloc<BookingDetailsEvent, BookingDetailsState>
SetupEndpoint();
}
} catch (e, st) {
- if (kDebugMode) print("qqq $e, $st");
+ if (kDebugMode) print("err=$e, $st");
emit(state.setupError());
}
});
@@ -66,7 +69,8 @@ class BookingDetailsBloc extends Bloc<BookingDetailsEvent, BookingDetailsState>
if (event.endpointNeedsUpdate) {
//await bookingDetailsRepository.updateEndpoint();
}
- final List<MobileKeysKey> keys = [];//await bookingDetailsRepository.refreshKeys();
+ final List<MobileKeysKey> keys =
+ []; //await bookingDetailsRepository.refreshKeys();
if (keys.length == 1) {
emit(state.validKey(keys[0]));
} else if (keys.length > 1) {
@@ -97,7 +101,8 @@ class BookingDetailsBloc extends Bloc<BookingDetailsEvent, BookingDetailsState>
Future<void> checkIfHouseKeepingOrdered(
Emitter<BookingDetailsState> emit) async {
- final isHouseKeepingOrdered = await bookingDetailsRepository.isHousesKeepingOrdered();
+ final isHouseKeepingOrdered =
+ await bookingDetailsRepository.isHousesKeepingOrdered();
if (isHouseKeepingOrdered) {
emit(state.houseKeepingOrdered());
}
diff --git a/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart b/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
index 60afb7b3..665e4851 100644
--- a/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
+++ b/comwell_key_app/lib/check_in/bloc/check_in_cubit.dart
@@ -35,7 +35,7 @@ class CheckInCubit extends Cubit<CheckInState> {
await _seosRepository.refreshKeys();
emit(state.checkInStatusYourDigitalCard(roomNumber: booking.roomNumber));
} catch (err, st) {
- print("qqq err=$err, $st");
+ print("err=$err, $st");
emit(state.setLoading(false));
emit(state.checkInStatusError(Exception(err.toString())));
}
diff --git a/comwell_key_app/lib/comwell_app.dart b/comwell_key_app/lib/comwell_app.dart
index 62a8b609..c4ccf61a 100644
--- a/comwell_key_app/lib/comwell_app.dart
+++ b/comwell_key_app/lib/comwell_app.dart
@@ -21,16 +21,15 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class ComwellApp extends StatelessWidget {
- final AuthenticationBloc authBloc = AuthenticationBloc(authenticationRepository: locator<AuthenticationRepository>());
+ final AuthenticationBloc authBloc = AuthenticationBloc(
+ authenticationRepository: locator<AuthenticationRepository>());
ComwellApp({super.key});
@override
Widget build(BuildContext context) {
- authBloc.post();
- print("qqq build App");
return BlocProvider<AuthenticationBloc>(
- create: (context) => authBloc,
+ create: (context) => authBloc..add(AuthenticationSubscriptionRequested()),
child: MultiBlocProvider(
providers: blocProviderList,
child: MaterialApp.router(
diff --git a/comwell_key_app/lib/overview/cubit/overview_cubit.dart b/comwell_key_app/lib/overview/cubit/overview_cubit.dart
index 09180a61..7f2ce4e4 100644
--- a/comwell_key_app/lib/overview/cubit/overview_cubit.dart
+++ b/comwell_key_app/lib/overview/cubit/overview_cubit.dart
@@ -18,7 +18,7 @@ class OverviewCubit extends Cubit<OverviewState> {
final bookings = await overviewRepository.fetchAllBookingsForUser("1");
emit(OverviewLoaded(bookings: bookings));
} catch (e, st) {
- if(kDebugMode) print("qqq err=$e, $st");
+ if (kDebugMode) print("err=$e, $st");
emit(OverviewError(error: e.toString()));
}
}
diff --git a/comwell_key_app/lib/routing/app_router.dart b/comwell_key_app/lib/routing/app_router.dart
index 220b5609..93086471 100644
--- a/comwell_key_app/lib/routing/app_router.dart
+++ b/comwell_key_app/lib/routing/app_router.dart
@@ -17,6 +17,7 @@ import 'package:comwell_key_app/profile_settings/components/change_password_moda
import 'package:comwell_key_app/profile_settings/profile_settings_page.dart';
import 'package:comwell_key_app/redeem_debug/redeem_page.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
+import 'package:comwell_key_app/utils/seos_repository.dart';
import 'package:comwell_key_app/utils/stream_to_listenable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -133,6 +134,7 @@ GoRouter goRouter(AuthenticationBloc authBloc) {
lazy: false,
create: (BuildContext context) => BookingDetailsBloc(
booking,
+ seosRepository: locator<SeosRepository>(),
bookingDetailsRepository:
locator<BookingDetailsRepository>(),
),
diff --git a/comwell_key_app/lib/tracking/trackers/firebase_tracker.dart b/comwell_key_app/lib/tracking/trackers/firebase_tracker.dart
index b302230d..d020a5e4 100644
--- a/comwell_key_app/lib/tracking/trackers/firebase_tracker.dart
+++ b/comwell_key_app/lib/tracking/trackers/firebase_tracker.dart
@@ -30,10 +30,9 @@ class FirebaseTracker {
name: name,
parameters: (parameters as Map<String, Object>?) ?? <String, Object>{},
);
- } catch (e) {
- if (kDebugMode) {
- debugPrint("qqq tracking error=$e");
- }
+ } catch (e, st) {
+ if (kDebugMode) print("err=$e, $st");
+
}
}
diff --git a/comwell_key_app/test/booking_details_test/booking_details_bloc_test.dart b/comwell_key_app/test/booking_details_test/booking_details_bloc_test.dart
index 7bddb09e..a1466777 100644
--- a/comwell_key_app/test/booking_details_test/booking_details_bloc_test.dart
+++ b/comwell_key_app/test/booking_details_test/booking_details_bloc_test.dart
@@ -3,20 +3,26 @@ import 'package:comwell_key_app/booking_details/bloc/booking_details_bloc.dart';
import 'package:comwell_key_app/booking_details/booking_details_repository.dart';
import 'package:comwell_key_app/check_in/check_in_repository.dart';
import 'package:comwell_key_app/utils/locator.dart';
+import 'package:comwell_key_app/utils/seos_repository.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:mockito/mockito.dart';
-class MockBookingDetailsRepository extends Mock implements BookingDetailsRepository {}
+class MockBookingDetailsRepository extends Mock
+ implements BookingDetailsRepository {}
+
+class MockSeosRepository extends Mock implements SeosRepository {}
void main() {
// Declare the mock HomeRepository
late BookingDetailsRepository mockBookingDetailsRepository;
+ late MockSeosRepository mockSeosRepository;
// Setup function runs before every test
setUp(() {
// Initialize the mock HomeRepository
mockBookingDetailsRepository = MockBookingDetailsRepository();
+ mockSeosRepository = MockSeosRepository();
setupLocator();
});
@@ -25,7 +31,11 @@ void main() {
'emits [ValidKey] when HomeInitialEvent is added and one key is returned',
build: () {
// Return bloc with mocked repository
- return BookingDetailsBloc(CheckInRepository.mockBooking, bookingDetailsRepository: mockBookingDetailsRepository);
+ return BookingDetailsBloc(
+ CheckInRepository.mockBooking,
+ bookingDetailsRepository: mockBookingDetailsRepository,
+ seosRepository: mockSeosRepository,
+ );
},
act: (bloc) => bloc.add(InitialEvent()),
// expect: () => [isA<ValidKey>()], // Expecting ValidKey state to be emitted