-
Notifications
You must be signed in to change notification settings - Fork 296
Leave space - UI #5354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Leave space - UI #5354
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
74c2ee4
Leave space - Add screen to leave a space.
bmarty cbd591e
Remove translations (key values have changed).
bmarty 9732d55
Add the (Admin) info.
bmarty de6f52c
Add unit test on LeaveSpaceState
bmarty f503bc4
Select all rooms by default
bmarty 5afe213
Update UI
bmarty b4232a8
Update tests
bmarty c1678b5
Cleanup to be able to merge.
bmarty 4d1a503
Metro now have `@AssistedInject`.
bmarty 6921117
Update screenshots
ElementBot 0e3efaf
Merge branch 'develop' into feature/bma/leaveSpace
bmarty c78aa7c
Update screenshots
ElementBot ef36922
Address review comments.
bmarty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
.../impl/src/test/kotlin/io/element/android/features/space/impl/leave/LeaveSpaceStateTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright 2025 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.space.impl.leave | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import io.element.android.libraries.architecture.AsyncData | ||
import kotlinx.collections.immutable.persistentListOf | ||
import kotlinx.collections.immutable.toPersistentList | ||
import org.junit.Test | ||
|
||
class LeaveSpaceStateTest { | ||
@Test | ||
fun `test loading`() { | ||
val sut = aLeaveSpaceState( | ||
selectableSpaceRooms = AsyncData.Loading() | ||
) | ||
assertThat(sut.showQuickAction).isFalse() | ||
assertThat(sut.areAllSelected).isFalse() | ||
assertThat(sut.hasOnlyLastAdminRoom).isFalse() | ||
assertThat(sut.numberOfSelectRooms).isEqualTo(0) | ||
} | ||
|
||
@Test | ||
fun `test no rooms`() { | ||
val sut = aLeaveSpaceState( | ||
selectableSpaceRooms = AsyncData.Success( | ||
persistentListOf() | ||
) | ||
) | ||
assertThat(sut.showQuickAction).isFalse() | ||
assertThat(sut.areAllSelected).isFalse() | ||
assertThat(sut.hasOnlyLastAdminRoom).isFalse() | ||
assertThat(sut.numberOfSelectRooms).isEqualTo(0) | ||
} | ||
|
||
@Test | ||
fun `test no last admin, 1 selected, 1 not selected`() { | ||
val sut = aLeaveSpaceState( | ||
selectableSpaceRooms = AsyncData.Success( | ||
listOf( | ||
aSelectableSpaceRoom(isLastAdmin = false, isSelected = true), | ||
aSelectableSpaceRoom(isLastAdmin = false, isSelected = false), | ||
).toPersistentList() | ||
) | ||
) | ||
assertThat(sut.showQuickAction).isTrue() | ||
assertThat(sut.areAllSelected).isFalse() | ||
assertThat(sut.hasOnlyLastAdminRoom).isFalse() | ||
assertThat(sut.numberOfSelectRooms).isEqualTo(1) | ||
} | ||
|
||
@Test | ||
fun `test no last admin, 2 selected`() { | ||
val sut = aLeaveSpaceState( | ||
selectableSpaceRooms = AsyncData.Success( | ||
listOf( | ||
aSelectableSpaceRoom(isLastAdmin = false, isSelected = true), | ||
aSelectableSpaceRoom(isLastAdmin = false, isSelected = true), | ||
).toPersistentList() | ||
) | ||
) | ||
assertThat(sut.showQuickAction).isTrue() | ||
assertThat(sut.areAllSelected).isTrue() | ||
assertThat(sut.hasOnlyLastAdminRoom).isFalse() | ||
assertThat(sut.numberOfSelectRooms).isEqualTo(2) | ||
} | ||
|
||
@Test | ||
fun `test 1 last admin, 2 selected`() { | ||
val sut = aLeaveSpaceState( | ||
selectableSpaceRooms = AsyncData.Success( | ||
listOf( | ||
aSelectableSpaceRoom(isLastAdmin = true, isSelected = false), | ||
aSelectableSpaceRoom(isLastAdmin = false, isSelected = true), | ||
aSelectableSpaceRoom(isLastAdmin = false, isSelected = true), | ||
).toPersistentList() | ||
) | ||
) | ||
assertThat(sut.showQuickAction).isTrue() | ||
assertThat(sut.areAllSelected).isTrue() | ||
assertThat(sut.hasOnlyLastAdminRoom).isFalse() | ||
assertThat(sut.numberOfSelectRooms).isEqualTo(2) | ||
} | ||
|
||
@Test | ||
fun `test only last admin`() { | ||
val sut = aLeaveSpaceState( | ||
selectableSpaceRooms = AsyncData.Success( | ||
listOf( | ||
aSelectableSpaceRoom(isLastAdmin = true, isSelected = false), | ||
aSelectableSpaceRoom(isLastAdmin = true, isSelected = false), | ||
).toPersistentList() | ||
) | ||
) | ||
assertThat(sut.showQuickAction).isFalse() | ||
assertThat(sut.areAllSelected).isFalse() | ||
assertThat(sut.hasOnlyLastAdminRoom).isTrue() | ||
assertThat(sut.numberOfSelectRooms).isEqualTo(0) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but maybe we could reuse the
rooms.filter
here for the.any
above and the.all
below instead of filtering the list 3 times? Since it'll be a small list (probably) maybe it's not worth it.