-
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.
happy path tests for the primary untested views. (#385)
* happy path tests for the primary untested views.
- Loading branch information
1 parent
71dbd52
commit 0ac66d5
Showing
15 changed files
with
1,337 additions
and
45 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
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
112 changes: 112 additions & 0 deletions
112
...pp/src/androidTest/java/com/mbta/tid/mbta_app/android/nearbyTransit/NearbyLineViewTest.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,112 @@ | ||
package com.mbta.tid.mbta_app.android.nearbyTransit | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import com.mbta.tid.mbta_app.model.ObjectCollectionBuilder | ||
import com.mbta.tid.mbta_app.model.PatternsByStop | ||
import com.mbta.tid.mbta_app.model.Prediction | ||
import com.mbta.tid.mbta_app.model.RealtimePatterns | ||
import com.mbta.tid.mbta_app.model.RouteType | ||
import com.mbta.tid.mbta_app.model.StopsAssociated | ||
import com.mbta.tid.mbta_app.model.UpcomingTrip | ||
import kotlin.time.Duration.Companion.minutes | ||
import kotlinx.datetime.Instant | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class NearbyLineViewTest { | ||
val builder = ObjectCollectionBuilder() | ||
val now = Instant.fromEpochMilliseconds(System.currentTimeMillis()) | ||
val route = | ||
builder.route { | ||
id = "route_1" | ||
type = RouteType.BUS | ||
directionNames = listOf("North", "South") | ||
directionDestinations = listOf("Downtown", "Uptown") | ||
longName = "Sample Route Long Name" | ||
shortName = "Sample Route" | ||
lineId = "line_1" | ||
routePatternIds = mutableListOf("pattern_1", "pattern_2") | ||
} | ||
val line = | ||
builder.line { | ||
id = "line_1" | ||
color = "FF0000" | ||
longName = "Sample Line Long Name" | ||
shortName = "Sample Line" | ||
textColor = "000000" | ||
} | ||
val routePattern = | ||
builder.routePattern(route) { | ||
id = "pattern_1" | ||
directionId = 0 | ||
name = "Sample Route Pattern" | ||
routeId = "route_1" | ||
representativeTripId = "trip_1" | ||
} | ||
val stop = | ||
builder.stop { | ||
id = "stop_1" | ||
name = "Sample Stop" | ||
} | ||
val trip = | ||
builder.trip(routePattern) { | ||
id = "trip_1" | ||
headsign = "Sample Headsign" | ||
} | ||
|
||
val patternsByStop = | ||
listOf( | ||
PatternsByStop( | ||
route, | ||
stop, | ||
listOf( | ||
RealtimePatterns.ByHeadsign( | ||
route, | ||
"Sample Headsign", | ||
line, | ||
listOf(routePattern), | ||
listOf( | ||
UpcomingTrip( | ||
trip, | ||
Prediction( | ||
"prediction_1", | ||
now, | ||
now.plus(1.minutes), | ||
0, | ||
false, | ||
Prediction.ScheduleRelationship.Scheduled, | ||
null, | ||
1, | ||
route.id, | ||
stop.id, | ||
trip.id, | ||
null | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
||
@get:Rule val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testNearbyLineViewDisplaysCorrectly() { | ||
composeTestRule.setContent { | ||
NearbyLineView( | ||
nearbyLine = StopsAssociated.WithLine(line, listOf(route), patternsByStop), | ||
pinned = false, | ||
onPin = {}, | ||
now = now, | ||
onOpenStopDetails = { _, _ -> } | ||
) | ||
} | ||
composeTestRule.onNodeWithText("Sample Line Long Name").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Sample Stop").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Sample Headsign").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("ARR").assertIsDisplayed() | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
...pp/src/androidTest/java/com/mbta/tid/mbta_app/android/nearbyTransit/NearbyStopViewTest.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,106 @@ | ||
package com.mbta.tid.mbta_app.android.nearbyTransit | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import com.mbta.tid.mbta_app.model.ObjectCollectionBuilder | ||
import com.mbta.tid.mbta_app.model.PatternsByStop | ||
import com.mbta.tid.mbta_app.model.Prediction | ||
import com.mbta.tid.mbta_app.model.RealtimePatterns | ||
import com.mbta.tid.mbta_app.model.RouteType | ||
import com.mbta.tid.mbta_app.model.UpcomingTrip | ||
import kotlin.time.Duration.Companion.minutes | ||
import kotlinx.datetime.Instant | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class NearbyStopViewTest { | ||
val builder = ObjectCollectionBuilder() | ||
val now = Instant.fromEpochMilliseconds(System.currentTimeMillis()) | ||
val route = | ||
builder.route { | ||
id = "route_1" | ||
type = RouteType.BUS | ||
directionNames = listOf("North", "South") | ||
directionDestinations = listOf("Downtown", "Uptown") | ||
longName = "Sample Route Long Name" | ||
shortName = "Sample Route" | ||
lineId = "line_1" | ||
routePatternIds = mutableListOf("pattern_1", "pattern_2") | ||
} | ||
val line = | ||
builder.line { | ||
id = "line_1" | ||
longName = "Sample Line Long Name" | ||
shortName = "Sample Line" | ||
} | ||
val routePattern = | ||
builder.routePattern(route) { | ||
id = "pattern_1" | ||
directionId = 0 | ||
name = "Sample Route Pattern" | ||
routeId = "route_1" | ||
representativeTripId = "trip_1" | ||
} | ||
val stop = | ||
builder.stop { | ||
id = "stop_1" | ||
name = "Sample Stop" | ||
} | ||
val trip = | ||
builder.trip(routePattern) { | ||
id = "trip_1" | ||
headsign = "Sample Headsign" | ||
} | ||
|
||
val patternsByStop = | ||
PatternsByStop( | ||
route, | ||
stop, | ||
listOf( | ||
RealtimePatterns.ByHeadsign( | ||
route, | ||
"Sample Headsign", | ||
line, | ||
listOf(routePattern), | ||
listOf( | ||
UpcomingTrip( | ||
trip, | ||
Prediction( | ||
"prediction_1", | ||
now, | ||
now.plus(1.minutes), | ||
0, | ||
false, | ||
Prediction.ScheduleRelationship.Scheduled, | ||
null, | ||
1, | ||
route.id, | ||
stop.id, | ||
trip.id, | ||
null | ||
) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
|
||
@get:Rule val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testNearbyStopViewDisplaysCorrectly() { | ||
composeTestRule.setContent { | ||
NearbyStopView( | ||
patternsAtStop = patternsByStop, | ||
condenseHeadsignPredictions = false, | ||
now = now, | ||
onOpenStopDetails = { _, _ -> } | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithText("Sample Stop").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Sample Headsign").assertIsDisplayed() | ||
composeTestRule.onNodeWithText("ARR").assertIsDisplayed() | ||
} | ||
} |
Oops, something went wrong.