-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/bundler/cyclonedx-cocoapods-1.4.1
- Loading branch information
Showing
43 changed files
with
1,590 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...oidTest/java/com/mbta/tid/mbta_app/android/nearbyTransit/NearbyTransitTabViewModelTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.mbta.tid.mbta_app.android.nearbyTransit | ||
|
||
import com.mbta.tid.mbta_app.model.ObjectCollectionBuilder | ||
import com.mbta.tid.mbta_app.model.PatternsByStop | ||
import com.mbta.tid.mbta_app.model.StopDetailsDepartures | ||
import com.mbta.tid.mbta_app.model.StopDetailsFilter | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
import org.junit.Test | ||
|
||
class NearbyTransitTabViewModelTest { | ||
|
||
@Test | ||
fun testSetStopDetailsFilter() { | ||
val vm = NearbyTransitTabViewModel() | ||
val newFilter = StopDetailsFilter("route_1", 1) | ||
|
||
assertNull(vm.stopDetailsFilter.value) | ||
|
||
vm.setStopDetailsFilter(newFilter) | ||
assertEquals(newFilter, vm.stopDetailsFilter.value) | ||
} | ||
|
||
@Test | ||
fun testSetStopDetailsDepartures() { | ||
val vm = NearbyTransitTabViewModel() | ||
val objectCollectionBuilder = ObjectCollectionBuilder() | ||
val route = objectCollectionBuilder.route {} | ||
val stop = objectCollectionBuilder.stop {} | ||
|
||
val departures = StopDetailsDepartures(listOf(PatternsByStop(route, stop, emptyList()))) | ||
|
||
assertNull(vm.stopDetailsDepartures.value) | ||
|
||
vm.setStopDetailsDepartures(departures) | ||
assertEquals(departures, vm.stopDetailsDepartures.value) | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
...src/androidTest/java/com/mbta/tid/mbta_app/android/onboarding/OnboardingScreenViewTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.mbta.tid.mbta_app.android.onboarding | ||
|
||
import android.location.Location | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.rule.GrantPermissionRule | ||
import com.mbta.tid.mbta_app.android.location.MockLocationDataManager | ||
import com.mbta.tid.mbta_app.model.OnboardingScreen | ||
import com.mbta.tid.mbta_app.repositories.MockSettingsRepository | ||
import com.mbta.tid.mbta_app.repositories.Settings | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class OnboardingScreenViewTest { | ||
@get:Rule val composeTestRule = createComposeRule() | ||
|
||
// We can't easily mock the permission request, so we grant the permission eagerly. | ||
@get:Rule | ||
val runtimePermissionRule = | ||
GrantPermissionRule.grant(android.Manifest.permission.ACCESS_FINE_LOCATION) | ||
|
||
@Test | ||
fun testLocationFlow() { | ||
var advanced = false | ||
val locationDataManager = MockLocationDataManager(Location("mock")) | ||
composeTestRule.setContent { | ||
OnboardingScreenView( | ||
screen = OnboardingScreen.Location, | ||
advance = { advanced = true }, | ||
locationDataManager = locationDataManager, | ||
) | ||
} | ||
|
||
composeTestRule | ||
.onNodeWithText( | ||
"We use your location to show you nearby transit options.", | ||
substring = true | ||
) | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Continue").performClick() | ||
|
||
composeTestRule.waitForIdle() | ||
assertTrue(advanced) | ||
} | ||
|
||
@Test | ||
fun testHideMapsFlow() { | ||
var savedSetting = false | ||
val settingsRepo = | ||
MockSettingsRepository( | ||
settings = mapOf(Settings.HideMaps to false), | ||
onSaveSettings = { | ||
assertEquals(mapOf(Settings.HideMaps to true), it) | ||
savedSetting = true | ||
} | ||
) | ||
var advanced = false | ||
composeTestRule.setContent { | ||
OnboardingScreenView( | ||
screen = OnboardingScreen.HideMaps, | ||
advance = { advanced = true }, | ||
locationDataManager = MockLocationDataManager(Location("mock")), | ||
settingsRepository = settingsRepo | ||
) | ||
} | ||
composeTestRule | ||
.onNodeWithText( | ||
"When using TalkBack, we can skip reading out maps to keep you focused on transit information." | ||
) | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Show maps").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Hide maps").performClick() | ||
|
||
composeTestRule.waitForIdle() | ||
assertTrue(savedSetting) | ||
assertTrue(advanced) | ||
} | ||
|
||
@Test | ||
fun testFeedbackFlow() { | ||
var advanced = false | ||
composeTestRule.setContent { | ||
OnboardingScreenView( | ||
screen = OnboardingScreen.Feedback, | ||
advance = { advanced = true }, | ||
locationDataManager = MockLocationDataManager(Location("mock")), | ||
) | ||
} | ||
composeTestRule | ||
.onNodeWithText( | ||
"MBTA Go is in the early stages! We want your feedback" + | ||
" as we continue making improvements and adding new features." | ||
) | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Get started").performClick() | ||
|
||
composeTestRule.waitForIdle() | ||
assertTrue(advanced) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.