From 1a1b4e098f9bcf18f67bbbc5cc510d5dcdfef422 Mon Sep 17 00:00:00 2001 From: Egor Egorov Date: Tue, 24 Oct 2023 14:54:09 +0300 Subject: [PATCH] Make Glia.configuration private(set) --- GliaWidgets/Public/Glia/Glia.swift | 3 ++- GliaWidgets/Sources/Interactor/Interactor.swift | 4 ---- .../Sources/ChatViewModel/ChatViewModelTests+CustomCard.swift | 1 - .../Sources/ChatViewModel/ChatViewModelTests+Gva.swift | 3 --- .../ChatViewModel/ChatViewModelTests+Transferring.swift | 1 - GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift | 4 ++-- 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/GliaWidgets/Public/Glia/Glia.swift b/GliaWidgets/Public/Glia/Glia.swift index 74899a9b7..7b2658f3e 100644 --- a/GliaWidgets/Public/Glia/Glia.swift +++ b/GliaWidgets/Public/Glia/Glia.swift @@ -94,7 +94,7 @@ public class Glia { var uiConfig: RemoteConfiguration? var assetsBuilder: RemoteConfiguration.AssetsBuilder = .standard - var configuration: Configuration? + private(set) var configuration: Configuration? init(environment: Environment) { self.environment = environment @@ -375,6 +375,7 @@ extension Glia { #if DEBUG extension Glia { + /// Used for unit tests only var isConfigured: Bool { configuration != nil } diff --git a/GliaWidgets/Sources/Interactor/Interactor.swift b/GliaWidgets/Sources/Interactor/Interactor.swift index b6ce22298..7873b4d39 100644 --- a/GliaWidgets/Sources/Interactor/Interactor.swift +++ b/GliaWidgets/Sources/Interactor/Interactor.swift @@ -80,10 +80,6 @@ class Interactor { self.environment = environment } - deinit { - print("☠️", Self.self, ObjectIdentifier(self)) - } - func addObserver(_ observer: AnyObject, handler: @escaping EventHandler) { guard !observers.contains(where: { $0().0 === observer }) else { return } observers.append { [weak observer] in (observer, handler) } diff --git a/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+CustomCard.swift b/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+CustomCard.swift index 80ee11a0b..a8fa5d420 100644 --- a/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+CustomCard.swift +++ b/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+CustomCard.swift @@ -21,7 +21,6 @@ extension ChatViewModelTests { } let interactorMock = Interactor.mock(environment: interactorEnv) interactorMock.state = .engaged(nil) -// interactorMock.isConfigurationPerformed = true var env = ChatViewModel.Environment.failing() env.fileManager.fileExistsAtPath = { _ in true } diff --git a/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Gva.swift b/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Gva.swift index ba7265e22..2f61e91e0 100644 --- a/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Gva.swift +++ b/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Gva.swift @@ -58,7 +58,6 @@ extension ChatViewModelTests { } let interactorMock = Interactor.mock(environment: interactorEnv) interactorMock.state = .engaged(nil) -// interactorMock.isConfigurationPerformed = true viewModel = .mock(interactor: interactorMock, environment: env) @@ -80,7 +79,6 @@ extension ChatViewModelTests { let interactorMock = Interactor.mock(environment: interactorEnv) interactorMock.state = .none -// interactorMock.isConfigurationPerformed = true var env = ChatViewModel.Environment.failing() env.fileManager.fileExistsAtPath = { _ in true } @@ -136,7 +134,6 @@ extension ChatViewModelTests { } let interactorMock = Interactor.mock(environment: interactorEnv) interactorMock.state = .engaged(nil) -// interactorMock.isConfigurationPerformed = true let viewModel = ChatViewModel.mock(interactor: interactorMock, environment: env) let messagesSectionIndex = 3 diff --git a/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Transferring.swift b/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Transferring.swift index 72a47faa0..bf390e669 100644 --- a/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Transferring.swift +++ b/GliaWidgetsTests/Sources/ChatViewModel/ChatViewModelTests+Transferring.swift @@ -20,7 +20,6 @@ extension ChatViewModelTests { interactorEnv.coreSdk.queueForEngagement = { _, _ in } interactorEnv.coreSdk.configureWithInteractor = { _ in } let interactorMock = Interactor.mock(environment: interactorEnv) -// interactorMock.isConfigurationPerformed = true var env = ChatViewModel.Environment.failing() env.fileManager.fileExistsAtPath = { _ in true } diff --git a/GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift b/GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift index 4ca456bde..cd49506ad 100644 --- a/GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift +++ b/GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift @@ -282,8 +282,8 @@ extension GliaTests { } environment.coreSdk.localeProvider.getRemoteString = { _ in "" } - environment.coreSdk.configureWithInteractor = { _ in } - environment.coreSdk.configureWithConfiguration = { _, completion in + environment.coreSDKConfigurator.configureWithInteractor = { _ in } + environment.coreSDKConfigurator.configureWithConfiguration = { _, completion in // Simulating what happens in the Widgets when the configuration gets done Glia.sharedInstance.stringProviding = StringProviding( getRemoteString: environment.coreSdk.localeProvider.getRemoteString