|
|
|
@ -26,8 +26,9 @@ import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
@@ -26,8 +26,9 @@ import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
|
|
|
|
|
import io.element.android.tests.testutils.WarmUpRule |
|
|
|
|
import io.element.android.tests.testutils.awaitLastSequentialItem |
|
|
|
|
import io.element.android.tests.testutils.lambda.lambdaRecorder |
|
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi |
|
|
|
|
import kotlinx.coroutines.flow.first |
|
|
|
|
import kotlinx.coroutines.test.advanceUntilIdle |
|
|
|
|
import kotlinx.coroutines.test.runTest |
|
|
|
|
import org.junit.Rule |
|
|
|
|
import org.junit.Test |
|
|
|
@ -154,6 +155,7 @@ class DeveloperSettingsPresenterTest {
@@ -154,6 +155,7 @@ class DeveloperSettingsPresenterTest {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalCoroutinesApi::class) |
|
|
|
|
@Test |
|
|
|
|
fun `present - toggling simplified sliding sync changes the preferences and logs out the user`() = runTest { |
|
|
|
|
val logoutCallRecorder = lambdaRecorder<Boolean, String?> { "" } |
|
|
|
@ -169,15 +171,13 @@ class DeveloperSettingsPresenterTest {
@@ -169,15 +171,13 @@ class DeveloperSettingsPresenterTest {
|
|
|
|
|
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(true)) |
|
|
|
|
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isTrue() |
|
|
|
|
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isTrue() |
|
|
|
|
// Give time for the logout to be called, but for some reason using runCurrent() is not enough |
|
|
|
|
delay(2) |
|
|
|
|
advanceUntilIdle() |
|
|
|
|
logoutCallRecorder.assertions().isCalledOnce() |
|
|
|
|
|
|
|
|
|
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(false)) |
|
|
|
|
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isFalse() |
|
|
|
|
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isFalse() |
|
|
|
|
// Give time for the logout to be called, but for some reason using runCurrent() is not enough |
|
|
|
|
delay(2) |
|
|
|
|
advanceUntilIdle() |
|
|
|
|
logoutCallRecorder.assertions().isCalledExactly(times = 2) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|