This commit is contained in:
Benoit Marty 2025-09-23 09:28:01 +02:00
parent 41ef36c1ae
commit bfc770d46e

View file

@ -7,9 +7,6 @@
package io.element.android.libraries.troubleshoot.impl package io.element.android.libraries.troubleshoot.impl
import app.cash.molecule.RecompositionMode
import app.cash.molecule.moleculeFlow
import app.cash.turbine.test
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.architecture.AsyncAction import io.element.android.libraries.architecture.AsyncAction
import io.element.android.libraries.push.test.FakeGetCurrentPushProvider import io.element.android.libraries.push.test.FakeGetCurrentPushProvider
@ -26,9 +23,7 @@ class TroubleshootNotificationsPresenterTest {
@Test @Test
fun `present - initial state`() = runTest { fun `present - initial state`() = runTest {
val presenter = createTroubleshootNotificationsPresenter() val presenter = createTroubleshootNotificationsPresenter()
moleculeFlow(RecompositionMode.Immediate) { presenter.test {
presenter.present()
}.test {
val initialState = awaitItem() val initialState = awaitItem()
assertThat(initialState.testSuiteState.tests).isEmpty() assertThat(initialState.testSuiteState.tests).isEmpty()
assertThat(initialState.testSuiteState.mainState).isEqualTo(AsyncAction.Uninitialized) assertThat(initialState.testSuiteState.mainState).isEqualTo(AsyncAction.Uninitialized)
@ -43,9 +38,7 @@ class TroubleshootNotificationsPresenterTest {
val presenter = createTroubleshootNotificationsPresenter( val presenter = createTroubleshootNotificationsPresenter(
troubleshootTestSuite = troubleshootTestSuite, troubleshootTestSuite = troubleshootTestSuite,
) )
moleculeFlow(RecompositionMode.Immediate) { presenter.test {
presenter.present()
}.test {
val initialState = awaitItem() val initialState = awaitItem()
initialState.eventSink(TroubleshootNotificationsEvents.StartTests) initialState.eventSink(TroubleshootNotificationsEvents.StartTests)
skipItems(1) skipItems(1)
@ -66,9 +59,7 @@ class TroubleshootNotificationsPresenterTest {
val presenter = createTroubleshootNotificationsPresenter( val presenter = createTroubleshootNotificationsPresenter(
troubleshootTestSuite = troubleshootTestSuite, troubleshootTestSuite = troubleshootTestSuite,
) )
moleculeFlow(RecompositionMode.Immediate) { presenter.test {
presenter.present()
}.test {
val initialState = awaitItem() val initialState = awaitItem()
initialState.eventSink(TroubleshootNotificationsEvents.RetryFailedTests) initialState.eventSink(TroubleshootNotificationsEvents.RetryFailedTests)
skipItems(1) skipItems(1)
@ -163,9 +154,7 @@ class TroubleshootNotificationsPresenterTest {
val presenter = createTroubleshootNotificationsPresenter( val presenter = createTroubleshootNotificationsPresenter(
troubleshootTestSuite = troubleshootTestSuite, troubleshootTestSuite = troubleshootTestSuite,
) )
moleculeFlow(RecompositionMode.Immediate) { presenter.test {
presenter.present()
}.test {
skipItems(1) skipItems(1)
val initialState = awaitItem() val initialState = awaitItem()
assertThat(initialState.testSuiteState.mainState).isInstanceOf(AsyncAction.Failure::class.java) assertThat(initialState.testSuiteState.mainState).isInstanceOf(AsyncAction.Failure::class.java)