Fixed: The SearchFragmentTestForCustomApp was failing sometimes.

This commit is contained in:
MohitMaliFtechiz 2025-01-31 15:23:35 +05:30 committed by Kelson
parent 499ea74048
commit a9364d5881
2 changed files with 6 additions and 4 deletions

View File

@ -131,7 +131,7 @@ class SearchFragmentTestForCustomApp {
customMainActivity = it customMainActivity = it
} }
// test with a large ZIM file to properly test the scenario // test with a large ZIM file to properly test the scenario
downloadingZimFile = getDownloadingZimFile() downloadingZimFile = getDownloadingZimFileFromDataFolder()
getOkkHttpClientForTesting().newCall(downloadRequest()).execute().use { response -> getOkkHttpClientForTesting().newCall(downloadRequest()).execute().use { response ->
if (response.isSuccessful) { if (response.isSuccessful) {
response.body?.let { responseBody -> response.body?.let { responseBody ->
@ -147,7 +147,7 @@ class SearchFragmentTestForCustomApp {
UiThreadStatement.runOnUiThread { UiThreadStatement.runOnUiThread {
customMainActivity.navigate(customMainActivity.readerFragmentResId) customMainActivity.navigate(customMainActivity.readerFragmentResId)
} }
openZimFileInReaderWithAssetFileDescriptor(downloadingZimFile) openZimFileInReader(zimFile = downloadingZimFile)
openSearchWithQuery() openSearchWithQuery()
val searchTerm = "gard" val searchTerm = "gard"
val searchedItem = "Gardanta Spirito" val searchedItem = "Gardanta Spirito"

View File

@ -100,14 +100,16 @@ class SearchRobot {
} }
fun searchAndClickOnArticle(searchString: String) { fun searchAndClickOnArticle(searchString: String) {
// wait a bit to properly load the ZIM file in the reader // Wait a bit to properly load the ZIM file in the reader.
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong()) BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
openSearchScreen() openSearchScreen()
// Wait a bit to properly visible the search screen.
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
searchWithFrequentlyTypedWords(searchString) searchWithFrequentlyTypedWords(searchString)
clickOnSearchItemInSearchList() clickOnSearchItemInSearchList()
} }
fun clickOnSearchItemInSearchList() { private fun clickOnSearchItemInSearchList() {
testFlakyView({ testFlakyView({
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong()) BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_SEARCH_TEST.toLong())
Espresso.onView(ViewMatchers.withId(R.id.search_list)).perform( Espresso.onView(ViewMatchers.withId(R.id.search_list)).perform(