Skip to content

Commit

Permalink
fix: Show alert message after conversation becomes degraded RC (#2501)
Browse files Browse the repository at this point in the history
  • Loading branch information
borichellow authored and github-actions[bot] committed Feb 15, 2024
1 parent dba769d commit ca6aafc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,7 @@ internal class MLSConversationsVerificationStatusesHandlerImpl(
)

persistMessage(conversationDegradedMessage)

conversationRepository.setDegradedConversationNotifiedFlag(conversationId, updatedStatus == VerificationStatus.DEGRADED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class MLSConversationsVerificationStatusesHandlerTest {
.suspendFunction(arrangement.persistMessageUseCase::invoke)
.with(any())
.wasNotInvoked()

verify(arrangement.conversationRepository)
.suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag)
.with(any(), any())
.wasNotInvoked()
}

@Test
Expand All @@ -89,6 +94,11 @@ class MLSConversationsVerificationStatusesHandlerTest {
.suspendFunction(arrangement.persistMessageUseCase::invoke)
.with(any())
.wasNotInvoked()

verify(arrangement.conversationRepository)
.suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag)
.with(any(), any())
.wasNotInvoked()
}

@Test
Expand Down Expand Up @@ -116,6 +126,11 @@ class MLSConversationsVerificationStatusesHandlerTest {
.suspendFunction(arrangement.persistMessageUseCase::invoke)
.with(anyInstanceOf(Message.System::class))
.wasInvoked(once)

verify(arrangement.conversationRepository)
.suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag)
.with(any(), eq(true))
.wasInvoked(once)
}

@Test
Expand All @@ -142,6 +157,11 @@ class MLSConversationsVerificationStatusesHandlerTest {
.suspendFunction(arrangement.persistMessageUseCase::invoke)
.with(any())
.wasNotInvoked()

verify(arrangement.conversationRepository)
.suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag)
.with(any(), any())
.wasNotInvoked()
}

@Test
Expand Down Expand Up @@ -169,6 +189,11 @@ class MLSConversationsVerificationStatusesHandlerTest {
.suspendFunction(arrangement.persistMessageUseCase::invoke)
.with(anyInstanceOf(Message.System::class))
.wasInvoked(once)

verify(arrangement.conversationRepository)
.suspendFunction(arrangement.conversationRepository::setDegradedConversationNotifiedFlag)
.with(any(), eq(false))
.wasInvoked(once)
}

private fun arrange(block: Arrangement.() -> Unit) = Arrangement(block).arrange()
Expand All @@ -182,6 +207,7 @@ class MLSConversationsVerificationStatusesHandlerTest {
init {
withUpdateVerificationStatus(Either.Right(Unit))
withPersistingMessage(Either.Right(Unit))
withSetDegradedConversationNotifiedFlag(Either.Right(Unit))
}

fun arrange() = block().run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ internal interface ConversationRepositoryArrangement {
.whenInvokedWith(any(), any())
.thenReturn(result)
}

fun withSetDegradedConversationNotifiedFlag(result: Either<CoreFailure, Unit>)
}

internal open class ConversationRepositoryArrangementImpl : ConversationRepositoryArrangement {
Expand Down Expand Up @@ -252,4 +254,11 @@ internal open class ConversationRepositoryArrangementImpl : ConversationReposito
.thenReturn(result)
}

override fun withSetDegradedConversationNotifiedFlag(result: Either<CoreFailure, Unit>) {
given(conversationRepository)
.suspendFunction(conversationRepository::setDegradedConversationNotifiedFlag)
.whenInvokedWith(any())
.thenReturn(result)
}

}

0 comments on commit ca6aafc

Please sign in to comment.