Refactored the GetContentShortcutTest test according to compose UI.

This commit is contained in:
MohitMaliFtechiz 2025-04-15 13:41:00 +05:30
parent 12e17e4d87
commit 7764a6a207
3 changed files with 23 additions and 10 deletions

View File

@ -38,6 +38,7 @@ import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.Findable.ViewId
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.R.string
import org.kiwix.kiwixmobile.core.page.SEARCH_ICON_TESTING_TAG
import org.kiwix.kiwixmobile.language.composables.LANGUAGE_ITEM_CHECKBOX_TESTING_TAG
import org.kiwix.kiwixmobile.testutils.TestUtils

View File

@ -18,23 +18,35 @@
package org.kiwix.kiwixmobile.page.history
import androidx.compose.ui.test.assertTextEquals
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import applyWithViewHierarchyPrinting
import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions.assertDisplayed
import org.kiwix.kiwixmobile.BaseRobot
import org.kiwix.kiwixmobile.Findable.StringId.ContentDesc
import org.kiwix.kiwixmobile.Findable.StringId.TextId
import org.kiwix.kiwixmobile.core.R
import org.kiwix.kiwixmobile.core.page.DELETE_MENU_ICON_TESTING_TAG
import org.kiwix.kiwixmobile.core.page.SWITCH_TEXT_TESTING_TAG
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
fun history(func: HistoryRobot.() -> Unit) = HistoryRobot().applyWithViewHierarchyPrinting(func)
class HistoryRobot : BaseRobot() {
fun assertHistoryDisplayed() {
assertDisplayed(R.string.history_from_current_book)
fun assertHistoryDisplayed(composeTestRule: ComposeTestRule) {
composeTestRule.apply {
waitForIdle()
onNodeWithTag(SWITCH_TEXT_TESTING_TAG)
.assertTextEquals(context.getString(R.string.history_from_current_book))
}
}
fun clickOnTrashIcon() {
clickOn(ContentDesc(R.string.pref_clear_all_history_title))
fun clickOnTrashIcon(composeTestRule: ComposeTestRule) {
composeTestRule.apply {
waitForIdle()
onNodeWithTag(DELETE_MENU_ICON_TESTING_TAG)
.performClick()
}
}
fun assertDeleteHistoryDialogDisplayed() {

View File

@ -123,13 +123,13 @@ class GetContentShortcutTest {
}
}
clickBookmarksOnNavDrawer {
assertBookMarksDisplayed()
clickOnTrashIcon()
assertBookMarksDisplayed(composeTestRule)
clickOnTrashIcon(composeTestRule)
assertDeleteBookmarksDialogDisplayed()
}
clickHistoryOnSideNav {
assertHistoryDisplayed()
clickOnTrashIcon()
assertHistoryDisplayed(composeTestRule)
clickOnTrashIcon(composeTestRule)
assertDeleteHistoryDialogDisplayed()
}
clickHostBooksOnSideNav(ZimHostRobot::assertMenuWifiHotspotDiplayed)