Skip to content

Commit 66e06d7

Browse files
committed
Pinned event : add some tests
1 parent 5e47c98 commit 66e06d7

File tree

4 files changed

+231
-47
lines changed

4 files changed

+231
-47
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesStateProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ fun aUserEventPermissions(
144144
canRedactOther: Boolean = false,
145145
canSendMessage: Boolean = true,
146146
canSendReaction: Boolean = true,
147-
canPin: Boolean = false,
147+
canPinUnpin: Boolean = false,
148148
) = UserEventPermissions(
149149
canRedactOwn = canRedactOwn,
150150
canRedactOther = canRedactOther,
151151
canSendMessage = canSendMessage,
152152
canSendReaction = canSendReaction,
153-
canPinUnpin = canPin,
153+
canPinUnpin = canPinUnpin,
154154
)
155155

156156
fun aReactionSummaryState(

features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/MessagesPresenterTest.kt

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ class MessagesPresenterTest {
155155
canRedactOtherResult = { Result.success(true) },
156156
canUserJoinCallResult = { Result.success(true) },
157157
typingNoticeResult = { Result.success(Unit) },
158-
)
158+
canUserPinUnpinResult = { Result.success(true) },
159+
160+
)
159161
assertThat(room.markAsReadCalls).isEmpty()
160162
val presenter = createMessagesPresenter(matrixRoom = room)
161163
moleculeFlow(RecompositionMode.Immediate) {
@@ -175,7 +177,9 @@ class MessagesPresenterTest {
175177
canRedactOwnResult = { Result.success(true) },
176178
canRedactOtherResult = { Result.success(true) },
177179
typingNoticeResult = { Result.success(Unit) },
178-
).apply {
180+
canUserPinUnpinResult = { Result.success(true) },
181+
182+
).apply {
179183
givenRoomInfo(aRoomInfo(hasRoomCall = true))
180184
}
181185
val presenter = createMessagesPresenter(matrixRoom = room)
@@ -203,7 +207,9 @@ class MessagesPresenterTest {
203207
canRedactOtherResult = { Result.success(true) },
204208
canUserJoinCallResult = { Result.success(true) },
205209
typingNoticeResult = { Result.success(Unit) },
206-
)
210+
canUserPinUnpinResult = { Result.success(true) },
211+
212+
)
207213
val presenter = createMessagesPresenter(matrixRoom = room, coroutineDispatchers = coroutineDispatchers)
208214
moleculeFlow(RecompositionMode.Immediate) {
209215
presenter.present()
@@ -240,7 +246,9 @@ class MessagesPresenterTest {
240246
canRedactOtherResult = { Result.success(true) },
241247
canUserJoinCallResult = { Result.success(true) },
242248
typingNoticeResult = { Result.success(Unit) },
243-
)
249+
canUserPinUnpinResult = { Result.success(true) },
250+
251+
)
244252
val presenter = createMessagesPresenter(matrixRoom = room, coroutineDispatchers = coroutineDispatchers)
245253
moleculeFlow(RecompositionMode.Immediate) {
246254
presenter.present()
@@ -298,7 +306,9 @@ class MessagesPresenterTest {
298306
canRedactOtherResult = { Result.success(true) },
299307
canUserJoinCallResult = { Result.success(true) },
300308
typingNoticeResult = { Result.success(Unit) },
301-
)
309+
canUserPinUnpinResult = { Result.success(true) },
310+
311+
)
302312
val presenter = createMessagesPresenter(
303313
clipboardHelper = clipboardHelper,
304314
matrixRoom = matrixRoom,
@@ -487,7 +497,9 @@ class MessagesPresenterTest {
487497
canRedactOtherResult = { Result.success(true) },
488498
canUserJoinCallResult = { Result.success(true) },
489499
typingNoticeResult = { Result.success(Unit) },
490-
)
500+
canUserPinUnpinResult = { Result.success(true) },
501+
502+
)
491503

