Skip to content

Commit

Permalink
chore: fix the test not working on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Wylwi committed Dec 19, 2024
1 parent 1333b9c commit 0158762
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ch.hikemate.app.ui.auth.SignInWithEmailScreen
import ch.hikemate.app.ui.map.HikeDetailScreen
import ch.hikemate.app.ui.map.MapScreen
import ch.hikemate.app.ui.map.RunHikeScreen
import ch.hikemate.app.ui.map.ZoomMapButton
import ch.hikemate.app.ui.navigation.Screen
import ch.hikemate.app.utils.LocationUtils
import ch.hikemate.app.utils.MapUtils
Expand Down Expand Up @@ -84,7 +85,15 @@ class EndToEndTest4 {
mockkObject(LocationUtils)
mockkObject(MapUtils)
every { LocationUtils.hasLocationPermission(any()) } returns true
every { MapUtils.centerMapOnLocation(any(), any(), any()) } returns Unit
every { LocationUtils.getUserLocation(any(), any(), any(), any()) } answers
{
val locCallback = arg<(Location?) -> Unit>(1)
locCallback(
Location("gps").apply {
latitude = 46.5775927207486
longitude = 6.551607112518172
})
}
every {
LocationUtils.onLocationPermissionsUpdated(
any(), any(), any(), any<LocationCallback>(), any(), any())
Expand Down Expand Up @@ -169,6 +178,22 @@ class EndToEndTest4 {

// ---- Navigate to a hike's details screen ----

composeTestRule.onNodeWithTag(MapScreen.TEST_TAG_CENTER_MAP_BUTTON).performClick()

composeTestRule.waitForIdle()

// We want to zoom in to be sure of the selected hike
composeTestRule.onNodeWithTag(ZoomMapButton.ZOOM_IN_BUTTON).performClick()
Thread.sleep(1000)
composeTestRule.onNodeWithTag(ZoomMapButton.ZOOM_IN_BUTTON).performClick()
Thread.sleep(1000)
composeTestRule.onNodeWithTag(ZoomMapButton.ZOOM_IN_BUTTON).performClick()
Thread.sleep(1000)
composeTestRule.onNodeWithTag(ZoomMapButton.ZOOM_IN_BUTTON).performClick()
Thread.sleep(1000)
composeTestRule.onNodeWithTag(ZoomMapButton.ZOOM_IN_BUTTON).performClick()
Thread.sleep(1000)

composeTestRule
.onNodeWithTag(MapScreen.TEST_TAG_SEARCH_BUTTON)
.assertIsDisplayed()
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/ch/hikemate/app/ui/map/RunHikeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ private fun parseLocationUpdate(
return Triple(null, null, null)
}

Log.d(LOG_TAG, "Location: ${locationResult.lastLocation}")

val loc = locationResult.lastLocation!!
val routeProjectionResponse =
LocationUtils.projectLocationOnHike(LatLong(loc.latitude, loc.longitude), hike)
Expand Down

0 comments on commit 0158762

Please sign in to comment.