diff --git a/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeEvent.kt b/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeEvent.kt index 545ffdc4d2f..ffedb335b53 100644 --- a/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeEvent.kt +++ b/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeEvent.kt @@ -1,9 +1,16 @@ package org.simple.clinic.facility.alertchange -sealed interface AlertFacilityChangeEvent { +import org.simple.clinic.widgets.UiEvent + +sealed interface AlertFacilityChangeEvent : UiEvent { + data class IsFacilityChangedStatusLoaded(val isFacilityChanged: Boolean) : AlertFacilityChangeEvent data object FacilityChangedMarkedAsFalse : AlertFacilityChangeEvent - data object YesButtonClicked : AlertFacilityChangeEvent + data object YesButtonClicked : AlertFacilityChangeEvent { + override val analyticsName: String = "Alert Facility Changed Sheet:Yes Button Clicked" + } + + data object FacilityChanged : AlertFacilityChangeEvent } diff --git a/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdate.kt b/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdate.kt index ddd23b942e7..2eb3b066a03 100644 --- a/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdate.kt +++ b/app/src/main/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdate.kt @@ -4,6 +4,7 @@ import com.spotify.mobius.Next import com.spotify.mobius.Next.next import com.spotify.mobius.Update import org.simple.clinic.facility.alertchange.AlertFacilityChangeEffect.MarkFacilityChangedAsFalse +import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChanged import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChangedMarkedAsFalse import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.IsFacilityChangedStatusLoaded import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.YesButtonClicked @@ -17,6 +18,7 @@ class AlertFacilityChangeUpdate : Update isFacilityChangeStatusLoaded(event, model) FacilityChangedMarkedAsFalse -> dispatch(CloseSheetWithContinuation) YesButtonClicked -> dispatch(MarkFacilityChangedAsFalse) + FacilityChanged -> dispatch(MarkFacilityChangedAsFalse) } } diff --git a/app/src/test/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdateTest.kt b/app/src/test/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdateTest.kt index 01472f39aec..9a84949a045 100644 --- a/app/src/test/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdateTest.kt +++ b/app/src/test/java/org/simple/clinic/facility/alertchange/AlertFacilityChangeUpdateTest.kt @@ -8,6 +8,7 @@ import com.spotify.mobius.test.UpdateSpec import com.spotify.mobius.test.UpdateSpec.assertThatNext import org.junit.Test import org.simple.clinic.facility.alertchange.AlertFacilityChangeEffect.MarkFacilityChangedAsFalse +import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChanged import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.FacilityChangedMarkedAsFalse import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.IsFacilityChangedStatusLoaded import org.simple.clinic.facility.alertchange.AlertFacilityChangeEvent.YesButtonClicked @@ -67,4 +68,17 @@ class AlertFacilityChangeUpdateTest { hasEffects(CloseSheetWithContinuation) )) } + + @Test + fun `when facility is changed, then mark facility changed as false`() { + val model = defaultModel.updateIsFacilityChanged(isFacilityChanged = true) + + updateSpec + .given(model) + .whenEvent(FacilityChanged) + .then(assertThatNext( + hasNoModel(), + hasEffects(MarkFacilityChangedAsFalse) + )) + } }