-
Notifications
You must be signed in to change notification settings - Fork 232
Render blocked user data (behind a disabled feature flag) #2930
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
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
643acb1
Render data of blocked users (behind deactivated feature flag).
bmarty 48b58b4
Add UI test on BlockedUserView
bmarty b2c8299
Remove obsolete comment.
bmarty 6c3afb3
Changelog
bmarty e18394a
Update screenshots
21802be
Fix changelog name
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a feature flag ShowBlockedUsersDetails, disabled by default to render display name and avatar of blocked users in the blocked users list. |
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
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
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
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
109 changes: 109 additions & 0 deletions
109
...t/kotlin/io/element/android/features/preferences/impl/blockedusers/BlockedUserViewTest.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,109 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.features.preferences.impl.blockedusers | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import io.element.android.features.preferences.impl.R | ||
import io.element.android.libraries.architecture.AsyncAction | ||
import io.element.android.libraries.matrix.ui.components.aMatrixUserList | ||
import io.element.android.libraries.ui.strings.CommonStrings | ||
import io.element.android.tests.testutils.EnsureNeverCalled | ||
import io.element.android.tests.testutils.EventsRecorder | ||
import io.element.android.tests.testutils.clickOn | ||
import io.element.android.tests.testutils.ensureCalledOnce | ||
import io.element.android.tests.testutils.pressBack | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.TestRule | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class BlockedUserViewTest { | ||
@get:Rule | ||
val rule = createAndroidComposeRule<ComponentActivity>() | ||
|
||
@Test | ||
fun `clicking on back invokes back callback`() { | ||
val eventsRecorder = EventsRecorder<BlockedUsersEvents>(expectEvents = false) | ||
ensureCalledOnce { callback -> | ||
rule.setLogoutView( | ||
aBlockedUsersState( | ||
eventSink = eventsRecorder | ||
), | ||
onBackClicked = callback, | ||
) | ||
rule.pressBack() | ||
} | ||
} | ||
|
||
@Test | ||
fun `clicking on a user emits the expected Event`() { | ||
val eventsRecorder = EventsRecorder<BlockedUsersEvents>() | ||
val userList = aMatrixUserList() | ||
rule.setLogoutView( | ||
aBlockedUsersState( | ||
blockedUsers = userList, | ||
eventSink = eventsRecorder | ||
), | ||
) | ||
rule.onNodeWithText(userList.first().displayName.orEmpty()).performClick() | ||
eventsRecorder.assertSingle(BlockedUsersEvents.Unblock(userList.first().userId)) | ||
} | ||
|
||
@Test | ||
fun `clicking on cancel sends a BlockedUsersEvents`() { | ||
val eventsRecorder = EventsRecorder<BlockedUsersEvents>() | ||
rule.setLogoutView( | ||
aBlockedUsersState( | ||
unblockUserAction = AsyncAction.Confirming, | ||
eventSink = eventsRecorder | ||
), | ||
) | ||
rule.clickOn(CommonStrings.action_cancel) | ||
eventsRecorder.assertSingle(BlockedUsersEvents.Cancel) | ||
} | ||
|
||
@Test | ||
fun `clicking on confirm sends a BlockedUsersEvents`() { | ||
val eventsRecorder = EventsRecorder<BlockedUsersEvents>() | ||
rule.setLogoutView( | ||
aBlockedUsersState( | ||
unblockUserAction = AsyncAction.Confirming, | ||
eventSink = eventsRecorder | ||
), | ||
) | ||
rule.clickOn(R.string.screen_blocked_users_unblock_alert_action) | ||
eventsRecorder.assertSingle(BlockedUsersEvents.ConfirmUnblock) | ||
} | ||
} | ||
|
||
private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setLogoutView( | ||
state: BlockedUsersState, | ||
onBackClicked: () -> Unit = EnsureNeverCalled(), | ||
) { | ||
setContent { | ||
BlockedUsersView( | ||
state = state, | ||
onBackPressed = onBackClicked, | ||
) | ||
} | ||
} |
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
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
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
4 changes: 2 additions & 2 deletions
4
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_0,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_1,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_2,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_3,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_4,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_5,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...users_BlockedUsersView_null_BlockedUsersView-Day-3_4_null_6,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ers_BlockedUsersView_null_BlockedUsersView-Night-3_5_null_0,NEXUS_5,1.0,en].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
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.
1.misc
? Should we use2930.misc
instead?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.
oups, good catch 21802be