-
Notifications
You must be signed in to change notification settings - Fork 8
feat(android.FavoritesView): Display toast when first time on favorites & has old pinned routes #1189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(android.FavoritesView): Display toast when first time on favorites & has old pinned routes #1189
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cdd1960
wip(android.FavoritesView): Toast on first open after promo
KaylaBrady 103af5a
feat(android.FavoritesView): Show toast on first land after promo
KaylaBrady 8546813
chore: add placeholder translations
KaylaBrady 0a431be
fix(android): revert version to 1.2.7
KaylaBrady 226f2e8
fix(translations): French appostrophe
KaylaBrady 997d2bd
fix(FavoritesViewModelTest): Fix broken tests
KaylaBrady 1df9c12
style: run pre-commit after rebase
KaylaBrady 1b9f880
fix: actually fix tests
KaylaBrady 31e42a9
fix broken ios tests
KaylaBrady 213c6a0
fix(FavoritesViewModelTest.updatesLocation): Stabilize flaky test
KaylaBrady File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
79 changes: 79 additions & 0 deletions
79
androidApp/src/androidTest/java/com/mbta/tid/mbta_app/android/favorites/FavoritesViewTest.kt
This file contains hidden or 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,79 @@ | ||
| package com.mbta.tid.mbta_app.android.favorites | ||
|
|
||
| import androidx.compose.ui.test.junit4.createComposeRule | ||
| import androidx.compose.ui.test.onNodeWithText | ||
| import androidx.compose.ui.test.performClick | ||
| import com.mbta.tid.mbta_app.android.component.ErrorBannerViewModel | ||
| import com.mbta.tid.mbta_app.model.ObjectCollectionBuilder | ||
| import com.mbta.tid.mbta_app.model.response.AlertsStreamDataResponse | ||
| import com.mbta.tid.mbta_app.model.response.GlobalResponse | ||
| import com.mbta.tid.mbta_app.repositories.MockErrorBannerStateRepository | ||
| import com.mbta.tid.mbta_app.viewModel.FavoritesViewModel | ||
| import com.mbta.tid.mbta_app.viewModel.IToastViewModel | ||
| import com.mbta.tid.mbta_app.viewModel.MockFavoritesViewModel | ||
| import com.mbta.tid.mbta_app.viewModel.ToastViewModel | ||
| import dev.mokkery.MockMode | ||
| import dev.mokkery.matcher.any | ||
| import dev.mokkery.mock | ||
| import dev.mokkery.resetCalls | ||
| import dev.mokkery.verify | ||
| import dev.mokkery.verify.VerifyMode | ||
| import kotlinx.coroutines.runBlocking | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
|
|
||
| class FavoritesViewTest { | ||
|
|
||
| @get:Rule val composeTestRule = createComposeRule() | ||
|
|
||
| @Test | ||
| fun testShowsToast() = runBlocking { | ||
| val favoritesVM = | ||
| MockFavoritesViewModel( | ||
| initialState = | ||
| FavoritesViewModel.State( | ||
| false, | ||
| emptySet(), | ||
| true, | ||
| emptyList(), | ||
| emptyList(), | ||
| null, | ||
| ) | ||
| ) | ||
| val toastVM = mock<IToastViewModel>(MockMode.autofill) | ||
|
|
||
| val objects = ObjectCollectionBuilder() | ||
|
|
||
| composeTestRule.setContent { | ||
| FavoritesView( | ||
| openSheetRoute = {}, | ||
| favoritesViewModel = favoritesVM, | ||
| errorBannerViewModel = | ||
| ErrorBannerViewModel(errorRepository = MockErrorBannerStateRepository()), | ||
| toastViewModel = toastVM, | ||
| alertData = AlertsStreamDataResponse(objects), | ||
| globalResponse = GlobalResponse(objects), | ||
| targetLocation = null, | ||
| setLastLocation = { _ -> }, | ||
| setIsTargeting = { _ -> }, | ||
| ) | ||
| } | ||
|
|
||
| verify(VerifyMode.exhaustiveOrder) { | ||
| toastVM.showToast( | ||
| ToastViewModel.Toast( | ||
| "Favorite stops replaces the prior starred routes feature.", | ||
| ToastViewModel.Duration.Indefinite, | ||
| any(), | ||
| null, | ||
| null, | ||
| ) | ||
| ) | ||
| } | ||
| resetCalls(toastVM) | ||
|
|
||
| composeTestRule.onNodeWithText("Add stops").performClick() | ||
|
|
||
| verify(VerifyMode.exhaustiveOrder) { toastVM.hideToast() } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decreasing the spacing here b/c otherwise the toast blocks the "Add stops" button. Confirmed this change with design.