Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log ongoing engagement event in Entry Widget #1174

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GliaWidgets/Sources/EntryWidget/EntryWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ private extension EntryWidget {
unreadSecureMessagesCount: Int?
) {
if let ongoingEngagement {
environment.log.info("Preparing items based on ongoing engagement")
igorkravchenko marked this conversation as resolved.
Show resolved Hide resolved
if ongoingEngagement.source == .callVisualizer {
viewState = .ongoingEngagement(.callVisualizer)
} else if ongoingEngagement.source == .coreEngagement {
Expand Down
36 changes: 36 additions & 0 deletions GliaWidgetsTests/Sources/EntryWidget/EntryWidgetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,40 @@ class EntryWidgetTests: XCTestCase {

XCTAssertEqual(calls, [.onCallVisualizerResume])
}

func test_ongoingEngagementLogMessageIsReceived() {
var logs: [String] = []
let expectedLogMessage = "Preparing items based on ongoing engagement"
let mockQueueId = "mockQueueId"
let mockQueue = Queue.mock(id: mockQueueId, media: [.messaging, .audio])

var queueMonitorEnvironment: QueuesMonitor.Environment = .mock
queueMonitorEnvironment.listQueues = { completion in
completion([mockQueue], nil)
}
queueMonitorEnvironment.subscribeForQueuesUpdates = { _, completion in
completion(.success(mockQueue))
return UUID.mock.uuidString
}
var environment = EntryWidget.Environment.mock()
environment.log.infoClosure = { logMessage, _, _, _ in
if let logMessageString = logMessage as? String {
logs.append(logMessageString)
}
}
environment.isAuthenticated = { false }
environment.queuesMonitor = QueuesMonitor(environment: queueMonitorEnvironment)
let interactor: Interactor = .mock()
interactor.setCurrentEngagement(.mock(media: .init(audio: .twoWay, video: .twoWay)))
environment.currentInteractor = { interactor }

let entryWidget = EntryWidget(
queueIds: [mockQueueId],
configuration: .default,
environment: environment
)

entryWidget.show(in: .init())
XCTAssertTrue(logs.contains(expectedLogMessage))
}
}
Loading