Merge pull request #3717 from element-hq/feature/bma/fixFlakyTest
Fix flaky tests.
This commit is contained in:
commit
9610292812
1 changed files with 5 additions and 5 deletions
|
|
@ -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.WarmUpRule
|
||||||
import io.element.android.tests.testutils.awaitLastSequentialItem
|
import io.element.android.tests.testutils.awaitLastSequentialItem
|
||||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.test.advanceUntilIdle
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
@ -154,6 +155,7 @@ class DeveloperSettingsPresenterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Test
|
@Test
|
||||||
fun `present - toggling simplified sliding sync changes the preferences and logs out the user`() = runTest {
|
fun `present - toggling simplified sliding sync changes the preferences and logs out the user`() = runTest {
|
||||||
val logoutCallRecorder = lambdaRecorder<Boolean, String?> { "" }
|
val logoutCallRecorder = lambdaRecorder<Boolean, String?> { "" }
|
||||||
|
|
@ -169,15 +171,13 @@ class DeveloperSettingsPresenterTest {
|
||||||
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(true))
|
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(true))
|
||||||
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isTrue()
|
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isTrue()
|
||||||
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isTrue()
|
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isTrue()
|
||||||
// Give time for the logout to be called, but for some reason using runCurrent() is not enough
|
advanceUntilIdle()
|
||||||
delay(2)
|
|
||||||
logoutCallRecorder.assertions().isCalledOnce()
|
logoutCallRecorder.assertions().isCalledOnce()
|
||||||
|
|
||||||
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(false))
|
initialState.eventSink(DeveloperSettingsEvents.SetSimplifiedSlidingSyncEnabled(false))
|
||||||
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isFalse()
|
assertThat(awaitItem().isSimpleSlidingSyncEnabled).isFalse()
|
||||||
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isFalse()
|
assertThat(preferences.isSimplifiedSlidingSyncEnabledFlow().first()).isFalse()
|
||||||
// Give time for the logout to be called, but for some reason using runCurrent() is not enough
|
advanceUntilIdle()
|
||||||
delay(2)
|
|
||||||
logoutCallRecorder.assertions().isCalledExactly(times = 2)
|
logoutCallRecorder.assertions().isCalledExactly(times = 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue