misc(power level) : update tests following api change
This commit is contained in:
parent
541a1d29bd
commit
d26f21a53b
25 changed files with 475 additions and 637 deletions
|
|
@ -76,7 +76,7 @@ class UserProfilePresenter(
|
|||
roomId
|
||||
?.let { client.getRoom(it) }
|
||||
?.use { room ->
|
||||
room.roomPermissions().use(false){ perms -> perms.canCall()}
|
||||
room.roomPermissions().use(false) { perms -> perms.canCall() }
|
||||
}
|
||||
.orFalse()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import io.element.android.libraries.matrix.api.MatrixClient
|
|||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.encryption.identity.IdentityState
|
||||
import io.element.android.libraries.matrix.api.room.StateEventType
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import io.element.android.libraries.matrix.test.AN_EXCEPTION
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
|
|
@ -36,9 +37,11 @@ import io.element.android.libraries.matrix.test.A_USER_ID_2
|
|||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||
import io.element.android.libraries.matrix.test.encryption.FakeEncryptionService
|
||||
import io.element.android.libraries.matrix.test.room.FakeBaseRoom
|
||||
import io.element.android.libraries.matrix.test.room.powerlevels.FakeRoomPermissions
|
||||
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
||||
import io.element.android.tests.testutils.WarmUpRule
|
||||
import io.element.android.tests.testutils.lambda.any
|
||||
import io.element.android.tests.testutils.lambda.lambdaError
|
||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import io.element.android.tests.testutils.lambda.value
|
||||
import io.element.android.tests.testutils.test
|
||||
|
|
@ -89,15 +92,7 @@ class UserProfilePresenterTest {
|
|||
@Test
|
||||
fun `present - canCall is false when canUserJoinCall returns false`() {
|
||||
testCanCall(
|
||||
canUserJoinCallResult = Result.success(false),
|
||||
expectedResult = false,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - canCall is false when canUserJoinCall fails`() {
|
||||
testCanCall(
|
||||
canUserJoinCallResult = Result.failure(AN_EXCEPTION),
|
||||
canUserJoinCall = false,
|
||||
expectedResult = false,
|
||||
)
|
||||
}
|
||||
|
|
@ -128,7 +123,7 @@ class UserProfilePresenterTest {
|
|||
|
||||
private fun testCanCall(
|
||||
isElementCallAvailable: Boolean = true,
|
||||
canUserJoinCallResult: Result<Boolean> = Result.success(true),
|
||||
canUserJoinCall: Boolean = true,
|
||||
dmRoom: RoomId? = A_ROOM_ID,
|
||||
canFindRoom: Boolean = true,
|
||||
expectedResult: Boolean,
|
||||
|
|
@ -136,7 +131,14 @@ class UserProfilePresenterTest {
|
|||
checkThatRoomIsDestroyed: Boolean = false,
|
||||
) = runTest {
|
||||
val room = FakeBaseRoom(
|
||||
canUserJoinCallResult = { canUserJoinCallResult },
|
||||
roomPermissions = FakeRoomPermissions(
|
||||
canSendState = { type ->
|
||||
when (type) {
|
||||
StateEventType.CALL_MEMBER -> canUserJoinCall
|
||||
else -> lambdaError()
|
||||
}
|
||||
}
|
||||
),
|
||||
)
|
||||
val client = createFakeMatrixClient().apply {
|
||||
if (canFindRoom) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue