Allow the services that are configured by secrets to be disabled. (#3961)
* Make the map tiler key optional. * Make the bug report URL optional. * Make the sentry URL optional. * Make the analytics configuration optional and handle consent taking Sentry into account. * Stop prompting users to report crashes when Sentry is disabled.
This commit is contained in:
@@ -155,11 +155,11 @@ class AnalyticsTests: XCTestCase {
|
||||
XCTAssertEqual(client.pendingUserProperties?.numSpaces, 5, "The number of spaces should have been updated.")
|
||||
}
|
||||
|
||||
func testSendingUserProperties() {
|
||||
func testSendingUserProperties() throws {
|
||||
// Given a client with user properties set
|
||||
|
||||
let client = PostHogAnalyticsClient(posthogFactory: MockPostHogFactory(mock: posthogMock))
|
||||
client.start(analyticsConfiguration: appSettings.analyticsConfiguration)
|
||||
try client.start(analyticsConfiguration: XCTUnwrap(appSettings.analyticsConfiguration))
|
||||
|
||||
client.updateUserProperties(AnalyticsEvent.UserProperties(allChatsActiveFilter: nil, ftueUseCaseSelection: .PersonalMessaging,
|
||||
numFavouriteRooms: nil,
|
||||
@@ -204,10 +204,10 @@ class AnalyticsTests: XCTestCase {
|
||||
XCTAssertTrue(ServiceLocator.shared.analytics.shouldShowAnalyticsPrompt)
|
||||
}
|
||||
|
||||
func testSendingAndUpdatingSuperProperties() {
|
||||
func testSendingAndUpdatingSuperProperties() throws {
|
||||
// Given a client with user properties set
|
||||
let client = PostHogAnalyticsClient(posthogFactory: MockPostHogFactory(mock: posthogMock))
|
||||
client.start(analyticsConfiguration: appSettings.analyticsConfiguration)
|
||||
try client.start(analyticsConfiguration: XCTUnwrap(appSettings.analyticsConfiguration))
|
||||
|
||||
client.updateSuperProperties(
|
||||
AnalyticsEvent.SuperProperties(appPlatform: .EXI,
|
||||
@@ -264,7 +264,7 @@ class AnalyticsTests: XCTestCase {
|
||||
XCTAssertEqual(capturedEvent2?.properties?["cryptoSDKVersion"] as? String, "001")
|
||||
}
|
||||
|
||||
func testShouldNotReportIfNotStarted() {
|
||||
func testShouldNotReportIfNotStarted() throws {
|
||||
// Given a client with user properties set
|
||||
let client = PostHogAnalyticsClient(posthogFactory: MockPostHogFactory(mock: posthogMock))
|
||||
|
||||
@@ -291,7 +291,7 @@ class AnalyticsTests: XCTestCase {
|
||||
XCTAssertEqual(posthogMock.capturePropertiesUserPropertiesCalled, false)
|
||||
|
||||
// start now
|
||||
client.start(analyticsConfiguration: appSettings.analyticsConfiguration)
|
||||
try client.start(analyticsConfiguration: XCTUnwrap(appSettings.analyticsConfiguration))
|
||||
XCTAssertEqual(posthogMock.optInCalled, true)
|
||||
|
||||
client.capture(someEvent)
|
||||
|
||||
@@ -41,18 +41,30 @@ class BugReportServiceTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testInitialStateWithRealService() throws {
|
||||
let service = BugReportService(withBaseURL: "https://www.example.com",
|
||||
applicationId: "mock_app_id",
|
||||
let service = BugReportService(baseURL: "https://www.example.com",
|
||||
applicationID: "mock_app_id",
|
||||
sdkGitSHA: "1234",
|
||||
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
||||
session: .mock,
|
||||
appHooks: AppHooks())
|
||||
XCTAssertTrue(service.isEnabled)
|
||||
XCTAssertFalse(service.crashedLastRun)
|
||||
}
|
||||
|
||||
func testInitialStateWithRealServiceAndNoURL() throws {
|
||||
let service = BugReportService(baseURL: nil,
|
||||
applicationID: "mock_app_id",
|
||||
sdkGitSHA: "1234",
|
||||
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
||||
session: .mock,
|
||||
appHooks: AppHooks())
|
||||
XCTAssertFalse(service.isEnabled)
|
||||
XCTAssertFalse(service.crashedLastRun)
|
||||
}
|
||||
|
||||
@MainActor func testSubmitBugReportWithRealService() async throws {
|
||||
let service = BugReportService(withBaseURL: "https://www.example.com",
|
||||
applicationId: "mock_app_id",
|
||||
let service = BugReportService(baseURL: "https://www.example.com",
|
||||
applicationID: "mock_app_id",
|
||||
sdkGitSHA: "1234",
|
||||
maxUploadSize: ServiceLocator.shared.settings.bugReportMaxUploadSize,
|
||||
session: .mock,
|
||||
|
||||
@@ -100,6 +100,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
@@ -684,6 +685,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
@@ -727,6 +729,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
@@ -760,6 +763,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
@@ -794,6 +798,7 @@ class ComposerToolbarViewModelTests: XCTestCase {
|
||||
completionSuggestionService: completionSuggestionServiceMock,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
composerDraftService: draftServiceMock)
|
||||
viewModel.context.composerFormattingEnabled = true
|
||||
|
||||
@@ -51,4 +51,24 @@ final class MapTilerURLBuilderTests: XCTestCase {
|
||||
let expectedURL: URL = "http://www.foo.com/dea61faf-292b-4774-9660-58fcef89a7f3/style.json?key=some_key"
|
||||
XCTAssertEqual(url, expectedURL)
|
||||
}
|
||||
|
||||
func testNilAPIKey() {
|
||||
let configuration = MapTilerConfiguration(baseURL: Self.baseURL,
|
||||
apiKey: nil,
|
||||
lightStyleID: Self.lightStyleID,
|
||||
darkStyleID: Self.darkStyleID)
|
||||
XCTAssertFalse(configuration.isEnabled)
|
||||
|
||||
builder = configuration
|
||||
|
||||
let staticMapURL = builder.staticMapURL(for: .dark,
|
||||
coordinates: .init(latitude: 1, longitude: 2),
|
||||
zoomLevel: 5,
|
||||
size: .init(width: 300, height: 200),
|
||||
attribution: .topLeft)
|
||||
XCTAssertNil(staticMapURL)
|
||||
|
||||
let dynamicMapURL = builder.dynamicMapURL(for: .light)
|
||||
XCTAssertNil(dynamicMapURL)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ class SettingsScreenViewModelTests: XCTestCase {
|
||||
@MainActor override func setUpWithError() throws {
|
||||
cancellables.removeAll()
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: ""))))
|
||||
viewModel = SettingsScreenViewModel(userSession: userSession)
|
||||
viewModel = SettingsScreenViewModel(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
isBugReportServiceEnabled: true)
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class UserSessionFlowCoordinatorTests: XCTestCase {
|
||||
userSessionFlowCoordinator = UserSessionFlowCoordinator(userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
navigationRootCoordinator: navigationRootCoordinator,
|
||||
appLockService: AppLockServiceMock(),
|
||||
bugReportService: BugReportServiceMock(),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
timelineControllerFactory: timelineControllerFactory,
|
||||
appMediator: AppMediatorMock.default,
|
||||
|
||||
Reference in New Issue
Block a user