From 6d691a7b4c852031c3046a04b46b1e373035955e Mon Sep 17 00:00:00 2001 From: Rasmus Tauts Date: Tue, 31 Dec 2024 12:07:12 +0200 Subject: [PATCH] Log ongoing engagement event in Entry Widget Both platforms now also log when ongoing engagement MOB-3909 --- .../Sources/EntryWidget/EntryWidget.swift | 1 + .../EntryWidget/EntryWidgetTests.swift | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/GliaWidgets/Sources/EntryWidget/EntryWidget.swift b/GliaWidgets/Sources/EntryWidget/EntryWidget.swift index 40f14e9e8..0d166c243 100644 --- a/GliaWidgets/Sources/EntryWidget/EntryWidget.swift +++ b/GliaWidgets/Sources/EntryWidget/EntryWidget.swift @@ -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 { diff --git a/GliaWidgetsTests/Sources/EntryWidget/EntryWidgetTests.swift b/GliaWidgetsTests/Sources/EntryWidget/EntryWidgetTests.swift index 43e02bcab..a1cc1e59b 100644 --- a/GliaWidgetsTests/Sources/EntryWidget/EntryWidgetTests.swift +++ b/GliaWidgetsTests/Sources/EntryWidget/EntryWidgetTests.swift @@ -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)) + } }