From 1c57bde7e57ea4ef558506e4ba858dddd20d033b Mon Sep 17 00:00:00 2001 From: Ilias Pavlidakis Date: Tue, 3 Dec 2024 11:43:38 +0200 Subject: [PATCH] Fix tests --- ...inatorStateMachine_JoiningStageTests.swift | 108 +++++++++--------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/StreamVideoTests/WebRTC/v2/StateMachine/Stages/WebRTCCoordinatorStateMachine_JoiningStageTests.swift b/StreamVideoTests/WebRTC/v2/StateMachine/Stages/WebRTCCoordinatorStateMachine_JoiningStageTests.swift index 0c4a42683..b5034924f 100644 --- a/StreamVideoTests/WebRTC/v2/StateMachine/Stages/WebRTCCoordinatorStateMachine_JoiningStageTests.swift +++ b/StreamVideoTests/WebRTC/v2/StateMachine/Stages/WebRTCCoordinatorStateMachine_JoiningStageTests.swift @@ -367,21 +367,22 @@ final class WebRTCCoordinatorStateMachine_JoiningStageTests: XCTestCase, @unchec from: .connected, expectedTarget: .joined, subject: subject - ) { [mockCoordinatorStack] _ in - let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) - let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) - - switch telemetry.data { - case .connectionTimeSeconds: - XCTAssertTrue(true) - case .reconnection: - XCTFail() - case .none: - XCTFail() - } - } + ) { _ in } cancellable.cancel() + + let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) + await fulfillment { mockSignalService.sendStatsWasCalledWithRequest?.telemetry != nil } + let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) + + switch telemetry.data { + case .connectionTimeSeconds: + XCTAssertTrue(true) + case .reconnection: + XCTFail() + case .none: + XCTFail() + } } // MARK: - transition from connected with isRejoiningFromSessionID != nil @@ -744,21 +745,22 @@ final class WebRTCCoordinatorStateMachine_JoiningStageTests: XCTestCase, @unchec from: .connected, expectedTarget: .joined, subject: subject - ) { [mockCoordinatorStack] _ in - let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) - let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) - - switch telemetry.data { - case .connectionTimeSeconds: - XCTFail() - case let .reconnection(reconnection): - XCTAssertEqual(reconnection.strategy, .rejoin) - case .none: - XCTFail() - } - } + ) { _ in } cancellable.cancel() + + let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) + await fulfillment { mockSignalService.sendStatsWasCalledWithRequest?.telemetry != nil } + let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) + + switch telemetry.data { + case .connectionTimeSeconds: + XCTFail() + case let .reconnection(reconnection): + XCTAssertEqual(reconnection.strategy, .rejoin) + case .none: + XCTFail() + } } // MARK: - transition from fastReconnected @@ -942,21 +944,22 @@ final class WebRTCCoordinatorStateMachine_JoiningStageTests: XCTestCase, @unchec from: .fastReconnected, expectedTarget: .joined, subject: subject - ) { [mockCoordinatorStack] _ in - let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) - let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) - - switch telemetry.data { - case .connectionTimeSeconds: - XCTFail() - case let .reconnection(reconnection): - XCTAssertEqual(reconnection.strategy, .fast) - case .none: - XCTFail() - } - } + ) { _ in } cancellable.cancel() + + let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) + await fulfillment { mockSignalService.sendStatsWasCalledWithRequest?.telemetry != nil } + let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) + + switch telemetry.data { + case .connectionTimeSeconds: + XCTFail() + case let .reconnection(reconnection): + XCTAssertEqual(reconnection.strategy, .fast) + case .none: + XCTFail() + } } // MARK: - transition from migrated @@ -1319,21 +1322,22 @@ final class WebRTCCoordinatorStateMachine_JoiningStageTests: XCTestCase, @unchec from: .migrated, expectedTarget: .joined, subject: subject - ) { [mockCoordinatorStack] _ in - let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) - let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) - - switch telemetry.data { - case .connectionTimeSeconds: - XCTFail() - case let .reconnection(reconnection): - XCTAssertEqual(reconnection.strategy, .migrate) - case .none: - XCTFail() - } - } + ) { _ in } cancellable.cancel() + + let mockSignalService = try XCTUnwrap(mockCoordinatorStack?.sfuStack.service) + await fulfillment { mockSignalService.sendStatsWasCalledWithRequest?.telemetry != nil } + let telemetry = try XCTUnwrap(mockSignalService.sendStatsWasCalledWithRequest?.telemetry) + + switch telemetry.data { + case .connectionTimeSeconds: + XCTFail() + case let .reconnection(reconnection): + XCTAssertEqual(reconnection.strategy, .migrate) + case .none: + XCTFail() + } } // MARK: - Private helpers