Summary
This issue tracks the addition of unit tests for the Health Connect permission handling and lifecycle reconciliation paths introduced in PR #40.
Context
Raised in: #40 (comment)
Requested by: @Devasy
What needs to be tested
File: workout-logger/lib/screens/profile_screen.dart (lines 36–128)
Using Mockito mocks for IHealthConnectService and SettingsProvider, following Arrange–Act–Assert (AAA) pattern, add tests under test/:
_reconcileHealthConnectState
didChangeAppLifecycleState
_requestHealthConnectPermission
Notes
- CI only builds the APK — run
flutter test locally before committing.
- Mock
IHealthConnectService methods: isAvailable, hasPermissions, requestPermissions.
Summary
This issue tracks the addition of unit tests for the Health Connect permission handling and lifecycle reconciliation paths introduced in PR #40.
Context
Raised in: #40 (comment)
Requested by: @Devasy
What needs to be tested
File:
workout-logger/lib/screens/profile_screen.dart(lines 36–128)Using Mockito mocks for
IHealthConnectServiceandSettingsProvider, following Arrange–Act–Assert (AAA) pattern, add tests undertest/:_reconcileHealthConnectStateSettingsProvider.healthConnectEnabledwhenhc.isAvailable()returnsfalseSettingsProvider.healthConnectEnabledwhenhc.hasPermissions()returnsfalsehealthConnectEnabledis alreadyfalse(no unnecessary plugin calls)didChangeAppLifecycleState_reconcileHealthConnectStatewhen state isAppLifecycleState.resumed_requestHealthConnectPermissionhc.isAvailable()returnsfalsesettings.setHealthConnectEnabled(true)when permissions are grantedrequestPermissions()throws, re-checkshasPermissions()and handles grant/denial correctlyNotes
flutter testlocally before committing.IHealthConnectServicemethods:isAvailable,hasPermissions,requestPermissions.