Skip to content
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

[NT-1055] LandingPage deeplink handling bug fix #1146

Merged
merged 5 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Kickstarter-iOS/ViewModels/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,13 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
)
.skipNil()

self.goToLandingPage = self.applicationLaunchOptionsProperty.signal.ignoreValues()
.takeWhen(self.didUpdateOptimizelyClientProperty.signal.ignoreValues())
.filter(shouldGoToLandingPage)

let deepLink = deeplinkActivated
.filter { _ in shouldGoToLandingPage() == false }
.take(until: self.goToLandingPage)

self.findRedirectUrl = deepLinkUrl
.filter { Navigation.match($0) == .emailClick }
Expand Down Expand Up @@ -378,10 +383,6 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
.filter { $0 == .tab(.search) }
.ignoreValues()

self.goToLandingPage = self.applicationLaunchOptionsProperty.signal.ignoreValues()
.takeWhen(self.didUpdateOptimizelyClientProperty.signal.ignoreValues())
.filter(shouldGoToLandingPage)

self.goToLogin = deepLink
.filter { $0 == .tab(.login) }
.ignoreValues()
Expand Down
27 changes: 27 additions & 0 deletions Kickstarter-iOS/ViewModels/AppDelegateViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,33 @@ final class AppDelegateViewModelTests: TestCase {
self.goToLandingPage.assertDidNotEmitValue()
}
}

func testDeeplink_DoesNotActivateIf_GoToLandingPageEmits() {
let optimizelyClient = MockOptimizelyClient()
|> \.experiments .~
[OptimizelyExperiment.Key.nativeOnboarding.rawValue: OptimizelyExperiment.Variant.variant1.rawValue]

let userDefaults = MockKeyValueStore()
|> \.hasSeenLandingPage .~ false

withEnvironment(currentUser: nil, optimizelyClient: optimizelyClient, userDefaults: userDefaults) {
self.goToLandingPage.assertDidNotEmitValue()

self.vm.inputs.applicationDidFinishLaunching(application: UIApplication.shared, launchOptions: nil)
self.vm.inputs.didUpdateOptimizelyClient(MockOptimizelyClient())

_ = self.vm.inputs.applicationOpenUrl(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we actually run this test with a project deeplink? The output that was being triggered during the bug was presentViewController, which first dismisses any previously presented VC.

application: UIApplication.shared,
url: URL(
string: "https://www.kickstarter.com/projects/chelsea-punk/chelsea-punk-band-the-final-album"
)!,
options: [:]
)

self.presentViewController.assertDidNotEmitValue()
self.goToLandingPage.assertValueCount(1)
}
}
}

private func qualtricsProps() -> [String: String] {
Expand Down