Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Missing tracing duration on low risk detail screen (EXPOSUREAPP-5092) #2326

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ data class LowRisk(
)
}

fun isGoneOnContentLowView(context: Context) = getRiskContactLast(context) != null && !isInDetailsMode

fun getProgressColorLowRisk(context: Context) = context.getColorCompat(R.color.colorStableLight)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/row_saved_days"
gone="@{state.getRiskContactLast(context) != null}"
gone="@{state.isGoneOnContentLowView(context)}"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package de.rki.coronawarnapp.tracing.states

import android.content.Context
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.risk.RiskState
import io.kotest.matchers.shouldBe
import io.mockk.MockKAnnotations
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.joda.time.Instant
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

internal class LowRiskTest {

@MockK private lateinit var context: Context

@BeforeEach
fun setUp() {
MockKAnnotations.init(this)
every {
context.getString(
R.string.risk_card_low_risk_most_recent_body_encounter_on_single_day,
any()
)
} returns "String not relevant for this test"
}

@AfterEach
fun tearDown() {
clearAllMocks()
}

private val defaultRisk = LowRisk(
riskState = RiskState.LOW_RISK,
isInDetailsMode = false,
lastExposureDetectionTime = Instant.now(),
allowManualUpdate = false,
daysWithEncounters = 0,
activeTracingDays = 1,
lastEncounterAt = null
)

@Test
fun `Active tracing row should be visible in low risk card on the home screen when there are no encounters`() {
defaultRisk.isGoneOnContentLowView(context) shouldBe false
}

@Test
fun `Active tracing row should be gone in low risk card on the home screen when there are encounters`() {
defaultRisk
.copy(daysWithEncounters = 1, lastEncounterAt = Instant.now())
.isGoneOnContentLowView(context) shouldBe true
}

@Test
fun `Active tracing row should be shown in low risk detail screen when there are no encounters`() {
defaultRisk
.copy(isInDetailsMode = true)
.isGoneOnContentLowView(context) shouldBe false
}

@Test
fun `Active tracing row should be shown in low risk detail screen when there are encounters`() {
defaultRisk
.copy(daysWithEncounters = 1, lastEncounterAt = Instant.now(), isInDetailsMode = true)
.isGoneOnContentLowView(context) shouldBe false
}
}