From d86cdebde765578c56917e3f73f391aeb23c6a83 Mon Sep 17 00:00:00 2001 From: andresmr Date: Wed, 17 Jan 2024 15:01:11 +0100 Subject: [PATCH 1/2] [ANDROIDAP-5770] Update compose library to 1.5.4 --- gradle/libs.versions.toml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a39297882f..bb5dc35df4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -28,13 +28,12 @@ fragmentktx = "1.6.1" dynamicanimation = "1.0.0" viewpager2 = "1.0.0" recyclerview = "1.3.1" -compose = "1.5.0" +compose = "1.5.4" composeTheme = "1.2.1" composeConstraintLayout = "1.0.1" -activityCompose = "1.7.2" -viewModelCompose = "2.6.1" -compose_ui_test = "1.5.0" -compose_ui_viewbinding = "1.5.0" +activityCompose = "1.8.2" +viewModelCompose = "2.7.0" +compose_ui_test = "1.5.4" material = "1.9.0" flexbox = "3.0.0" material3 = "1.1.1" From 8407fd8fe3fc6bcd136933c6e1d0de0857d90562 Mon Sep 17 00:00:00 2001 From: andresmr Date: Fri, 19 Jan 2024 10:47:41 +0100 Subject: [PATCH 2/2] [ANDROAPP-5770] update tests to perform search --- .../managestock/ManageStockViewModelTest.kt | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/stock-usecase/src/test/java/org/dhis2/android/rtsm/ui/managestock/ManageStockViewModelTest.kt b/stock-usecase/src/test/java/org/dhis2/android/rtsm/ui/managestock/ManageStockViewModelTest.kt index 640337f5fd..ca0635d656 100644 --- a/stock-usecase/src/test/java/org/dhis2/android/rtsm/ui/managestock/ManageStockViewModelTest.kt +++ b/stock-usecase/src/test/java/org/dhis2/android/rtsm/ui/managestock/ManageStockViewModelTest.kt @@ -1,9 +1,9 @@ package org.dhis2.android.rtsm.ui.managestock import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import androidx.lifecycle.liveData import com.github.javafaker.Faker import io.reactivex.disposables.CompositeDisposable -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.dhis2.android.rtsm.MainDispatcherRule import org.dhis2.android.rtsm.data.AppConfig @@ -11,6 +11,8 @@ import org.dhis2.android.rtsm.data.DestinationFactory import org.dhis2.android.rtsm.data.FacilityFactory import org.dhis2.android.rtsm.data.TransactionType import org.dhis2.android.rtsm.data.models.IdentifiableModel +import org.dhis2.android.rtsm.data.models.SearchParametersModel +import org.dhis2.android.rtsm.data.models.SearchResult import org.dhis2.android.rtsm.data.models.StockItem import org.dhis2.android.rtsm.data.models.Transaction import org.dhis2.android.rtsm.services.SpeechRecognitionManager @@ -33,10 +35,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mock import org.mockito.junit.MockitoJUnitRunner +import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock +import org.mockito.kotlin.whenever import timber.log.Timber -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(MockitoJUnitRunner::class) class ManageStockViewModelTest { @get:Rule @@ -123,6 +126,18 @@ class ManageStockViewModelTest { @Test fun init_shouldSetFacilityDateAndDistributedToForDistribution() = runTest { + whenever( + stockManager.search( + query = SearchParametersModel( + null, + null, + facility.uid, + ), + ou = facility.uid, + config = appConfig, + ), + ) doReturn SearchResult(liveData { emptyList() }) + val transaction = Transaction( transactionType = TransactionType.DISTRIBUTION, facility = facility, @@ -130,6 +145,7 @@ class ManageStockViewModelTest { distributedTo = distributedTo, ) val viewModel = getModel() + viewModel.setConfig(appConfig) viewModel.setup(transaction) viewModel.transaction.let { @@ -142,6 +158,18 @@ class ManageStockViewModelTest { @Test fun init_shouldSetFacilityAndDateForDiscard() = runTest { + whenever( + stockManager.search( + query = SearchParametersModel( + null, + null, + facility.uid, + ), + ou = facility.uid, + config = appConfig, + ), + ) doReturn SearchResult(liveData { emptyList() }) + val transaction = Transaction( transactionType = TransactionType.DISCARD, facility = facility, @@ -149,6 +177,7 @@ class ManageStockViewModelTest { distributedTo = null, ) val viewModel = getModel() + viewModel.setConfig(appConfig) viewModel.setup(transaction) viewModel.transaction.let { @@ -161,6 +190,18 @@ class ManageStockViewModelTest { @Test fun init_shouldSetFacilityAndDateForCorrection() = runTest { + whenever( + stockManager.search( + query = SearchParametersModel( + null, + null, + facility.uid, + ), + ou = facility.uid, + config = appConfig, + ), + ) doReturn SearchResult(liveData { emptyList() }) + val transaction = Transaction( transactionType = TransactionType.CORRECTION, facility = facility, @@ -168,6 +209,7 @@ class ManageStockViewModelTest { distributedTo = null, ) val viewModel = getModel() + viewModel.setConfig(appConfig) viewModel.setup(transaction) viewModel.transaction.let {