|
|
|
@ -17,6 +17,7 @@ import im.vector.app.features.analytics.plan.Interaction
@@ -17,6 +17,7 @@ import im.vector.app.features.analytics.plan.Interaction
|
|
|
|
|
import io.element.android.features.leaveroom.api.LeaveRoomEvent |
|
|
|
|
import io.element.android.features.leaveroom.api.LeaveRoomState |
|
|
|
|
import io.element.android.features.leaveroom.api.aLeaveRoomState |
|
|
|
|
import io.element.android.features.roomdetails.impl.RoomBadge |
|
|
|
|
import io.element.android.features.roomdetails.impl.RoomDetailsEvent |
|
|
|
|
import io.element.android.features.roomdetails.impl.RoomDetailsPresenter |
|
|
|
|
import io.element.android.features.roomdetails.impl.RoomDetailsState |
|
|
|
@ -134,7 +135,8 @@ class RoomDetailsPresenterTest {
@@ -134,7 +135,8 @@ class RoomDetailsPresenterTest {
|
|
|
|
|
assertThat(initialState.isEncrypted).isEqualTo(room.isEncrypted) |
|
|
|
|
assertThat(initialState.canShowPinnedMessages).isTrue() |
|
|
|
|
assertThat(initialState.pinnedMessagesCount).isNull() |
|
|
|
|
cancelAndIgnoreRemainingEvents() |
|
|
|
|
assertThat(initialState.roomBadges).isEmpty() |
|
|
|
|
assertThat(awaitItem().roomBadges).isEqualTo(listOf(RoomBadge.ENCRYPTED)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -142,6 +144,7 @@ class RoomDetailsPresenterTest {
@@ -142,6 +144,7 @@ class RoomDetailsPresenterTest {
|
|
|
|
|
fun `present - initial state is updated with roomInfo if it exists`() = runTest { |
|
|
|
|
val roomInfo = aRoomInfo( |
|
|
|
|
name = A_ROOM_NAME, |
|
|
|
|
isPublic = true, |
|
|
|
|
topic = A_ROOM_TOPIC, |
|
|
|
|
avatarUrl = AN_AVATAR_URL, |
|
|
|
|
pinnedEventIds = listOf(AN_EVENT_ID), |
|
|
|
@ -161,10 +164,55 @@ class RoomDetailsPresenterTest {
@@ -161,10 +164,55 @@ class RoomDetailsPresenterTest {
|
|
|
|
|
assertThat(updatedState.roomAvatarUrl).isEqualTo(roomInfo.avatarUrl) |
|
|
|
|
assertThat(updatedState.roomTopic).isEqualTo(RoomTopicState.ExistingTopic(roomInfo.topic!!)) |
|
|
|
|
assertThat(updatedState.pinnedMessagesCount).isEqualTo(roomInfo.pinnedEventIds.size) |
|
|
|
|
assertThat(updatedState.roomBadges).isEqualTo(listOf(RoomBadge.ENCRYPTED, RoomBadge.PUBLIC)) |
|
|
|
|
cancelAndIgnoreRemainingEvents() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `present - initial state not public not encrypted should have no badges`() = runTest { |
|
|
|
|
val roomInfo = aRoomInfo( |
|
|
|
|
name = A_ROOM_NAME, |
|
|
|
|
isPublic = false, |
|
|
|
|
) |
|
|
|
|
val room = aMatrixRoom( |
|
|
|
|
isEncrypted = false, |
|
|
|
|
canInviteResult = { Result.success(true) }, |
|
|
|
|
canUserJoinCallResult = { Result.success(true) }, |
|
|
|
|
canSendStateResult = { _, _ -> Result.success(true) }, |
|
|
|
|
).apply { |
|
|
|
|
givenRoomInfo(roomInfo) |
|
|
|
|
} |
|
|
|
|
val presenter = createRoomDetailsPresenter(room) |
|
|
|
|
presenter.test { |
|
|
|
|
skipItems(1) |
|
|
|
|
val updatedState = awaitItem() |
|
|
|
|
assertThat(updatedState.roomBadges).isEmpty() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `present - initial state public not encrypted should have not encrypted and public badges`() = runTest { |
|
|
|
|
val roomInfo = aRoomInfo( |
|
|
|
|
name = A_ROOM_NAME, |
|
|
|
|
isPublic = true, |
|
|
|
|
) |
|
|
|
|
val room = aMatrixRoom( |
|
|
|
|
isEncrypted = false, |
|
|
|
|
canInviteResult = { Result.success(true) }, |
|
|
|
|
canUserJoinCallResult = { Result.success(true) }, |
|
|
|
|
canSendStateResult = { _, _ -> Result.success(true) }, |
|
|
|
|
).apply { |
|
|
|
|
givenRoomInfo(roomInfo) |
|
|
|
|
} |
|
|
|
|
val presenter = createRoomDetailsPresenter(room) |
|
|
|
|
presenter.test { |
|
|
|
|
skipItems(1) |
|
|
|
|
val updatedState = awaitItem() |
|
|
|
|
assertThat(updatedState.roomBadges).isEqualTo(listOf(RoomBadge.NOT_ENCRYPTED, RoomBadge.PUBLIC)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `present - initial state with no room name`() = runTest { |
|
|
|
|
val room = aMatrixRoom( |
|
|
|
|