From 9304762b70ff096781469b30ea6300b54a9461cb Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 22 Jan 2026 17:18:59 +0100 Subject: [PATCH] Use presenter test extension. --- .../impl/root/StartChatPresenterTest.kt | 24 ++++------------ .../userlist/DefaultUserListPresenterTest.kt | 28 +++++-------------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt index 7b34b8b52b..7c209d9052 100644 --- a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt +++ b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/root/StartChatPresenterTest.kt @@ -9,9 +9,6 @@ package io.element.android.features.startchat.impl.root import androidx.compose.runtime.MutableState -import app.cash.molecule.RecompositionMode -import app.cash.molecule.moleculeFlow -import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import io.element.android.features.invitepeople.test.FakeStartDMAction import io.element.android.features.startchat.api.ConfirmingStartDmWithMatrixUser @@ -33,6 +30,7 @@ import io.element.android.tests.testutils.WarmUpRule import io.element.android.tests.testutils.lambda.any import io.element.android.tests.testutils.lambda.lambdaRecorder import io.element.android.tests.testutils.lambda.value +import io.element.android.tests.testutils.test import kotlinx.coroutines.test.runTest import org.junit.Rule import org.junit.Test @@ -49,9 +47,7 @@ class StartChatPresenterTest { } val startDMAction = FakeStartDMAction(executeResult = executeResult) val presenter = createStartChatPresenter(startDMAction) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.startDmAction).isInstanceOf(AsyncAction.Uninitialized::class.java) assertThat(initialState.applicationName).isEqualTo(aBuildMeta().applicationName) @@ -83,9 +79,7 @@ class StartChatPresenterTest { } val startDMAction = FakeStartDMAction(executeResult = executeResult) val presenter = createStartChatPresenter(startDMAction) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.startDmAction).isInstanceOf(AsyncAction.Uninitialized::class.java) assertThat(initialState.applicationName).isEqualTo(aBuildMeta().applicationName) @@ -114,9 +108,7 @@ class StartChatPresenterTest { } val startDMAction = FakeStartDMAction(executeResult = executeResult) val presenter = createStartChatPresenter(startDMAction) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.startDmAction).isInstanceOf(AsyncAction.Uninitialized::class.java) initialState.eventSink(StartChatEvents.StartDM(matrixUser)) @@ -144,9 +136,7 @@ class StartChatPresenterTest { } val startDMAction = FakeStartDMAction(executeResult = executeResult) val presenter = createStartChatPresenter(startDMAction) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.startDmAction).isInstanceOf(AsyncAction.Uninitialized::class.java) initialState.eventSink(StartChatEvents.StartDM(matrixUser)) @@ -169,9 +159,7 @@ class StartChatPresenterTest { @Test fun `present - room directory search`() = runTest { val presenter = createStartChatPresenter(isRoomDirectorySearchEnabled = true) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) awaitItem().let { state -> assertThat(state.isRoomDirectorySearchEnabled).isTrue() diff --git a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/userlist/DefaultUserListPresenterTest.kt b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/userlist/DefaultUserListPresenterTest.kt index c02b59f77a..772392bf92 100644 --- a/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/userlist/DefaultUserListPresenterTest.kt +++ b/features/startchat/impl/src/test/kotlin/io/element/android/features/startchat/impl/userlist/DefaultUserListPresenterTest.kt @@ -8,9 +8,6 @@ package io.element.android.features.startchat.impl.userlist -import app.cash.molecule.RecompositionMode -import app.cash.molecule.moleculeFlow -import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import io.element.android.libraries.designsystem.theme.components.SearchBarResultState import io.element.android.libraries.matrix.test.FakeMatrixClient @@ -20,6 +17,7 @@ import io.element.android.libraries.usersearch.api.UserSearchResult import io.element.android.libraries.usersearch.api.UserSearchResultState import io.element.android.libraries.usersearch.test.FakeUserRepository import io.element.android.tests.testutils.WarmUpRule +import io.element.android.tests.testutils.test import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.test.runTest import org.junit.Rule @@ -40,9 +38,7 @@ class DefaultUserListPresenterTest { UserListDataStore(), FakeMatrixClient(), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) val initialState = awaitItem() assertThat(initialState.searchQuery).isEmpty() @@ -62,9 +58,7 @@ class DefaultUserListPresenterTest { UserListDataStore(), FakeMatrixClient(), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) val initialState = awaitItem() assertThat(initialState.searchQuery).isEmpty() @@ -84,9 +78,7 @@ class DefaultUserListPresenterTest { UserListDataStore(), FakeMatrixClient(), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) val initialState = awaitItem() @@ -121,9 +113,7 @@ class DefaultUserListPresenterTest { UserListDataStore(), FakeMatrixClient(), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) val initialState = awaitItem() @@ -174,9 +164,7 @@ class DefaultUserListPresenterTest { UserListDataStore(), FakeMatrixClient(), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) val initialState = awaitItem() @@ -200,9 +188,7 @@ class DefaultUserListPresenterTest { UserListDataStore(), FakeMatrixClient(), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { skipItems(1) val initialState = awaitItem()