diff --git a/feature/setup/src/main/java/com/simprints/feature/setup/screen/SetupFragment.kt b/feature/setup/src/main/java/com/simprints/feature/setup/screen/SetupFragment.kt index 10f8d32d83..d323fcd071 100644 --- a/feature/setup/src/main/java/com/simprints/feature/setup/screen/SetupFragment.kt +++ b/feature/setup/src/main/java/com/simprints/feature/setup/screen/SetupFragment.kt @@ -94,7 +94,9 @@ internal class SetupFragment : Fragment(R.layout.fragment_setup) { // Overall setup result observeOverallSetupResult() // Start the setup process - viewModel.start() + if (savedInstanceState == null) { + viewModel.start() + } } private fun observeOverallSetupResult() = viewModel.overallSetupResult.observe(viewLifecycleOwner) { diff --git a/feature/setup/src/test/java/com/simprints/feature/setup/screen/SetupViewModelTest.kt b/feature/setup/src/test/java/com/simprints/feature/setup/screen/SetupViewModelTest.kt index 12b03961ce..ea9328b776 100644 --- a/feature/setup/src/test/java/com/simprints/feature/setup/screen/SetupViewModelTest.kt +++ b/feature/setup/src/test/java/com/simprints/feature/setup/screen/SetupViewModelTest.kt @@ -81,7 +81,11 @@ class SetupViewModelTest { fun `should not request location permission if collectLocation is disabled`() = runTest { // Given coEvery { configManager.getProjectConfiguration().general.collectLocation } returns false - coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk() + coEvery { + configManager + .getProjectConfiguration() + .synchronization.down.commCare + } returns mockk() // when viewModel.start() @@ -95,7 +99,11 @@ class SetupViewModelTest { // Given justRun { locationStore.collectLocationInBackground() } coEvery { configManager.getProjectConfiguration() } returns mockk() - coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk() + coEvery { + configManager + .getProjectConfiguration() + .synchronization.down.commCare + } returns mockk() // when viewModel.locationPermissionCheckDone(granted = true) @@ -109,7 +117,11 @@ class SetupViewModelTest { // Given justRun { locationStore.collectLocationInBackground() } coEvery { configManager.getProjectConfiguration() } returns mockk() - coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk() + coEvery { + configManager + .getProjectConfiguration() + .synchronization.down.commCare + } returns mockk() // when viewModel.locationPermissionCheckDone(granted = false) @@ -122,7 +134,11 @@ class SetupViewModelTest { fun `should request CommCare permission if needed when location permission is granted`() = runTest { // Given justRun { locationStore.collectLocationInBackground() } - coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk() + coEvery { + configManager + .getProjectConfiguration() + .synchronization.down.commCare + } returns mockk() // When viewModel.locationPermissionCheckDone(true) @@ -135,7 +151,11 @@ class SetupViewModelTest { fun `should request CommCare permission if needed when location permission is not granted`() = runTest { // Given justRun { locationStore.collectLocationInBackground() } - coEvery { configManager.getProjectConfiguration().synchronization.down.commCare } returns mockk() + coEvery { + configManager + .getProjectConfiguration() + .synchronization.down.commCare + } returns mockk() // When viewModel.locationPermissionCheckDone(false)