diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index a0bb87b389..c7a42731e3 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -447,7 +447,6 @@ 85BDC310243359040053DB07 /* FindInPageUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85BDC30F243359040053DB07 /* FindInPageUserScript.swift */; }; 85BDC3142434D8F80053DB07 /* DebugUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85BDC3132434D8F80053DB07 /* DebugUserScript.swift */; }; 85BDC3192436161C0053DB07 /* LoginFormDetectionUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85BDC3182436161C0053DB07 /* LoginFormDetectionUserScript.swift */; }; - 85C011FD299285A6001E0A99 /* SyncManagementViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85C011FB29928524001E0A99 /* SyncManagementViewModelTests.swift */; }; 85C11E4120904BBE00BFFEB4 /* VariantManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85C11E4020904BBE00BFFEB4 /* VariantManagerTests.swift */; }; 85C11E4C2090888C00BFFEB4 /* HomeRowReminder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85C11E4B2090888C00BFFEB4 /* HomeRowReminder.swift */; }; 85C11E532090B23A00BFFEB4 /* UserDefaultsHomeRowReminderStorageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85C11E522090B23A00BFFEB4 /* UserDefaultsHomeRowReminderStorageTests.swift */; }; @@ -609,10 +608,8 @@ 98F3A1D8217B37010011A0D4 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F3A1D7217B37010011A0D4 /* Theme.swift */; }; 98F6EA472863124100720957 /* ContentBlockerRulesLists.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F6EA462863124100720957 /* ContentBlockerRulesLists.swift */; }; 98F78B8E22419093007CACF4 /* ThemableNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98F78B8D22419093007CACF4 /* ThemableNavigationController.swift */; }; - 9F2510142BF5809E0096DB16 /* SubscriptionFlowViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F2510132BF5809E0096DB16 /* SubscriptionFlowViewModelTests.swift */; }; 9F8FE9492BAE50E50071E372 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 9F8FE9482BAE50E50071E372 /* Lottie */; }; 9FA5E44B2BF1AF3400BDEF02 /* SubscriptionContainerViewFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FA5E44A2BF1AF3400BDEF02 /* SubscriptionContainerViewFactory.swift */; }; - 9FA5E44E2BF1B16400BDEF02 /* SubscriptionContainerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FA5E44D2BF1B16400BDEF02 /* SubscriptionContainerViewModelTests.swift */; }; AA3D854523D9942200788410 /* AppIconSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3D854423D9942200788410 /* AppIconSettingsViewController.swift */; }; AA3D854723D9E88E00788410 /* AppIconSettingsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3D854623D9E88E00788410 /* AppIconSettingsCell.swift */; }; AA3D854923DA1DFB00788410 /* AppIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3D854823DA1DFB00788410 /* AppIcon.swift */; }; @@ -938,6 +935,10 @@ F198D7981E3A45D90088DA8A /* WKWebViewConfigurationExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F198D7971E3A45D90088DA8A /* WKWebViewConfigurationExtensionTests.swift */; }; F1A886781F29394E0096251E /* WebCacheManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1A886771F29394E0096251E /* WebCacheManager.swift */; }; F1AE54E81F0425FC00D9A700 /* AuthenticationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1AE54E71F0425FC00D9A700 /* AuthenticationViewController.swift */; }; + F1BDDBFD2C340D9C00459306 /* SubscriptionContainerViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1BDDBF92C340D9C00459306 /* SubscriptionContainerViewModelTests.swift */; }; + F1BDDBFE2C340D9C00459306 /* SubscriptionFlowViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1BDDBFA2C340D9C00459306 /* SubscriptionFlowViewModelTests.swift */; }; + F1BDDBFF2C340D9C00459306 /* SubscriptionPagesUseSubscriptionFeatureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1BDDBFB2C340D9C00459306 /* SubscriptionPagesUseSubscriptionFeatureTests.swift */; }; + F1BDDC022C340DDF00459306 /* SyncManagementViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1BDDC002C340DDF00459306 /* SyncManagementViewModelTests.swift */; }; F1BE54581E69DE1000FCF649 /* TutorialSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1BE54571E69DE1000FCF649 /* TutorialSettings.swift */; }; F1C4A70E1E57725800A6CA1B /* OmniBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1C4A70D1E57725800A6CA1B /* OmniBar.swift */; }; F1CA3C371F045878005FADB3 /* PrivacyStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1CA3C361F045878005FADB3 /* PrivacyStore.swift */; }; @@ -1567,7 +1568,6 @@ 85BDC30F243359040053DB07 /* FindInPageUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindInPageUserScript.swift; sourceTree = ""; }; 85BDC3132434D8F80053DB07 /* DebugUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugUserScript.swift; sourceTree = ""; }; 85BDC3182436161C0053DB07 /* LoginFormDetectionUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginFormDetectionUserScript.swift; sourceTree = ""; }; - 85C011FB29928524001E0A99 /* SyncManagementViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SyncManagementViewModelTests.swift; sourceTree = ""; }; 85C11E4020904BBE00BFFEB4 /* VariantManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VariantManagerTests.swift; sourceTree = ""; }; 85C11E4B2090888C00BFFEB4 /* HomeRowReminder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeRowReminder.swift; sourceTree = ""; }; 85C11E522090B23A00BFFEB4 /* UserDefaultsHomeRowReminderStorageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsHomeRowReminderStorageTests.swift; sourceTree = ""; }; @@ -2252,9 +2252,7 @@ 98F3A1D7217B37010011A0D4 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; 98F6EA462863124100720957 /* ContentBlockerRulesLists.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentBlockerRulesLists.swift; sourceTree = ""; }; 98F78B8D22419093007CACF4 /* ThemableNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemableNavigationController.swift; sourceTree = ""; }; - 9F2510132BF5809E0096DB16 /* SubscriptionFlowViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionFlowViewModelTests.swift; sourceTree = ""; }; 9FA5E44A2BF1AF3400BDEF02 /* SubscriptionContainerViewFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionContainerViewFactory.swift; sourceTree = ""; }; - 9FA5E44D2BF1B16400BDEF02 /* SubscriptionContainerViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionContainerViewModelTests.swift; sourceTree = ""; }; AA3D854423D9942200788410 /* AppIconSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconSettingsViewController.swift; sourceTree = ""; }; AA3D854623D9E88E00788410 /* AppIconSettingsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIconSettingsCell.swift; sourceTree = ""; }; AA3D854823DA1DFB00788410 /* AppIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIcon.swift; sourceTree = ""; }; @@ -2620,6 +2618,10 @@ F1AA54601E48D90700223211 /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; }; F1AE54E71F0425FC00D9A700 /* AuthenticationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticationViewController.swift; sourceTree = ""; }; F1B745211E549D550072547E /* UIColorExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIColorExtension.swift; path = ../Core/UIColorExtension.swift; sourceTree = ""; }; + F1BDDBF92C340D9C00459306 /* SubscriptionContainerViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscriptionContainerViewModelTests.swift; sourceTree = ""; }; + F1BDDBFA2C340D9C00459306 /* SubscriptionFlowViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscriptionFlowViewModelTests.swift; sourceTree = ""; }; + F1BDDBFB2C340D9C00459306 /* SubscriptionPagesUseSubscriptionFeatureTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscriptionPagesUseSubscriptionFeatureTests.swift; sourceTree = ""; }; + F1BDDC002C340DDF00459306 /* SyncManagementViewModelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncManagementViewModelTests.swift; sourceTree = ""; }; F1BE54571E69DE1000FCF649 /* TutorialSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TutorialSettings.swift; sourceTree = ""; }; F1C4A70D1E57725800A6CA1B /* OmniBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OmniBar.swift; sourceTree = ""; }; F1CA3C361F045878005FADB3 /* PrivacyStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivacyStore.swift; sourceTree = ""; }; @@ -3735,7 +3737,7 @@ 84E341A91E2F7EFB00BDBA6F /* UnitTests */ = { isa = PBXGroup; children = ( - 85C011FA2992850A001E0A99 /* SyncUI */, + F1BDDC012C340DDF00459306 /* SyncUI */, F12D98401F266B30003C2EE3 /* DuckDuckGo */, F1E092B31E92A6B900732CCC /* Core */, F1134ED11F40EDB600B73467 /* TestUtils */, @@ -3961,14 +3963,6 @@ name = Web; sourceTree = ""; }; - 85C011FA2992850A001E0A99 /* SyncUI */ = { - isa = PBXGroup; - children = ( - 85C011FB29928524001E0A99 /* SyncManagementViewModelTests.swift */, - ); - name = SyncUI; - sourceTree = ""; - }; 85C11E4A209084DE00BFFEB4 /* HomeRow */ = { isa = PBXGroup; children = ( @@ -4217,15 +4211,6 @@ name = Themes; sourceTree = ""; }; - 9FA5E44C2BF1B14100BDEF02 /* Subscription */ = { - isa = PBXGroup; - children = ( - 9FA5E44D2BF1B16400BDEF02 /* SubscriptionContainerViewModelTests.swift */, - 9F2510132BF5809E0096DB16 /* SubscriptionFlowViewModelTests.swift */, - ); - name = Subscription; - sourceTree = ""; - }; AA4D6A8023DE4973007E8790 /* AppIcon */ = { isa = PBXGroup; children = ( @@ -4953,9 +4938,7 @@ isa = PBXGroup; children = ( 6F03CAFF2C32ED22004179A8 /* NewTabPage */, - 569437222BDD402600C0881B /* Sync */, 6FF9157F2B88E04F0042AC87 /* AdAttribution */, - CB48D3342B90CEBD00631D8B /* UserBehaviorMonitor */, F17669A21E411D63003D3222 /* Application */, 981FED7222045FFA008488D7 /* AutoClear */, 1E1D8B5B2994FF7800C96994 /* Autoconsent */, @@ -4969,10 +4952,12 @@ EE56DE3A2A6038F500375C41 /* NetworkProtection */, F1D477C71F2139210031ED49 /* OmniBar */, 98EA2C3F218BB5140023E1DC /* Settings */, - 9FA5E44C2BF1B14100BDEF02 /* Subscription */, + F1BDDBFC2C340D9C00459306 /* Subscription */, + 569437222BDD402600C0881B /* Sync */, F13B4BF71F18C9E800814661 /* Tabs */, 98EA2C3A218B9A880023E1DC /* Themes */, F12790DD1EBBDDF3001D3AEC /* Tutorials */, + CB48D3342B90CEBD00631D8B /* UserBehaviorMonitor */, F194FAF91F14E605009B4DF8 /* UserInterface */, 317045BE2858C69A0016ED1F /* Utils */, 4B6484F927FFCF520050A7A1 /* Waitlist */, @@ -5329,6 +5314,24 @@ name = Privacy; sourceTree = ""; }; + F1BDDBFC2C340D9C00459306 /* Subscription */ = { + isa = PBXGroup; + children = ( + F1BDDBF92C340D9C00459306 /* SubscriptionContainerViewModelTests.swift */, + F1BDDBFA2C340D9C00459306 /* SubscriptionFlowViewModelTests.swift */, + F1BDDBFB2C340D9C00459306 /* SubscriptionPagesUseSubscriptionFeatureTests.swift */, + ); + path = Subscription; + sourceTree = ""; + }; + F1BDDC012C340DDF00459306 /* SyncUI */ = { + isa = PBXGroup; + children = ( + F1BDDC002C340DDF00459306 /* SyncManagementViewModelTests.swift */, + ); + path = SyncUI; + sourceTree = ""; + }; F1BE54481E69DD5F00FCF649 /* Onboarding */ = { isa = PBXGroup; children = ( @@ -7001,13 +7004,13 @@ 83EDCC411F86B89C005CDFCD /* StatisticsLoaderTests.swift in Sources */, C14882E327F20D9A00D59F0C /* BookmarksExporterTests.swift in Sources */, 85C29708247BDD060063A335 /* DaxDialogsBrowsingSpecTests.swift in Sources */, - 9FA5E44E2BF1B16400BDEF02 /* SubscriptionContainerViewModelTests.swift in Sources */, 85BA58581F34F72F00C6E8CA /* AppUserDefaultsTests.swift in Sources */, F1134EBC1F40D45700B73467 /* MockStatisticsStore.swift in Sources */, 983C52E72C2C0ACB007B5747 /* BookmarkStateRepairTests.swift in Sources */, 31C138AC27A403CB00FFD4B2 /* DownloadManagerTests.swift in Sources */, EEFE9C732A603CE9005B0A26 /* NetworkProtectionStatusViewModelTests.swift in Sources */, F13B4BF91F18CA0600814661 /* TabsModelTests.swift in Sources */, + F1BDDBFD2C340D9C00459306 /* SubscriptionContainerViewModelTests.swift in Sources */, 98B31290218CCB2200E54DE1 /* MockDependencyProvider.swift in Sources */, CBDD5DDF29A6736A00832877 /* APIHeadersTests.swift in Sources */, 986B45D0299E30A50089D2D7 /* BookmarkEntityTests.swift in Sources */, @@ -7024,6 +7027,8 @@ F1134ECE1F40EA9C00B73467 /* AtbParserTests.swift in Sources */, D62EC3BE2C24710F00FC9D04 /* DuckPlayerURLExtensionTests.swift in Sources */, F189AEE41F18FDAF001EBAE1 /* LinkTests.swift in Sources */, + F1BDDBFE2C340D9C00459306 /* SubscriptionFlowViewModelTests.swift in Sources */, + F1BDDC022C340DDF00459306 /* SyncManagementViewModelTests.swift in Sources */, D625AAEC2BBEF27600BC189A /* TabURLInterceptorTests.swift in Sources */, 5694372B2BE3F2D900C0881B /* SyncErrorHandlerTests.swift in Sources */, 987130C7294AAB9F00AB05E0 /* MenuBookmarksViewModelTests.swift in Sources */, @@ -7060,7 +7065,6 @@ 1E8146AD28C8ABF000D1AF63 /* TrackerAnimationLogicTests.swift in Sources */, C1CDA31E2AFBF811006D1476 /* AutofillNeverPromptWebsitesManagerTests.swift in Sources */, B6AD9E3A28D456820019CDE9 /* PrivacyConfigurationManagerMock.swift in Sources */, - 9F2510142BF5809E0096DB16 /* SubscriptionFlowViewModelTests.swift in Sources */, F189AED71F18F6DE001EBAE1 /* TabTests.swift in Sources */, F13B4BFB1F18E3D900814661 /* TabsModelPersistenceExtensionTests.swift in Sources */, CB48D3372B90DF2000631D8B /* UserBehaviorMonitorTests.swift in Sources */, @@ -7111,11 +7115,11 @@ F1134ED21F40EF3A00B73467 /* JsonTestDataLoader.swift in Sources */, 850250B520D80419002199C7 /* AtbAndVariantCleanupTests.swift in Sources */, 834DF992248FDE1A0075EA48 /* UserAgentTests.swift in Sources */, - 85C011FD299285A6001E0A99 /* SyncManagementViewModelTests.swift in Sources */, C14882E727F20DAB00D59F0C /* HtmlTestDataLoader.swift in Sources */, F17D72391E8B35C6003E8B0E /* AppURLsTests.swift in Sources */, F1134ED61F40F29F00B73467 /* StatisticsUserDefaultsTests.swift in Sources */, 98629D342C21BE37001E6031 /* BookmarksStateValidationTests.swift in Sources */, + F1BDDBFF2C340D9C00459306 /* SubscriptionPagesUseSubscriptionFeatureTests.swift in Sources */, 98EA2C3C218B9AAD0023E1DC /* ThemeManagerTests.swift in Sources */, 569437292BDD487600C0881B /* SyncCredentialsAdapterTests.swift in Sources */, 6AC98419288055C1005FA9CA /* BarsAnimatorTests.swift in Sources */, @@ -9962,7 +9966,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 164.3.0; + version = 165.0.0; }; }; 9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index c6f6300232..15eb24cbec 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/DuckDuckGo/BrowserServicesKit", "state" : { - "revision" : "28dd48c5aca37c46402e2a14f7c47aad3877b3aa", - "version" : "164.3.0" + "revision" : "777e5ae1ab890d9ec22e069bc5dc0f0ada4b35af", + "version" : "165.0.0" } }, { diff --git a/DuckDuckGo/SettingsViewModel.swift b/DuckDuckGo/SettingsViewModel.swift index e547ac8500..74a4202ed2 100644 --- a/DuckDuckGo/SettingsViewModel.swift +++ b/DuckDuckGo/SettingsViewModel.swift @@ -750,7 +750,10 @@ extension SettingsViewModel { @available(iOS 15.0, *) func restoreAccountPurchase() async { DispatchQueue.main.async { self.state.subscription.isRestoring = true } - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: subscriptionManager) + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) let result = await appStoreRestoreFlow.restoreAccountFromPastPurchase() switch result { case .success: diff --git a/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift b/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift index 684ea20a41..6172f1bb66 100644 --- a/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift +++ b/DuckDuckGo/Subscription/SubscriptionManageriOS14.swift @@ -29,6 +29,13 @@ class SubscriptionManageriOS14: SubscriptionManager { func storePurchaseManager() -> StorePurchaseManager { DefaultStorePurchaseManager() } + + static func loadEnvironmentFrom(userDefaults: UserDefaults) -> SubscriptionEnvironment? { + return nil + } + + static func save(subscriptionEnvironment: SubscriptionEnvironment, userDefaults: UserDefaults) {} + var currentEnvironment: SubscriptionEnvironment = SubscriptionEnvironment.default var canPurchase: Bool = false func loadInitialData() {} diff --git a/DuckDuckGo/Subscription/UserScripts/SubscriptionPagesUseSubscriptionFeature.swift b/DuckDuckGo/Subscription/UserScripts/SubscriptionPagesUseSubscriptionFeature.swift index e257a026be..d28469bc02 100644 --- a/DuckDuckGo/Subscription/UserScripts/SubscriptionPagesUseSubscriptionFeature.swift +++ b/DuckDuckGo/Subscription/UserScripts/SubscriptionPagesUseSubscriptionFeature.swift @@ -95,7 +95,6 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature, ObservableObjec private let subscriptionManager: SubscriptionManager private var accountManager: AccountManager { subscriptionManager.accountManager } private let appStorePurchaseFlow: AppStorePurchaseFlow - private let appStoreRestoreFlow: AppStoreRestoreFlow private let appStoreAccountManagementFlow: AppStoreAccountManagementFlow @@ -177,7 +176,6 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature, ObservableObjec private func resetSubscriptionFlow() { setTransactionError(nil) - } private func setTransactionError(_ error: UseSubscriptionError?) { diff --git a/DuckDuckGo/Subscription/Views/SubscriptionContainerViewFactory.swift b/DuckDuckGo/Subscription/Views/SubscriptionContainerViewFactory.swift index 32c1423204..8b49dd0a8d 100644 --- a/DuckDuckGo/Subscription/Views/SubscriptionContainerViewFactory.swift +++ b/DuckDuckGo/Subscription/Views/SubscriptionContainerViewFactory.swift @@ -24,10 +24,18 @@ import Subscription enum SubscriptionContainerViewFactory { static func makeSubscribeFlow(origin: String?, navigationCoordinator: SubscriptionNavigationCoordinator, subscriptionManager: SubscriptionManager) -> some View { - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: subscriptionManager) + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) let viewModel = SubscriptionContainerViewModel( subscriptionManager: subscriptionManager, @@ -44,10 +52,18 @@ enum SubscriptionContainerViewFactory { } static func makeRestoreFlow(navigationCoordinator: SubscriptionNavigationCoordinator, subscriptionManager: SubscriptionManager) -> some View { - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: subscriptionManager) + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) let viewModel = SubscriptionContainerViewModel( subscriptionManager: subscriptionManager, @@ -66,11 +82,18 @@ enum SubscriptionContainerViewFactory { static func makeEmailFlow(navigationCoordinator: SubscriptionNavigationCoordinator, subscriptionManager: SubscriptionManager, onDisappear: @escaping () -> Void) -> some View { - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: subscriptionManager) - + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) let viewModel = SubscriptionContainerViewModel( subscriptionManager: subscriptionManager, origin: nil, diff --git a/DuckDuckGoTests/Subscription/SubscriptionContainerViewModelTests.swift b/DuckDuckGoTests/Subscription/SubscriptionContainerViewModelTests.swift new file mode 100644 index 0000000000..77f460da48 --- /dev/null +++ b/DuckDuckGoTests/Subscription/SubscriptionContainerViewModelTests.swift @@ -0,0 +1,89 @@ +// +// SubscriptionContainerViewModelTests.swift +// DuckDuckGo +// +// Copyright © 2024 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import XCTest +@testable import DuckDuckGo +@testable import Subscription +import SubscriptionTestingUtilities + +@available(iOS 15.0, *) +final class SubscriptionContainerViewModelTests: XCTestCase { + var sut: SubscriptionContainerViewModel! + let subscriptionManager = MockDependencyProvider().subscriptionManager + + func testWhenInitWithOriginThenSubscriptionFlowPurchaseURLHasOriginSet() { + // GIVEN + let origin = "test_origin" + let queryParameter = URLQueryItem(name: "origin", value: "test_origin") + let expectedURL = SubscriptionURL.purchase.subscriptionURL(environment: .production).appending(percentEncodedQueryItem: queryParameter) + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) + + // WHEN + sut = .init(subscriptionManager: subscriptionManager, + origin: origin, + userScript: .init(), + subFeature: .init(subscriptionManager: subscriptionManager, + subscriptionAttributionOrigin: nil, + appStorePurchaseFlow: appStorePurchaseFlow, + appStoreRestoreFlow: appStoreRestoreFlow, + appStoreAccountManagementFlow: appStoreAccountManagementFlow)) + + // THEN + XCTAssertEqual(sut.flow.purchaseURL, expectedURL) + } + + func testWhenInitWithoutOriginThenSubscriptionFlowPurchaseURLDoesNotHaveOriginSet() { + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) + + // WHEN + sut = .init(subscriptionManager: subscriptionManager, + origin: nil, + userScript: .init(), + subFeature: .init(subscriptionManager: subscriptionManager, + subscriptionAttributionOrigin: nil, + appStorePurchaseFlow: appStorePurchaseFlow, + appStoreRestoreFlow: appStoreRestoreFlow, + appStoreAccountManagementFlow: appStoreAccountManagementFlow)) + + // THEN + XCTAssertEqual(sut.flow.purchaseURL, SubscriptionURL.purchase.subscriptionURL(environment: .production)) + } +} diff --git a/DuckDuckGoTests/SubscriptionFlowViewModelTests.swift b/DuckDuckGoTests/Subscription/SubscriptionFlowViewModelTests.swift similarity index 50% rename from DuckDuckGoTests/SubscriptionFlowViewModelTests.swift rename to DuckDuckGoTests/Subscription/SubscriptionFlowViewModelTests.swift index 6d375a2a87..76646f449e 100644 --- a/DuckDuckGoTests/SubscriptionFlowViewModelTests.swift +++ b/DuckDuckGoTests/Subscription/SubscriptionFlowViewModelTests.swift @@ -26,43 +26,59 @@ import SubscriptionTestingUtilities final class SubscriptionFlowViewModelTests: XCTestCase { private var sut: SubscriptionFlowViewModel! - let mockDependencyProvider = MockDependencyProvider() - + let subscriptionManager = MockDependencyProvider().subscriptionManager + func testWhenInitWithOriginThenSubscriptionFlowPurchaseURLHasOriginSet() { // GIVEN let origin = "test_origin" let queryParameter = URLQueryItem(name: "origin", value: "test_origin") let expectedURL = SubscriptionURL.purchase.subscriptionURL(environment: .production).appending(percentEncodedQueryItem: queryParameter) - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: mockDependencyProvider.subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) // WHEN - sut = .init(origin: origin, userScript: .init(), subFeature: .init(subscriptionManager: mockDependencyProvider.subscriptionManager, + sut = .init(origin: origin, userScript: .init(), subFeature: .init(subscriptionManager: subscriptionManager, subscriptionAttributionOrigin: nil, appStorePurchaseFlow: appStorePurchaseFlow, appStoreRestoreFlow: appStoreRestoreFlow, appStoreAccountManagementFlow: appStoreAccountManagementFlow), - subscriptionManager: mockDependencyProvider.subscriptionManager) + subscriptionManager: subscriptionManager) // THEN XCTAssertEqual(sut.purchaseURL, expectedURL) } func testWhenInitWithoutOriginThenSubscriptionFlowPurchaseURLDoesNotHaveOriginSet() { - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: mockDependencyProvider.subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) + let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(accountManager: subscriptionManager.accountManager, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + authEndpointService: subscriptionManager.authEndpointService) + let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionEndpointService: subscriptionManager.subscriptionEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager, + appStoreRestoreFlow: appStoreRestoreFlow, + authEndpointService: subscriptionManager.authEndpointService) + let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(authEndpointService: subscriptionManager.authEndpointService, + storePurchaseManager: subscriptionManager.storePurchaseManager(), + accountManager: subscriptionManager.accountManager) // WHEN - sut = .init(origin: nil, userScript: .init(), subFeature: .init(subscriptionManager: mockDependencyProvider.subscriptionManager, + sut = .init(origin: nil, userScript: .init(), subFeature: .init(subscriptionManager: subscriptionManager, subscriptionAttributionOrigin: nil, appStorePurchaseFlow: appStorePurchaseFlow, appStoreRestoreFlow: appStoreRestoreFlow, appStoreAccountManagementFlow: appStoreAccountManagementFlow), - subscriptionManager: mockDependencyProvider.subscriptionManager) + subscriptionManager: subscriptionManager) // THEN XCTAssertEqual(sut.purchaseURL, SubscriptionURL.purchase.subscriptionURL(environment: .production)) diff --git a/DuckDuckGoTests/Subscription/SubscriptionPagesUseSubscriptionFeatureTests.swift b/DuckDuckGoTests/Subscription/SubscriptionPagesUseSubscriptionFeatureTests.swift new file mode 100644 index 0000000000..f6292a6138 --- /dev/null +++ b/DuckDuckGoTests/Subscription/SubscriptionPagesUseSubscriptionFeatureTests.swift @@ -0,0 +1,47 @@ +// +// SubscriptionPagesUseSubscriptionFeatureTests.swift +// DuckDuckGo +// +// Copyright © 2024 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import XCTest +@testable import DuckDuckGo +@testable import Subscription +import SubscriptionTestingUtilities + +@available(iOS 15.0, *) +final class SubscriptionPagesUseSubscriptionFeatureTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + let appStorePurchaseFlow = AppStorePurchaseFlowMock(purchaseSubscriptionResult: .success("TransactionJWS"), + completeSubscriptionPurchaseResult: .success(PurchaseUpdate(type: "t", token: "t"))) + let appStoreAccountManagementFlow = AppStoreAccountManagementFlowMock(refreshAuthTokenIfNeededResult: .success("Something")) + let feature = SubscriptionPagesUseSubscriptionFeature(subscriptionManager: SubscriptionMockFactory.subscriptionManager, + subscriptionAttributionOrigin: "???", + appStorePurchaseFlow: appStorePurchaseFlow, + appStoreRestoreFlow: SubscriptionMockFactory.appStoreRestoreFlow, + appStoreAccountManagementFlow: appStoreAccountManagementFlow) + // To be implemented + } +} diff --git a/DuckDuckGoTests/SubscriptionContainerViewModelTests.swift b/DuckDuckGoTests/SubscriptionContainerViewModelTests.swift deleted file mode 100644 index 922c406ba6..0000000000 --- a/DuckDuckGoTests/SubscriptionContainerViewModelTests.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// SubscriptionContainerViewModelTests.swift -// DuckDuckGo -// -// Copyright © 2024 DuckDuckGo. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import XCTest -@testable import DuckDuckGo -@testable import Subscription -import SubscriptionTestingUtilities - -@available(iOS 15.0, *) -final class SubscriptionContainerViewModelTests: XCTestCase { - var sut: SubscriptionContainerViewModel! - let mockDependencyProvider = MockDependencyProvider() - - func testWhenInitWithOriginThenSubscriptionFlowPurchaseURLHasOriginSet() { - // GIVEN - let origin = "test_origin" - let queryParameter = URLQueryItem(name: "origin", value: "test_origin") - let expectedURL = SubscriptionURL.purchase.subscriptionURL(environment: .production).appending(percentEncodedQueryItem: queryParameter) - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: mockDependencyProvider.subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) - - // WHEN - sut = .init(subscriptionManager: mockDependencyProvider.subscriptionManager, - origin: origin, - userScript: .init(), - subFeature: .init(subscriptionManager: mockDependencyProvider.subscriptionManager, - subscriptionAttributionOrigin: nil, - appStorePurchaseFlow: appStorePurchaseFlow, - appStoreRestoreFlow: appStoreRestoreFlow, - appStoreAccountManagementFlow: appStoreAccountManagementFlow)) - - // THEN - XCTAssertEqual(sut.flow.purchaseURL, expectedURL) - } - - func testWhenInitWithoutOriginThenSubscriptionFlowPurchaseURLDoesNotHaveOriginSet() { - let appStoreRestoreFlow = DefaultAppStoreRestoreFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) - let appStorePurchaseFlow = DefaultAppStorePurchaseFlow(subscriptionManager: mockDependencyProvider.subscriptionManager, - appStoreRestoreFlow: appStoreRestoreFlow) - let appStoreAccountManagementFlow = DefaultAppStoreAccountManagementFlow(subscriptionManager: mockDependencyProvider.subscriptionManager) - - // WHEN - sut = .init(subscriptionManager: mockDependencyProvider.subscriptionManager, - origin: nil, - userScript: .init(), - subFeature: .init(subscriptionManager: mockDependencyProvider.subscriptionManager, - subscriptionAttributionOrigin: nil, - appStorePurchaseFlow: appStorePurchaseFlow, - appStoreRestoreFlow: appStoreRestoreFlow, - appStoreAccountManagementFlow: appStoreAccountManagementFlow)) - - // THEN - XCTAssertEqual(sut.flow.purchaseURL, SubscriptionURL.purchase.subscriptionURL(environment: .production)) - } - -} diff --git a/DuckDuckGoTests/SyncManagementViewModelTests.swift b/DuckDuckGoTests/SyncUI/SyncManagementViewModelTests.swift similarity index 100% rename from DuckDuckGoTests/SyncManagementViewModelTests.swift rename to DuckDuckGoTests/SyncUI/SyncManagementViewModelTests.swift