From 1debc8269c0a7e8f72f56db76e191e274bcb95ab Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Wed, 26 Mar 2025 21:24:42 +0530 Subject: [PATCH] Fixed: `TopLevelDestinationTest`, and `GetContentShortcutTest` test cases which was failing due to migration to jetpack. --- .../java/org/kiwix/kiwixmobile/help/HelpRobot.kt | 12 ++++++++---- .../kiwixmobile/main/TopLevelDestinationTest.kt | 2 +- .../kiwixmobile/shortcuts/GetContentShortcutTest.kt | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt index a9a07687c..f1991e2c5 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/help/HelpRobot.kt @@ -27,18 +27,22 @@ import androidx.test.espresso.Espresso.onView import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.matcher.ViewMatchers.withText import org.kiwix.kiwixmobile.BaseRobot -import org.kiwix.kiwixmobile.Findable.ViewId -import org.kiwix.kiwixmobile.core.R.id +import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.core.R.string import org.kiwix.kiwixmobile.core.help.HELP_SCREEN_ITEM_DESCRIPTION_TESTING_TAG import org.kiwix.kiwixmobile.core.help.HELP_SCREEN_ITEM_TITLE_TESTING_TAG +import org.kiwix.kiwixmobile.core.ui.components.TOOLBAR_TITLE_TESTING_TAG import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView fun help(func: HelpRobot.() -> Unit) = HelpRobot().apply(func) class HelpRobot : BaseRobot() { - fun assertToolbarDisplayed() { - isVisible(ViewId(id.toolbar)) + fun assertToolbarDisplayed(composeTestRule: ComposeContentTestRule) { + composeTestRule.apply { + waitForIdle() + onNodeWithTag(TOOLBAR_TITLE_TESTING_TAG) + .assertTextEquals(context.getString(R.string.menu_help)) + } } fun clickOnWhatDoesKiwixDo(composeTestRule: ComposeContentTestRule) { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt index 07f24ba55..9b60a862c 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/main/TopLevelDestinationTest.kt @@ -130,7 +130,7 @@ class TopLevelDestinationTest : BaseActivityTest() { } clickHostBooksOnSideNav(ZimHostRobot::assertMenuWifiHotspotDiplayed) clickSettingsOnSideNav(SettingsRobot::assertMenuSettingsDisplayed) - clickHelpOnSideNav(HelpRobot::assertToolbarDisplayed) + clickHelpOnSideNav { HelpRobot().assertToolbarDisplayed(composeTestRule) } clickSupportKiwixOnSideNav() pressBack() } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/shortcuts/GetContentShortcutTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/shortcuts/GetContentShortcutTest.kt index 800b8ef16..e50f27be0 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/shortcuts/GetContentShortcutTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/shortcuts/GetContentShortcutTest.kt @@ -134,7 +134,7 @@ class GetContentShortcutTest { } clickHostBooksOnSideNav(ZimHostRobot::assertMenuWifiHotspotDiplayed) clickSettingsOnSideNav(SettingsRobot::assertMenuSettingsDisplayed) - clickHelpOnSideNav(HelpRobot::assertToolbarDisplayed) + clickHelpOnSideNav { HelpRobot().assertToolbarDisplayed(composeTestRule) } clickSupportKiwixOnSideNav() pressBack() }