Browse Source

Merge pull request #3717 from element-hq/feature/bma/fixFlakyTest

Fix flaky tests.
pull/3283/merge
Benoit Marty 1 week ago committed by GitHub
parent
commit
45f4e54e18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenterTest.kt

10
features/preferences/impl/src/test/kotlin/io/element/android/features/preferences/impl/developer/DeveloperSettingsPresenterTest.kt

@ -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)
}
}

Loading…
Cancel
Save