mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 12:42:56 -04:00
Refactored the OpenSearchItemTest unit test.
* Fixed: ZimHostFragmentTest UI test.
This commit is contained in:
parent
7b03c5da3e
commit
8b446a5200
@ -162,7 +162,7 @@ class ZimHostFragmentTest {
|
||||
zimHost {
|
||||
refreshLibraryList(composeTestRule)
|
||||
assertZimFilesLoaded(composeTestRule)
|
||||
openZimHostFragment(kiwixMainActivity as CoreMainActivity)
|
||||
openZimHostFragment(kiwixMainActivity as CoreMainActivity, composeTestRule)
|
||||
|
||||
// Check if server is already started
|
||||
stopServerIfAlreadyStarted(composeTestRule)
|
||||
|
@ -31,9 +31,9 @@ import applyWithViewHierarchyPrinting
|
||||
import com.adevinta.android.barista.interaction.BaristaSleepInteractions
|
||||
import junit.framework.AssertionFailedError
|
||||
import org.kiwix.kiwixmobile.BaseRobot
|
||||
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
||||
import org.kiwix.kiwixmobile.core.R
|
||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||
import org.kiwix.kiwixmobile.core.main.LEFT_DRAWER_ZIM_HOST_ITEM_TESTING_TAG
|
||||
import org.kiwix.kiwixmobile.core.ui.components.TOOLBAR_TITLE_TESTING_TAG
|
||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_NATURAL_BUTTON_TESTING_TAG
|
||||
import org.kiwix.kiwixmobile.core.utils.dialog.ALERT_DIALOG_TITLE_TEXT_TESTING_TAG
|
||||
@ -69,9 +69,17 @@ class ZimHostRobot : BaseRobot() {
|
||||
zimFileNodes.assertCountEquals(2)
|
||||
}
|
||||
|
||||
fun openZimHostFragment(coreMainActivity: CoreMainActivity) {
|
||||
fun openZimHostFragment(
|
||||
coreMainActivity: CoreMainActivity,
|
||||
composeTestRule: ComposeContentTestRule
|
||||
) {
|
||||
openDrawer(coreMainActivity)
|
||||
clickOn(TextId(R.string.menu_wifi_hotspot))
|
||||
testFlakyView({
|
||||
composeTestRule.apply {
|
||||
waitForIdle()
|
||||
onNodeWithTag(LEFT_DRAWER_ZIM_HOST_ITEM_TESTING_TAG).performClick()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun clickOnTestZim(composeTestRule: ComposeContentTestRule) {
|
||||
|
@ -19,7 +19,7 @@
|
||||
package org.kiwix.kiwixmobile.core.search.viewmodel.effects
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.NavOptions
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkConstructor
|
||||
@ -45,7 +45,10 @@ internal class OpenSearchItemTest {
|
||||
} returns intent
|
||||
OpenSearchItem(searchListItem, false).invokeWith(activity)
|
||||
verify {
|
||||
activity.navigate(activity.readerFragmentResId, any<Bundle>())
|
||||
activity.navigate(
|
||||
"${activity.readerFragmentRoute}?searchItemTitle=searchItemTitle",
|
||||
any<NavOptions>()
|
||||
)
|
||||
activity.setNavigationResultOnCurrent(
|
||||
SearchItemToOpen(searchListItem.value, false, ZimFileReader.CONTENT_PREFIX),
|
||||
TAG_FILE_SEARCHED
|
||||
@ -65,7 +68,10 @@ internal class OpenSearchItemTest {
|
||||
} returns intent
|
||||
OpenSearchItem(searchListItem, true).invokeWith(activity)
|
||||
verify {
|
||||
activity.navigate(activity.readerFragmentResId, any<Bundle>())
|
||||
activity.navigate(
|
||||
"${activity.readerFragmentRoute}?searchItemTitle=searchItemTitle",
|
||||
any<NavOptions>()
|
||||
)
|
||||
activity.setNavigationResultOnCurrent(
|
||||
SearchItemToOpen(searchListItem.value, true, ZimFileReader.CONTENT_PREFIX),
|
||||
TAG_FILE_SEARCHED
|
||||
|
Loading…
x
Reference in New Issue
Block a user