From d3c7fea02f431b7a2743a365585e9654a738c88e Mon Sep 17 00:00:00 2001 From: Leigh Douglas Date: Thu, 21 Nov 2024 15:56:23 -0500 Subject: [PATCH] [no-jira] Fix pledge redemption notifications not working, update tests (#2175) --- .../kickstarter/viewmodels/SurveyResponseViewModel.kt | 4 ++-- .../com/kickstarter/viewmodels/DeepLinkViewModelTest.kt | 6 +++--- .../viewmodels/SurveyResponseViewModelTest.kt | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/kickstarter/viewmodels/SurveyResponseViewModel.kt b/app/src/main/java/com/kickstarter/viewmodels/SurveyResponseViewModel.kt index cfa1cbc971..303ae3025b 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/SurveyResponseViewModel.kt +++ b/app/src/main/java/com/kickstarter/viewmodels/SurveyResponseViewModel.kt @@ -80,9 +80,9 @@ interface SurveyResponseViewModel { val pledgeRedemptionUrl = intent() .filter { - it.hasExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION) && it.getParcelableExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION).isNotNull() + it.hasExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION) && !it.getStringExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION).isNullOrEmpty() } - .map { requireNotNull(it.getParcelableExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION)) } + .map { requireNotNull(it.getStringExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION)) } .ofType(String::class.java) .map { UrlUtils.appendPath(environment.webEndpoint(), it) } diff --git a/app/src/test/java/com/kickstarter/viewmodels/DeepLinkViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/DeepLinkViewModelTest.kt index 41161e44e1..7f864afd8c 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/DeepLinkViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/DeepLinkViewModelTest.kt @@ -323,7 +323,7 @@ class DeepLinkViewModelTest : KSRobolectricTestCase() { @Test fun testProjectSurveyDeeplink_startsSurveyActivity() { val url = - "https://www.kickstarter.com/projects/creator/project/surveys/survey-param" + "https://www.kickstarter.com/projects/alexlidell/power-of-five-collectors-edition-omnibus/backing/survey_responses" setUpEnvironment(intent = intentWithData(url)) startBrowser.assertNoValues() startDiscoveryActivity.assertNoValues() @@ -338,7 +338,7 @@ class DeepLinkViewModelTest : KSRobolectricTestCase() { @Test fun testProjectSurveyEditDeeplink_startsSurveyActivity() { val url = - "https://www.kickstarter.com/projects/creator/project/surveys/survey-param/edit" + "https://www.kickstarter.com/projects/alexlidell/power-of-five-collectors-edition-omnibus/surveys/0/edit" setUpEnvironment(intent = intentWithData(url)) startBrowser.assertNoValues() startDiscoveryActivity.assertNoValues() @@ -368,7 +368,7 @@ class DeepLinkViewModelTest : KSRobolectricTestCase() { @Test fun testProjectSurveyRedeemDeeplink_startsSurveyActivity() { val url = - "https://www.kickstarter.com/projects/creator/project/backing/redeem" + "https://www.kickstarter.com/projects/alexlidell/power-of-five-collectors-edition-omnibus/backing/redeem" setUpEnvironment(intent = intentWithData(url)) startBrowser.assertNoValues() startDiscoveryActivity.assertNoValues() diff --git a/app/src/test/java/com/kickstarter/viewmodels/SurveyResponseViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/SurveyResponseViewModelTest.kt index 5507e80c2b..aaa52bddbd 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/SurveyResponseViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/SurveyResponseViewModelTest.kt @@ -126,6 +126,15 @@ class SurveyResponseViewModelTest : KSRobolectricTestCase() { webViewUrl.assertValues("www.kickstarter.com/projects/1231313/test-project-deeplink/backing/survey_responses") } + @Test + fun `open webview when pledge redemption is opened from notification`() { + val pledgeRedemptionUrlPath = "projects/1231313/test-project-notification/backing/redeem" + + setUpEnvironment(environment().toBuilder().webEndpoint("www.test.dev/").build(), Intent().putExtra(IntentKey.NOTIFICATION_PLEDGE_REDEMPTION, pledgeRedemptionUrlPath)) + + webViewUrl.assertValues("www.test.dev/projects/1231313/test-project-notification/backing/redeem") + } + @After fun clear() { disposables.clear()