Skip to content

Commit 7227a83

Browse files
authored
Merge pull request #7558 from vector-im/feature/bma/fix_search_tests
Fix search tests
2 parents c74445c + d07c6da commit 7227a83

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/search/SearchMessagesTest.kt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.matrix.android.sdk.session.search
1818

19+
import org.amshove.kluent.shouldBeEqualTo
1920
import org.junit.Assert.assertTrue
2021
import org.junit.FixMethodOrder
2122
import org.junit.Test
@@ -43,7 +44,7 @@ class SearchMessagesTest : InstrumentedTest {
4344
cryptoTestData.firstSession
4445
.searchService()
4546
.search(
46-
searchTerm = "lore",
47+
searchTerm = "lorem",
4748
limit = 10,
4849
includeProfile = true,
4950
afterLimit = 0,
@@ -61,7 +62,7 @@ class SearchMessagesTest : InstrumentedTest {
6162
cryptoTestData.firstSession
6263
.searchService()
6364
.search(
64-
searchTerm = "lore",
65+
searchTerm = "lorem",
6566
roomId = cryptoTestData.roomId,
6667
limit = 10,
6768
includeProfile = true,
@@ -73,7 +74,28 @@ class SearchMessagesTest : InstrumentedTest {
7374
}
7475
}
7576

76-
private fun doTest(block: suspend (CryptoTestData) -> SearchResult) = runCryptoTest(context()) { cryptoTestHelper, commonTestHelper ->
77+
@Test
78+
fun sendTextMessageAndSearchPartOfItIncompleteWord() {
79+
doTest(expectedNumberOfResult = 0) { cryptoTestData ->
80+
cryptoTestData.firstSession
81+
.searchService()
82+
.search(
83+
searchTerm = "lore", /* incomplete word */
84+
roomId = cryptoTestData.roomId,
85+
limit = 10,
86+
includeProfile = true,
87+
afterLimit = 0,
88+
beforeLimit = 10,
89+
orderByRecent = true,
90+
nextBatch = null
91+
)
92+
}
93+
}
94+
95+
private fun doTest(
96+
expectedNumberOfResult: Int = 2,
97+
block: suspend (CryptoTestData) -> SearchResult,
98+
) = runCryptoTest(context()) { cryptoTestHelper, commonTestHelper ->
7799
val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceInARoom(false)
78100
val aliceSession = cryptoTestData.firstSession
79101
val aliceRoomId = cryptoTestData.roomId
@@ -87,7 +109,7 @@ class SearchMessagesTest : InstrumentedTest {
87109

88110
val data = block.invoke(cryptoTestData)
89111

90-
assertTrue(data.results?.size == 2)
112+
data.results?.size shouldBeEqualTo expectedNumberOfResult
91113
assertTrue(
92114
data.results
93115
?.all {

0 commit comments

Comments
 (0)