Add test covering fallback to user profile.
This commit is contained in:
@@ -37,6 +37,7 @@ import io.element.android.libraries.matrix.api.room.MatrixRoomMembersState
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.libraries.matrix.test.A_THROWABLE
|
||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
||||
import io.element.android.tests.testutils.WarmUpRule
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -122,6 +123,33 @@ class RoomMemberDetailsPresenterTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - will fallback to user profile if user is not a member of the room`() = runTest {
|
||||
val bobProfile = aMatrixUser("@bob:server.org", "Bob", avatarUrl = "anAvatarUrl")
|
||||
val room = aMatrixRoom().apply {
|
||||
givenUserDisplayNameResult(Result.failure(Exception("Not a member!")))
|
||||
givenUserAvatarUrlResult(Result.failure(Exception("Not a member!")))
|
||||
}
|
||||
val client = FakeMatrixClient().apply {
|
||||
givenGetProfileResult(bobProfile.userId, Result.success(bobProfile))
|
||||
}
|
||||
val presenter = createRoomMemberDetailsPresenter(
|
||||
client = client,
|
||||
room = room,
|
||||
roomMemberId = UserId("@bob:server.org")
|
||||
)
|
||||
moleculeFlow(RecompositionMode.Immediate) {
|
||||
presenter.present()
|
||||
}.test {
|
||||
skipItems(2)
|
||||
val initialState = awaitFirstItem()
|
||||
assertThat(initialState.userName).isEqualTo("Bob")
|
||||
assertThat(initialState.avatarUrl).isEqualTo("anAvatarUrl")
|
||||
|
||||
ensureAllEventsConsumed()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - BlockUser needing confirmation displays confirmation dialog`() = runTest {
|
||||
val presenter = createRoomMemberDetailsPresenter()
|
||||
|
||||
Reference in New Issue
Block a user