feat(room preview) : use room summary joined members count
This commit is contained in:
parent
ba07370dfa
commit
3b0ac5420a
3 changed files with 48 additions and 8 deletions
|
|
@ -256,7 +256,7 @@ internal fun MatrixRoomInfo.toContentState(): ContentState {
|
||||||
name = name,
|
name = name,
|
||||||
topic = topic,
|
topic = topic,
|
||||||
alias = canonicalAlias,
|
alias = canonicalAlias,
|
||||||
numberOfMembers = activeMembersCount,
|
numberOfMembers = joinedMembersCount,
|
||||||
isDm = isDm,
|
isDm = isDm,
|
||||||
roomType = if (isSpace) RoomType.Space else RoomType.Room,
|
roomType = if (isSpace) RoomType.Space else RoomType.Room,
|
||||||
roomAvatarUrl = avatarUrl,
|
roomAvatarUrl = avatarUrl,
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class JoinRoomPresenterTest {
|
||||||
assertThat(contentState.name).isEqualTo(roomSummary.info.name)
|
assertThat(contentState.name).isEqualTo(roomSummary.info.name)
|
||||||
assertThat(contentState.topic).isEqualTo(roomSummary.info.topic)
|
assertThat(contentState.topic).isEqualTo(roomSummary.info.topic)
|
||||||
assertThat(contentState.alias).isEqualTo(roomSummary.info.canonicalAlias)
|
assertThat(contentState.alias).isEqualTo(roomSummary.info.canonicalAlias)
|
||||||
assertThat(contentState.numberOfMembers).isEqualTo(roomSummary.info.activeMembersCount)
|
assertThat(contentState.numberOfMembers).isEqualTo(roomSummary.info.joinedMembersCount)
|
||||||
assertThat(contentState.isDm).isEqualTo(roomSummary.info.isDirect)
|
assertThat(contentState.isDm).isEqualTo(roomSummary.info.isDirect)
|
||||||
assertThat(contentState.roomAvatarUrl).isEqualTo(roomSummary.info.avatarUrl)
|
assertThat(contentState.roomAvatarUrl).isEqualTo(roomSummary.info.avatarUrl)
|
||||||
}
|
}
|
||||||
|
|
@ -545,7 +545,7 @@ class JoinRoomPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - when room is not known RoomPreview is loaded as Private `() = runTest {
|
fun `present - when room is not known RoomPreview is loaded as Private`() = runTest {
|
||||||
val client = FakeMatrixClient(
|
val client = FakeMatrixClient(
|
||||||
getRoomPreviewInfoResult = { _, _ ->
|
getRoomPreviewInfoResult = { _, _ ->
|
||||||
Result.success(
|
Result.success(
|
||||||
|
|
@ -565,7 +565,47 @@ class JoinRoomPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - when room is not known RoomPreview is loaded as KnockRestricted `() = runTest {
|
fun `present - when room is not known RoomPreview is loaded as Custom`() = runTest {
|
||||||
|
val client = FakeMatrixClient(
|
||||||
|
getRoomPreviewInfoResult = { _, _ ->
|
||||||
|
Result.success(
|
||||||
|
aRoomPreviewInfo(joinRule = JoinRule.Custom("custom"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
val presenter = createJoinRoomPresenter(
|
||||||
|
matrixClient = client
|
||||||
|
)
|
||||||
|
presenter.test {
|
||||||
|
skipItems(1)
|
||||||
|
awaitItem().also { state ->
|
||||||
|
assertThat(state.joinAuthorisationStatus).isEqualTo(JoinAuthorisationStatus.Unknown)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - when room is not known RoomPreview is loaded as Invite`() = runTest {
|
||||||
|
val client = FakeMatrixClient(
|
||||||
|
getRoomPreviewInfoResult = { _, _ ->
|
||||||
|
Result.success(
|
||||||
|
aRoomPreviewInfo(joinRule = JoinRule.Invite)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
val presenter = createJoinRoomPresenter(
|
||||||
|
matrixClient = client
|
||||||
|
)
|
||||||
|
presenter.test {
|
||||||
|
skipItems(1)
|
||||||
|
awaitItem().also { state ->
|
||||||
|
assertThat(state.joinAuthorisationStatus).isEqualTo(JoinAuthorisationStatus.NeedInvite)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - when room is not known RoomPreview is loaded as KnockRestricted`() = runTest {
|
||||||
val client = FakeMatrixClient(
|
val client = FakeMatrixClient(
|
||||||
getRoomPreviewInfoResult = { _, _ ->
|
getRoomPreviewInfoResult = { _, _ ->
|
||||||
Result.success(
|
Result.success(
|
||||||
|
|
@ -585,7 +625,7 @@ class JoinRoomPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - when room is not known RoomPreview is loaded as Restricted `() = runTest {
|
fun `present - when room is not known RoomPreview is loaded as Restricted`() = runTest {
|
||||||
val client = FakeMatrixClient(
|
val client = FakeMatrixClient(
|
||||||
getRoomPreviewInfoResult = { _, _ ->
|
getRoomPreviewInfoResult = { _, _ ->
|
||||||
Result.success(
|
Result.success(
|
||||||
|
|
@ -605,7 +645,7 @@ class JoinRoomPresenterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - when room is not known RoomPreview is loaded as Space `() = runTest {
|
fun `present - when room is not known RoomPreview is loaded as Space`() = runTest {
|
||||||
val client = FakeMatrixClient(
|
val client = FakeMatrixClient(
|
||||||
getRoomPreviewInfoResult = { _, _ ->
|
getRoomPreviewInfoResult = { _, _ ->
|
||||||
Result.success(
|
Result.success(
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ fun aRoomInfo(
|
||||||
alternativeAliases: List<RoomAlias> = emptyList(),
|
alternativeAliases: List<RoomAlias> = emptyList(),
|
||||||
currentUserMembership: CurrentUserMembership = CurrentUserMembership.JOINED,
|
currentUserMembership: CurrentUserMembership = CurrentUserMembership.JOINED,
|
||||||
inviter: RoomMember? = null,
|
inviter: RoomMember? = null,
|
||||||
activeMembersCount: Long = 1,
|
activeMembersCount: Long = 2,
|
||||||
invitedMembersCount: Long = 0,
|
invitedMembersCount: Long = 1,
|
||||||
joinedMembersCount: Long = 1,
|
joinedMembersCount: Long = 1,
|
||||||
highlightCount: Long = 0,
|
highlightCount: Long = 0,
|
||||||
notificationCount: Long = 0,
|
notificationCount: Long = 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue