Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Jan 25, 2024
1 parent a8cd46e commit 4fb8642
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ data class ApplicationConfiguration(
var appLogoIconResourceFile: String = "ic_default_logo",
var count: String = ConfigurationRegistry.DEFAULT_COUNT,
var patientTypeFilterTagViaMetaCodingSystem: String = "",
var taskOrderFilterTagViaMetaCodingSystem: String = DEFAULT_TASK_ORDER_FILTER_TAG_META_CODING_SYSTEM,
var taskOrderFilterTagViaMetaCodingSystem: String =
DEFAULT_TASK_ORDER_FILTER_TAG_META_CODING_SYSTEM,
var taskFilterTagViaMetaCodingSystem: String = DEFAULT_TASK_FILTER_TAG_META_CODING_SYSTEM
) : Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,17 @@ constructor(
phoneContacts = patient.extractTelecom(),
chwAssigned = patient.generalPractitionerFirstRep,
showIdentifierInProfile = true,
healthStatus = patient.extractHealthStatusFromMeta(configuration.patientTypeFilterTagViaMetaCodingSystem),
healthStatus =
patient.extractHealthStatusFromMeta(configuration.patientTypeFilterTagViaMetaCodingSystem),
tasks =
patient
.activeTasks()
.sortedWith(
compareBy(
{ it.clinicVisitOrder(configuration.taskOrderFilterTagViaMetaCodingSystem) ?: Double.MAX_VALUE },
{
it.clinicVisitOrder(configuration.taskOrderFilterTagViaMetaCodingSystem)
?: Double.MAX_VALUE
},
// tasks with no clinicVisitOrder, would be sorted with Task#description
{ it.description }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import ca.uhn.fhir.context.FhirContext
import ca.uhn.fhir.context.FhirVersionEnum
import com.google.android.fhir.datacapture.QuestionnaireFragment
import com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.checkQuestionnaireResponse
import com.google.android.fhir.logicalId
import dagger.hilt.android.testing.BindValue
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
Expand Down Expand Up @@ -343,6 +344,7 @@ class QuestionnaireActivityTest : ActivityRobolectricTest() {
val questionnaireResponse =
questionnaireViewModel2.generateQuestionnaireResponse(questionnaire, populationIntent)
questionnaireResponse.distinctifyLinkId()
questionnaireResponse.questionnaire = "${questionnaire.resourceType}/${questionnaire.logicalId}"
checkQuestionnaireResponse(questionnaire, questionnaireResponse)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.test.core.app.ApplicationProvider
import io.mockk.coEvery
import io.mockk.mockk
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
Expand All @@ -42,16 +43,19 @@ class SettingsScreenKtTest : RobolectricTest() {
private val devMenuViewModel = mockk<DevViewModel>()

@Test
fun testSettingsScreenShowsUserProfileRows() = runTest {
coEvery { devMenuViewModel.getResourcesToReport() } returns emptyMap()
coEvery { settingsViewModel.profileData } returns MutableLiveData()
composeRule.setContent {
SettingsScreen(settingsViewModel = settingsViewModel, devViewModel = devMenuViewModel)
}
fun testSettingsScreenShowsUserProfileRows() =
runTest(UnconfinedTestDispatcher()) {
coEvery { devMenuViewModel.getResourcesToReport() } returns emptyMap()
coEvery { settingsViewModel.profileData } returns MutableLiveData()
composeRule.setContent {
SettingsScreen(settingsViewModel = settingsViewModel, devViewModel = devMenuViewModel)
}

composeRule.onNodeWithText(appContext.getString(R.string.re_fetch_practitioner)).assertExists()
composeRule.onNodeWithText(appContext.getString(R.string.sync)).assertExists()
composeRule.onNodeWithText(appContext.getString(R.string.dev_menu)).assertExists()
composeRule.onNodeWithText(appContext.getString(R.string.logout)).assertExists()
}
composeRule
.onNodeWithText(appContext.getString(R.string.re_fetch_practitioner))
.assertExists()
composeRule.onNodeWithText(appContext.getString(R.string.sync)).assertExists()
composeRule.onNodeWithText(appContext.getString(R.string.dev_menu)).assertExists()
composeRule.onNodeWithText(appContext.getString(R.string.logout)).assertExists()
}
}

0 comments on commit 4fb8642

Please sign in to comment.