Skip to content
Snippets Groups Projects
Unverified Commit d04c4171 authored by Juraj Kusnier's avatar Juraj Kusnier Committed by GitHub
Browse files

Test result not updated when clicking on "Test anzeigen" (EXPOSUREAPP-7136) (#3137)


* update pending test immediately

* add update pending test flag

* update test

* update test

Co-authored-by: default avatarMohamed <mohamed.metwalli@sap.com>
parent 0a7a015c
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,8 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
SubmissionTestResultPendingViewModel(
TestDispatcherProvider(),
submissionRepository,
testType = CoronaTest.Type.PCR
testType = CoronaTest.Type.PCR,
initialUpdate = false
)
)
......@@ -81,7 +82,10 @@ class SubmissionTestResultFragmentTest : BaseUITest() {
setupMockViewModel(
object : SubmissionTestResultPendingViewModel.Factory {
override fun create(testType: CoronaTest.Type): SubmissionTestResultPendingViewModel = viewModel
override fun create(
testType: CoronaTest.Type,
initialUpdate: Boolean
): SubmissionTestResultPendingViewModel = viewModel
}
)
}
......
......@@ -222,7 +222,10 @@ class HomeFragmentViewModel @AssistedInject constructor(
is SubmissionStatePCR.TestPending -> PcrTestPendingCard.Item(state) {
routeToScreen.postValue(
HomeFragmentDirections
.actionMainFragmentToSubmissionTestResultPendingFragment(testType = CoronaTest.Type.PCR)
.actionMainFragmentToSubmissionTestResultPendingFragment(
testType = CoronaTest.Type.PCR,
forceTestResultUpdate = true
)
)
}
is SubmissionStatePCR.SubmissionDone -> PcrTestSubmissionDoneCard.Item(state) {
......@@ -274,7 +277,8 @@ class HomeFragmentViewModel @AssistedInject constructor(
routeToScreen.postValue(
HomeFragmentDirections
.actionMainFragmentToSubmissionTestResultPendingFragment(
testType = CoronaTest.Type.RAPID_ANTIGEN
testType = CoronaTest.Type.RAPID_ANTIGEN,
forceTestResultUpdate = true
)
)
}
......
......@@ -31,8 +31,6 @@ class SubmissionTestResultPendingFragment : Fragment(R.layout.fragment_submissio
private val binding: FragmentSubmissionTestResultPendingBinding by viewBindingLazy()
private var skipInitialTestResultRefresh = false
private var errorDialog: AlertDialog? = null
private val navArgs by navArgs<SubmissionTestResultPendingFragmentArgs>()
......@@ -42,7 +40,7 @@ class SubmissionTestResultPendingFragment : Fragment(R.layout.fragment_submissio
factoryProducer = { viewModelFactory },
constructorCall = { factory, _ ->
factory as SubmissionTestResultPendingViewModel.Factory
factory.create(navArgs.testType)
factory.create(navArgs.testType, navArgs.forceTestResultUpdate)
}
)
......@@ -81,8 +79,6 @@ class SubmissionTestResultPendingFragment : Fragment(R.layout.fragment_submissio
}
}
skipInitialTestResultRefresh = arguments?.getBoolean("skipInitialTestResultRefresh") ?: false
binding.apply {
submissionTestResultButtonPendingRefresh.setOnClickListener {
viewModel.updateTestResult()
......@@ -120,7 +116,6 @@ class SubmissionTestResultPendingFragment : Fragment(R.layout.fragment_submissio
override fun onResume() {
super.onResume()
binding.submissionTestResultContainer.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT)
skipInitialTestResultRefresh = false
viewModel.cwaWebExceptionLiveData.observeOnce(this.viewLifecycleOwner) { exception ->
handleError(exception)
}
......
......@@ -27,11 +27,15 @@ import timber.log.Timber
class SubmissionTestResultPendingViewModel @AssistedInject constructor(
dispatcherProvider: DispatcherProvider,
private val submissionRepository: SubmissionRepository,
@Assisted private val testType: CoronaTest.Type
@Assisted private val testType: CoronaTest.Type,
@Assisted private val initialUpdate: Boolean
) : CWAViewModel(dispatcherProvider = dispatcherProvider) {
init {
Timber.v("init() coronaTestType=%s", testType)
if (initialUpdate) {
updateTestResult()
}
}
val routeToScreen = SingleLiveEvent<NavDirections?>()
......@@ -122,6 +126,6 @@ class SubmissionTestResultPendingViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory : CWAViewModelFactory<SubmissionTestResultPendingViewModel> {
fun create(testType: CoronaTest.Type): SubmissionTestResultPendingViewModel
fun create(testType: CoronaTest.Type, initialUpdate: Boolean): SubmissionTestResultPendingViewModel
}
}
......@@ -310,7 +310,7 @@
android:label="SubmissionTestResultPendingFragment"
tools:layout="@layout/fragment_submission_test_result_pending">
<argument
android:name="skipInitialTestResultRefresh"
android:name="forceTestResultUpdate"
android:defaultValue="false"
app:argType="boolean" />
<action
......@@ -350,12 +350,7 @@
android:id="@+id/action_submissionTanFragment_to_submissionTestResultPendingFragment"
app:destination="@id/submissionTestResultPendingFragment"
app:popUpTo="@id/mainFragment"
app:popUpToInclusive="false">
<argument
android:name="skipInitialTestResultRefresh"
android:defaultValue="true"
app:argType="boolean" />
</action>
app:popUpToInclusive="false" />
<action
android:id="@+id/action_submissionTanFragment_to_submissionDeletionWarningFragment"
app:destination="@id/submissionDeletionWarningFragment" />
......@@ -394,12 +389,7 @@
android:id="@+id/action_submissionTestResultPendingFragment"
app:destination="@id/submissionTestResultPendingFragment"
app:popUpTo="@id/mainFragment"
app:popUpToInclusive="false">
<argument
android:name="skipInitialTestResultRefresh"
android:defaultValue="true"
app:argType="boolean" />
</action>
app:popUpToInclusive="false" />
<action
android:id="@+id/action_to_submissionTestResultAvailableFragment"
......@@ -745,12 +735,7 @@
android:id="@+id/action_submissionDeletionWarningFragment_to_submissionTestResultPendingFragment"
app:destination="@id/submissionTestResultPendingFragment"
app:popUpTo="@id/mainFragment"
app:popUpToInclusive="false">
<argument
android:name="skipInitialTestResultRefresh"
android:defaultValue="true"
app:argType="boolean" />
</action>
app:popUpToInclusive="false" />
<action
android:id="@+id/action_submissionDeletionWarningFragment_to_submissionTestResultAvailableFragment"
app:destination="@id/submissionTestResultAvailableFragment"
......
......@@ -8,6 +8,7 @@ import io.kotest.matchers.shouldBe
import io.mockk.MockKAnnotations
import io.mockk.Runs
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.just
......@@ -40,11 +41,13 @@ class SubmissionTestResultPendingViewModelTest : BaseTest() {
}
}
fun createInstance(scope: CoroutineScope = TestCoroutineScope()) = SubmissionTestResultPendingViewModel(
dispatcherProvider = scope.asDispatcherProvider(),
submissionRepository = submissionRepository,
testType = testType
)
fun createInstance(scope: CoroutineScope = TestCoroutineScope(), forceInitialUpdate: Boolean = false) =
SubmissionTestResultPendingViewModel(
dispatcherProvider = scope.asDispatcherProvider(),
submissionRepository = submissionRepository,
testType = testType,
initialUpdate = forceInitialUpdate
)
@Test
fun `web exception handling`() {
......@@ -61,4 +64,18 @@ class SubmissionTestResultPendingViewModelTest : BaseTest() {
cwaWebExceptionLiveData.value shouldBe unexpectedError
}
}
@Test
fun `initial update triggered when forced`() {
createInstance(forceInitialUpdate = true).apply {
coVerify(exactly = 1) { submissionRepository.refreshTest(any()) }
}
}
@Test
fun `initial update not triggered when not forced`() {
createInstance().apply {
coVerify(exactly = 0) { submissionRepository.refreshTest(any()) }
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment