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: self clients list is not updated when a new client event is received (WPB-5791) #2290

Merged
merged 10 commits into from
Dec 7, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class ClientDataSource(
newClientEvent: Event.User.NewClient
): Either<CoreFailure, Unit> = wrapStorageRequest {
newClientDAO.insertNewClient(clientMapper.toInsertClientParam(selfUserID, newClientEvent))
MohamadJaara marked this conversation as resolved.
Show resolved Hide resolved
clientDAO.insertClient(clientMapper.toInsertClientParam(selfUserID, newClientEvent))
Copy link
Member

@mchenani mchenani Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between these two lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

different DB-tables where we save clients into.
NewClient table containse only self-user clients that was added and user wasn't informed about it yet. So it's used for informing user about new devices by the dialog (kinda "there is a new device, was it you?").

And the Client table - is a table for all the clients

}
MohamadJaara marked this conversation as resolved.
Show resolved Hide resolved

override suspend fun clearNewClients() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ class ClientRepositoryTest {

@Test
fun whenSavingNewClient_thenNewClientSaved() = runTest {
MohamadJaara marked this conversation as resolved.
Show resolved Hide resolved
val (arrangement, repository) = Arrangement().arrange()
val (arrangement, repository) = Arrangement()
.withInsertClient()
.arrange()

val newClientEvent = TestEvent.newClient()
val insertClientParam = MapperProvider.clientMapper().toInsertClientParam(selfUserId, newClientEvent)
Expand All @@ -411,6 +413,11 @@ class ClientRepositoryTest {
.suspendFunction(arrangement.newClientDAO::insertNewClient)
.with(eq(insertClientParam))
.wasInvoked(exactly = once)

verify(arrangement.clientDAO)
.suspendFunction(arrangement.clientDAO::insertClient)
.with(eq(insertClientParam))
.wasInvoked(exactly = once)
}

@Test
Expand Down Expand Up @@ -498,6 +505,13 @@ class ClientRepositoryTest {
.thenReturn(flowOf(result))
}

fun withInsertClient() = apply {
given(clientDAO)
.suspendFunction(clientDAO::insertClient)
.whenInvokedWith(any())
.thenReturn(Unit)
}

fun withSuccessfulResponse(expectedResponse: Map<UserIdDTO, List<SimpleClientResponse>>) = apply {
given(clientApi)
.suspendFunction(clientApi::listClientsOfUsers).whenInvokedWith(any()).then {
Expand Down
Loading