Skip to content

Commit

Permalink
fix: fixed wrong query in ConversationDAO to fetch all conversations (
Browse files Browse the repository at this point in the history
#2099)

* fix: fixed wrong query

* fixed tests
  • Loading branch information
gongracr authored Sep 28, 2023
1 parent 6adb534 commit d842f28
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ WHERE
OR (type IS 'ONE_ON_ONE' AND userDeleted = 1) -- show deleted 1:1 convos, to maintain prev, logic
)
AND (protocol IS 'PROTEUS' OR (protocol IS 'MLS' AND mls_group_state IS 'ESTABLISHED'))
AND archived = ?
AND (archived = 0 OR archived = :isArchived)
ORDER BY lastModifiedDate DESC, name IS NULL, name COLLATE NOCASE ASC;

selectAllConversations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.wire.kalium.persistence.dao.asset.AssetDAO
import com.wire.kalium.persistence.dao.asset.AssetEntity
import com.wire.kalium.persistence.dao.conversation.ConversationDAO
import com.wire.kalium.persistence.dao.conversation.ConversationEntity
import com.wire.kalium.persistence.dao.conversation.ConversationMapper
import com.wire.kalium.persistence.dao.conversation.ConversationViewEntity
import com.wire.kalium.persistence.dao.conversation.MLS_DEFAULT_LAST_KEY_MATERIAL_UPDATE_MILLI
import com.wire.kalium.persistence.dao.conversation.ProposalTimerEntity
Expand Down Expand Up @@ -820,7 +821,7 @@ class ConversationDAOTest : BaseDatabaseTest() {
}

@Test
fun givenConnectionRequestAndUserWithoutName_whenSelectingAllConversationDetails_thenShouldReturnConnectionRequest() = runTest {
fun givenConnectionRequestAndUserWithoutName_whenSelectingAllConversationDetails_thenShouldNotReturnConnectionRequest() = runTest {
val includeArchived = false
val conversationId = QualifiedIDEntity("connection-conversationId", "domain")
val conversation = conversationEntity1.copy(id = conversationId, type = ConversationEntity.Type.CONNECTION_PENDING)
Expand Down Expand Up @@ -861,6 +862,24 @@ class ConversationDAOTest : BaseDatabaseTest() {
}
}

@Test
fun givenLocalConversations_whenGettingAllArchivedAndNotArchivedConversations_thenShouldReturnThemAll() = runTest {
val includeArchived = true
conversationDAO.insertConversation(conversationEntity1.copy(archived = true))
conversationDAO.insertConversation(conversationEntity2.copy(archived = false))

userDAO.insertUser(user1)
userDAO.insertUser(user2)

memberDAO.insertMember(member1, conversationEntity1.id)
memberDAO.insertMember(member2, conversationEntity2.id)

val result = conversationDAO.getAllConversationDetails(includeArchived).first()

assertEquals(2, result.size)

}

@Test
fun givenObserveConversationList_whenAConversationHaveNullAsName_thenItIsIncluded() = runTest {
// given
Expand Down

0 comments on commit d842f28

Please sign in to comment.