mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Resetting the app after deletion and cleanup settings (#372)
* Fixes #361 - Reset everything if the app has been deleted since the last run * Cleaned up and renamed the ElementSettings to ApplicationSettings. Removed its singleton and moved it to the service locator. * Moved the ApplicationSettings to the Application folder * Merged together the BuildSettings and ApplicationSettings * Reset the UserDefaults too when resetting the application state * Rename ServiceLocator.applicationSettings to just settings * Fix indentation * Rename ApplicationSettings to AppSettings * Various tweaks following code review * Fix unit tests
This commit is contained in:
@@ -19,10 +19,16 @@ import AnalyticsEvents
|
||||
import XCTest
|
||||
|
||||
class AnalyticsTests: XCTestCase {
|
||||
private var applicationSettings: AppSettings!
|
||||
|
||||
override func setUp() {
|
||||
AppSettings.configureWithSuiteName("io.element.elementx.unitests")
|
||||
AppSettings.reset()
|
||||
applicationSettings = AppSettings()
|
||||
}
|
||||
|
||||
func testAnalyticsPromptNewUser() {
|
||||
// Given a fresh install of the app (without PostHog analytics having been set).
|
||||
ElementSettings.store.removeObject(forKey: ElementSettings.UserDefaultsKeys.enableAnalytics.rawValue)
|
||||
|
||||
// When the user is prompted for analytics.
|
||||
let showPrompt = Analytics.shared.shouldShowAnalyticsPrompt
|
||||
|
||||
@@ -32,7 +38,7 @@ class AnalyticsTests: XCTestCase {
|
||||
|
||||
func testAnalyticsPromptUserDeclinedPostHog() {
|
||||
// Given an existing install of the app where the user previously declined PostHog
|
||||
ElementSettings.shared.enableAnalytics = false
|
||||
applicationSettings.enableAnalytics = false
|
||||
|
||||
// When the user is prompted for analytics
|
||||
let showPrompt = Analytics.shared.shouldShowAnalyticsPrompt
|
||||
@@ -43,7 +49,7 @@ class AnalyticsTests: XCTestCase {
|
||||
|
||||
func testAnalyticsPromptUserAcceptedPostHog() {
|
||||
// Given an existing install of the app where the user previously accepted PostHog
|
||||
ElementSettings.shared.enableAnalytics = true
|
||||
applicationSettings.enableAnalytics = true
|
||||
|
||||
// When the user is prompted for analytics
|
||||
let showPrompt = Analytics.shared.shouldShowAnalyticsPrompt
|
||||
|
||||
Reference in New Issue
Block a user