492504
val redactEventLambda = lambdaRecorder { _: EventId?, _: TransactionId?, _: String? -> Result.success(true) }
493505
liveTimeline.redactEventLambda = redactEventLambda
@@ -561,7 +573,9 @@ class MessagesPresenterTest {
561573
canRedactOtherResult = { Result.success(true) },
562574
canUserJoinCallResult = { Result.success(true) },
563575
typingNoticeResult = { Result.success(Unit) },
564-
)
576+
canUserPinUnpinResult = { Result.success(true) },
577+
578+
)
565579
val presenter = createMessagesPresenter(matrixRoom = room)
566580
moleculeFlow(RecompositionMode.Immediate) {
567581
presenter.present()
@@ -596,7 +610,9 @@ class MessagesPresenterTest {
596610
canRedactOtherResult = { Result.success(true) },
597611
canUserJoinCallResult = { Result.success(true) },
598612
typingNoticeResult = { Result.success(Unit) },
599-
)
613+
canUserPinUnpinResult = { Result.success(true) },
614+
615+
)
600616
val presenter = createMessagesPresenter(matrixRoom = room)
601617
moleculeFlow(RecompositionMode.Immediate) {
602618
presenter.present()
@@ -620,7 +636,9 @@ class MessagesPresenterTest {
620636
canRedactOtherResult = { Result.success(true) },
621637
canUserJoinCallResult = { Result.success(true) },
622638
typingNoticeResult = { Result.success(Unit) },
623-
)
639+
canUserPinUnpinResult = { Result.success(true) },
640+
641+
)
624642
val presenter = createMessagesPresenter(matrixRoom = room)
625643
moleculeFlow(RecompositionMode.Immediate) {
626644
presenter.present()
@@ -644,7 +662,9 @@ class MessagesPresenterTest {
644662
canRedactOtherResult = { Result.success(true) },
645663
canUserJoinCallResult = { Result.success(true) },
646664
typingNoticeResult = { Result.success(Unit) },
647-
)
665+
canUserPinUnpinResult = { Result.success(true) },
666+
667+
)
648668
room.givenRoomMembersState(
649669
MatrixRoomMembersState.Ready(
650670
persistentListOf(
@@ -679,7 +699,9 @@ class MessagesPresenterTest {
679699
canRedactOtherResult = { Result.success(true) },
680700
canUserJoinCallResult = { Result.success(true) },
681701
typingNoticeResult = { Result.success(Unit) },
682-
)
702+
canUserPinUnpinResult = { Result.success(true) },
703+
704+
)
683705
room.givenRoomMembersState(
684706
MatrixRoomMembersState.Error(
685707
failure = Throwable(),
@@ -715,7 +737,9 @@ class MessagesPresenterTest {
715737
canRedactOtherResult = { Result.success(true) },
716738
canUserJoinCallResult = { Result.success(true) },
717739
typingNoticeResult = { Result.success(Unit) },
718-
)
740+
canUserPinUnpinResult = { Result.success(true) },
741+
742+
)
719743
room.givenRoomMembersState(MatrixRoomMembersState.Unknown)
720744
val presenter = createMessagesPresenter(matrixRoom = room)
721745
moleculeFlow(RecompositionMode.Immediate) {
@@ -741,7 +765,9 @@ class MessagesPresenterTest {
741765
canRedactOtherResult = { Result.success(true) },
742766
canUserJoinCallResult = { Result.success(true) },
743767
typingNoticeResult = { Result.success(Unit) },
744-
)
768+
canUserPinUnpinResult = { Result.success(true) },
769+
770+
)
745771
room.givenRoomMembersState(
746772
MatrixRoomMembersState.Ready(
747773
persistentListOf(
@@ -781,7 +807,9 @@ class MessagesPresenterTest {
781807
canRedactOtherResult = { Result.success(true) },
782808
canUserJoinCallResult = { Result.success(true) },
783809
typingNoticeResult = { Result.success(Unit) },
784-
)
810+
canUserPinUnpinResult = { Result.success(true) },
811+
812+
)
785813
val presenter = createMessagesPresenter(matrixRoom = matrixRoom)
786814
moleculeFlow(RecompositionMode.Immediate) {
787815
presenter.present()
@@ -805,7 +833,9 @@ class MessagesPresenterTest {
805833
canRedactOtherResult = { Result.success(true) },
806834
canUserJoinCallResult = { Result.success(true) },
807835
typingNoticeResult = { Result.success(Unit) },
808-
)
836+
canUserPinUnpinResult = { Result.success(true) },
837+
838+
)
809839
val presenter = createMessagesPresenter(matrixRoom = matrixRoom)
810840
moleculeFlow(RecompositionMode.Immediate) {
811841
presenter.present()
@@ -826,7 +856,8 @@ class MessagesPresenterTest {
826856
canRedactOtherResult = { Result.success(false) },
827857
canUserJoinCallResult = { Result.success(true) },
828858
typingNoticeResult = { Result.success(Unit) },
829-
)
859+
canUserPinUnpinResult = { Result.success(true) },
860+
)
830861
val presenter = createMessagesPresenter(matrixRoom = matrixRoom)
831862
moleculeFlow(RecompositionMode.Immediate) {
832863
presenter.present()
@@ -846,7 +877,8 @@ class MessagesPresenterTest {
846877
canRedactOwnResult = { Result.success(false) },
847878
canUserJoinCallResult = { Result.success(true) },
848879
typingNoticeResult = { Result.success(Unit) },
849-
)
880+
canUserPinUnpinResult = { Result.success(true) },
881+
)
850882
val presenter = createMessagesPresenter(matrixRoom = matrixRoom)
851883
moleculeFlow(RecompositionMode.Immediate) {
852884
presenter.present()
@@ -892,6 +924,7 @@ class MessagesPresenterTest {
892924
canRedactOtherResult = { Result.success(true) },
893925
canUserJoinCallResult = { Result.success(true) },
894926
typingNoticeResult = { Result.success(Unit) },
927+
canUserPinUnpinResult = { Result.success(true) },
895928
).apply {
896929
givenRoomInfo(aRoomInfo(id = roomId, name = ""))
897930
},
@@ -959,7 +992,11 @@ class MessagesPresenterTest {
959992
}
960993
}
961994
val featureFlagService = FakeFeatureFlagService()
962-
val actionListPresenter = ActionListPresenter(appPreferencesStore = appPreferencesStore, featureFlagsService = featureFlagService)
995+
val actionListPresenter = ActionListPresenter(
996+
appPreferencesStore = appPreferencesStore,
997+
featureFlagsService = featureFlagService,
998+
room = matrixRoom,
999+
)
9631000
val typingNotificationPresenter = TypingNotificationPresenter(
9641001
room = matrixRoom,
9651002
sessionPreferencesStore = sessionPreferencesStore,

0 commit comments

Comments
 (0)