Skip to content
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

fix: Show alert message after conversation becomes degraded [WPB-6607] #2502

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}

}
Loading