Skip to content

Commit

Permalink
Log ongoing engagement event in Entry Widget
Browse files Browse the repository at this point in the history
Both platforms now also log when ongoing engagement

MOB-3909
  • Loading branch information
rasmustautsglia authored and github-review-helper committed Jan 7, 2025
1 parent e332c67 commit 6d691a7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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")
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))
}
}

0 comments on commit 6d691a7

Please sign in to comment.