Skip to content

Commit

Permalink
[ANDROAPP-6162] Remove old form option (#3632)
Browse files Browse the repository at this point in the history
* [ANDROAPP-6162] Remove COMPOSE_FORM option

Signed-off-by: andresmr <[email protected]>

* [ANDROAPP-6162] Ignore flaky test

Signed-off-by: andresmr <[email protected]>

* [ANDROAPP-6162] Ignore flaky test

Signed-off-by: andresmr <[email protected]>

---------

Signed-off-by: andresmr <[email protected]>
  • Loading branch information
andresmr authored and Balcan committed May 20, 2024
1 parent d32b4b0 commit 3fd0158
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
4 changes: 3 additions & 1 deletion app/src/androidTest/java/org/dhis2/usescases/BaseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ open class BaseTest {
}

private fun disableComposeForms() {
preferencesRobot.saveValue(SET_FROM_TESTING, true)
preferencesRobot.saveValue(Feature.COMPOSE_FORMS.name, false)
}


fun enableComposeForms() {
preferencesRobot.saveValue("SET_FROM_DEVELOPMENT", true)
preferencesRobot.saveValue(SET_FROM_TESTING, true)
preferencesRobot.saveValue(Feature.COMPOSE_FORMS.name, true)
}

Expand All @@ -184,5 +185,6 @@ open class BaseTest {
val disableAnimationsTestRule = DisableAnimations()
const val MOCK_SERVER_URL = "http://127.0.0.1:8080"
const val API = "api"
const val SET_FROM_TESTING = "SET_FROM_TESTING"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SyncFlowTest : BaseTest() {
ApplicationProvider.getApplicationContext<AppTest>().mutableWorkInfoStatuses
}

@Ignore("Flaky test, will be fixed in next release")
@Test
fun shouldShowErrorWhenTEISyncFails() {
mockWebServerRobot.addResponse(GET, "/api/system/ping", API_PING_RESPONSE_OK)
Expand Down Expand Up @@ -187,6 +188,7 @@ class SyncFlowTest : BaseTest() {
cleanLocalDatabase()
}

@Ignore("Flaky test, will be addressed in next release")
@Test
fun shouldShowErrorWhenSyncDataSetFails() {
prepareFacilityDataSetIntentAndLaunchActivity(ruleDataSet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,36 @@ package org.dhis2.commons.featureconfig.data
import org.dhis2.commons.featureconfig.model.Feature
import org.dhis2.commons.featureconfig.model.FeatureState
import org.dhis2.commons.prefs.PreferenceProvider
import org.hisp.dhis.android.core.D2
import org.hisp.dhis.android.core.settings.ExperimentalFeature
import javax.inject.Inject

class FeatureConfigRepositoryImpl @Inject constructor(
val preferences: PreferenceProvider,
val d2: D2,
) : FeatureConfigRepository {

val SET_FROM_DEVELOPMENT = "SET_FROM_DEVELOPMENT"

override val featuresList: List<FeatureState>
get() = Feature.entries.map {
FeatureState(it, isFeatureEnable(it))
}
get() = Feature.entries
.filter { it.name != Feature.COMPOSE_FORMS.name }
.map { FeatureState(it, isFeatureEnable(it)) }

override fun updateItem(featureState: FeatureState) {
if (featureState.feature.name == Feature.COMPOSE_FORMS.name) {
preferences.setValue(SET_FROM_DEVELOPMENT, true)
}
preferences.setValue(featureState.feature.name, !featureState.enable)
}

override fun isFeatureEnable(feature: Feature): Boolean {
return when {
feature.name == Feature.COMPOSE_FORMS.name -> {
val fromDevelopment = preferences.getBoolean(SET_FROM_DEVELOPMENT, false)
val fromDevelopment = preferences.getBoolean("SET_FROM_TESTING", false)
if (fromDevelopment) {
preferences.getBoolean(feature.name, false)
} else if (d2.settingModule().generalSetting().blockingExists()) {
d2.settingModule().generalSetting()
.hasExperimentalFeature(ExperimentalFeature.NewFormLayout).blockingGet()
} else {
true
}
}

preferences.contains(feature.name) -> {
preferences.getBoolean(feature.name, false)
}

else -> false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import dagger.Provides
import org.dhis2.commons.featureconfig.data.FeatureConfigRepository
import org.dhis2.commons.featureconfig.data.FeatureConfigRepositoryImpl
import org.dhis2.commons.prefs.PreferenceProvider
import org.hisp.dhis.android.core.D2Manager

@Module
class FeatureConfigModule {

@Provides
fun provideRepository(preferenceProvider: PreferenceProvider): FeatureConfigRepository {
return FeatureConfigRepositoryImpl(preferenceProvider, provideD2())
return FeatureConfigRepositoryImpl(preferenceProvider)
}

private fun provideD2() = D2Manager.getD2()
}

0 comments on commit 3fd0158

Please sign in to comment.