Skip to content

Commit

Permalink
fixup! Use queues from QueuesMonitor to determine Secure Conversation…
Browse files Browse the repository at this point in the history
…s availability
  • Loading branch information
ykyivskyi-gl committed Nov 4, 2024
1 parent 587ef04 commit 8120070
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension EngagementCoordinator.Environment {
},
flipCameraButtonStyle: .nop,
alertManager: .mock(),
queuesMonitor: .mock
queuesMonitor: .mock()
)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension Glia.Environment {
snackBar: .mock,
processInfo: .mock(),
cameraDeviceManager: { .mock },
queuesMonitor: .mock,
queuesMonitor: .mock(),
isAuthenticated: { false }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
extension Interactor.Environment {
static let mock = Self(
coreSdk: .mock,
queuesMonitor: .mock,
queuesMonitor: .mock(),
gcd: .mock,
log: .mock
)
Expand Down
4 changes: 0 additions & 4 deletions GliaWidgets/Sources/QueuesMonitor/QueuesMonitor.Mock.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#if DEBUG
extension QueuesMonitor {
static var mock: Self {
mock()
}

static func mock(
listQueues: CoreSdkClient.ListQueues? = nil,
subscribeForQueuesUpdates: CoreSdkClient.SubscribeForQueuesUpdates? = nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension SecureConversationsTranscriptModelTests {
listQueues: modelEnv.listQueues,
isAuthenticated: { true },
log: logger,
queuesMonitor: .mock
queuesMonitor: .mock()
)

let viewModel = TranscriptModel(
Expand Down Expand Up @@ -198,7 +198,7 @@ private extension SecureConversationsTranscriptModelTests {
listQueues: modelEnv.listQueues,
isAuthenticated: { true },
log: logger,
queuesMonitor: .mock
queuesMonitor: .mock()
)

return TranscriptModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private extension SecureConversationsTranscriptModelTests {
listQueues: modelEnv.listQueues,
isAuthenticated: { true },
log: logger,
queuesMonitor: .mock
queuesMonitor: .mock()
)

return TranscriptModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private extension SecureConversationsTranscriptModelTests {
listQueues: modelEnv.listQueues,
isAuthenticated: { true },
log: logger,
queuesMonitor: .mock
queuesMonitor: .mock()
)

return TranscriptModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private extension SecureConversationsTranscriptModelTests {
listQueues: modelEnv.listQueues,
isAuthenticated: { true },
log: logger,
queuesMonitor: .mock
queuesMonitor: .mock()
)

return TranscriptModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ extension SecureConversations.Coordinator.Environment {
cameraDeviceManager: { .mock },
flipCameraButtonStyle: .nop,
alertManager: .mock(),
queuesMonitor: .mock
queuesMonitor: .mock()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension SecureConversations.Availability {
listQueues: { _ in },
isAuthenticated: { true },
log: .mock,
queuesMonitor: .mock
queuesMonitor: .mock()
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class ChatViewModelTests: XCTestCase {
// Given
enum Calls { case fetchSiteConfigurations }
var calls: [Calls] = []
let interactorEnv = Interactor.Environment(coreSdk: .failing, queuesMonitor: .mock, gcd: .mock, log: .mock)
let interactorEnv = Interactor.Environment(coreSdk: .failing, queuesMonitor: .mock(), gcd: .mock, log: .mock)
let interactor = Interactor.mock(environment: interactorEnv)
var viewModelEnv = ChatViewModel.Environment.failing()
viewModelEnv.fileManager.urlsForDirectoryInDomainMask = { _, _ in [.mock] }
Expand All @@ -261,7 +261,7 @@ class ChatViewModelTests: XCTestCase {
// Given
enum Calls { case fetchSiteConfigurations }
var calls: [Calls] = []
var interactorEnv = Interactor.Environment.init(coreSdk: .failing, queuesMonitor: .mock, gcd: .mock, log: .mock)
var interactorEnv = Interactor.Environment.init(coreSdk: .failing, queuesMonitor: .mock(), gcd: .mock, log: .mock)
var interactorLog = CoreSdkClient.Logger.failing
interactorLog.infoClosure = { _, _, _, _ in }
interactorLog.prefixedClosure = { _ in interactorLog }
Expand Down Expand Up @@ -457,7 +457,7 @@ class ChatViewModelTests: XCTestCase {
listQueues: transcriptModelEnv.listQueues,
isAuthenticated: { true },
log: logger,
queuesMonitor: .mock
queuesMonitor: .mock()
)
let transcriptModel = TranscriptModel(
isCustomCardSupported: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ extension ChatCoordinator.Environment {
cameraDeviceManager: { .mock },
flipCameraButtonStyle: .nop,
alertManager: .mock(),
queuesMonitor: .mock
queuesMonitor: .mock()
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EngagementCoordinatorSurveyTests: XCTestCase {
},
mediaStreams: .init(audio: .none, video: .oneWay)
)
let interactor = Interactor.mock(environment: .init(coreSdk: coreSdkClient, queuesMonitor: .mock, gcd: .failing, log: .failing))
let interactor = Interactor.mock(environment: .init(coreSdk: coreSdkClient, queuesMonitor: .mock(), gcd: .failing, log: .failing))
interactor.currentEngagement = engagement
var alertManagerEnv = AlertManager.Environment.failing()
var log = CoreSdkClient.Logger.failing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private extension GliaTests {
completion(.success(()))
}
sdkEnv.coreSdk.getCurrentEngagement = { nil }
sdkEnv.queuesMonitor = .mock
sdkEnv.queuesMonitor = .mock()
let window = UIWindow(frame: .zero)
window.makeKeyAndVisible()
sdkEnv.uiApplication.windows = { [window] }
Expand Down
24 changes: 12 additions & 12 deletions GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension GliaTests {
sdkEnv.coreSDKConfigurator.configureWithConfiguration = { _, completion in
completion(.success(()))
}
sdkEnv.queuesMonitor = .mock
sdkEnv.queuesMonitor = .mock()
let window = UIWindow(frame: .zero)
window.makeKeyAndVisible()
sdkEnv.uiApplication.windows = { [window] }
Expand Down Expand Up @@ -61,7 +61,7 @@ extension GliaTests {
}
environment.coreSdk.localeProvider.getRemoteString = { _ in nil }
environment.coreSDKConfigurator.configureWithInteractor = { _ in }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

let rootCoordinator = EngagementCoordinator.mock(
engagementKind: .chat,
Expand Down Expand Up @@ -104,7 +104,7 @@ extension GliaTests {
sdk.environment.coreSDKConfigurator.configureWithConfiguration = { _, completion in
completion(.success(()))
}
sdk.environment.queuesMonitor = .mock
sdk.environment.queuesMonitor = .mock()
try sdk.configure(
with: .mock(),
theme: .mock()
Expand Down Expand Up @@ -138,7 +138,7 @@ extension GliaTests {
}
environment.coreSdk.localeProvider.getRemoteString = { _ in nil }
environment.coreSdk.getCurrentEngagement = { nil }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()
let sdk = Glia(environment: environment)
try sdk.configure(
with: .mock(),
Expand Down Expand Up @@ -179,7 +179,7 @@ extension GliaTests {
environment.createRootCoordinator = { _, _, _, _, _, _, _ in
.mock(environment: .engagementCoordEnvironmentWithKeyWindow)
}
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()
let sdk = Glia(environment: environment)
try sdk.start(.chat, configuration: .mock(), queueID: "queueId", theme: .mock())

Expand Down Expand Up @@ -219,7 +219,7 @@ extension GliaTests {
}
environment.coreSDKConfigurator.configureWithInteractor = { _ in }
environment.coreSdk.localeProvider.getRemoteString = { _ in nil }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

let sdk = Glia(environment: environment)

Expand Down Expand Up @@ -267,7 +267,7 @@ extension GliaTests {
}
environment.coreSDKConfigurator.configureWithInteractor = { _ in }
environment.coreSdk.getCurrentEngagement = { nil }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()
var logger = CoreSdkClient.Logger.failing
logger.configureLocalLogLevelClosure = { _ in }
logger.configureRemoteLogLevelClosure = { _ in }
Expand Down Expand Up @@ -308,7 +308,7 @@ extension GliaTests {
logger.infoClosure = { _, _, _, _ in }
logger.prefixedClosure = { _ in logger }
environment.coreSdk.createLogger = { _ in logger }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

var resultingViewFactory: ViewFactory?

Expand Down Expand Up @@ -360,7 +360,7 @@ extension GliaTests {
logger.prefixedClosure = { _ in logger }
environment.coreSdk.createLogger = { _ in logger }
environment.print = .mock
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()
var resultingViewFactory: ViewFactory?

environment.createRootCoordinator = { _, viewFactory, _, _, _, _, _ in
Expand Down Expand Up @@ -410,7 +410,7 @@ extension GliaTests {
environment.coreSdk.createLogger = { _ in logger }
environment.print = .mock
environment.conditionalCompilation.isDebug = { true }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

var resultingViewFactory: ViewFactory?

Expand All @@ -434,7 +434,7 @@ extension GliaTests {
}
environment.coreSDKConfigurator.configureWithInteractor = { _ in }
environment.coreSdk.getCurrentEngagement = { nil }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

let sdk = Glia(environment: environment)

Expand Down Expand Up @@ -468,7 +468,7 @@ extension GliaTests {
environment.coreSdk.createLogger = { _ in logger }
environment.print = .mock
environment.conditionalCompilation.isDebug = { true }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

var resultingViewFactory: ViewFactory?

Expand Down
4 changes: 2 additions & 2 deletions GliaWidgetsTests/Sources/Glia/GliaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ final class GliaTests: XCTestCase {
gliaEnv.coreSdk.fetchSiteConfigurations = { _ in }
gliaEnv.uuid = { .mock }
gliaEnv.gcd.mainQueue.async = { callback in callback() }
gliaEnv.queuesMonitor = .mock
gliaEnv.queuesMonitor = .mock()

let expectedTheme = Theme.mock(
colorStyle: .custom(.init()),
Expand Down Expand Up @@ -604,7 +604,7 @@ final class GliaTests: XCTestCase {
var engCoordEnvironment = EngagementCoordinator.Environment.engagementCoordEnvironmentWithKeyWindow
engCoordEnvironment.fileManager = .mock
environment.createRootCoordinator = { _, _, _, _, _, _, _ in EngagementCoordinator.mock(environment: engCoordEnvironment) }
environment.queuesMonitor = .mock
environment.queuesMonitor = .mock()

let sdk = Glia(environment: environment)
enum Call {
Expand Down
4 changes: 2 additions & 2 deletions GliaWidgetsTests/Sources/InteractorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InteractorTests: XCTestCase {
coreSdkCalls.append(.queueForEngagement)
}

var interactorEnv = Interactor.Environment(coreSdk: coreSdk, queuesMonitor: .mock, gcd: .failing, log: .failing)
var interactorEnv = Interactor.Environment(coreSdk: coreSdk, queuesMonitor: .mock(), gcd: .failing, log: .failing)
interactorEnv.log.infoClosure = { _, _, _, _ in }
interactorEnv.log.prefixedClosure = { _ in interactorEnv.log }

Expand All @@ -55,7 +55,7 @@ class InteractorTests: XCTestCase {

interactor = .init(
visitorContext: nil,
environment: .init(coreSdk: .failing, queuesMonitor: .mock, gcd: .mock, log: .failing)
environment: .init(coreSdk: .failing, queuesMonitor: .mock(), gcd: .mock, log: .failing)
)

interactor.addObserver(self, handler: { event in
Expand Down

0 comments on commit 8120070

Please sign in to comment.