From 9e35c629aeea10c17cd7e9173a09dec9c6e1e5cf Mon Sep 17 00:00:00 2001 From: Egor Egorov Date: Mon, 23 Dec 2024 16:15:33 +0200 Subject: [PATCH] Handle `follow_up` end reason This commit adds handling of `follow_up` end reason the same way as `operator_hung_up` MOB-3900 --- .../Sources/Interactor/Interactor.swift | 2 +- .../Sources/InteractorTests.swift | 27 ++++++++++++++++++- Podfile | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/GliaWidgets/Sources/Interactor/Interactor.swift b/GliaWidgets/Sources/Interactor/Interactor.swift index 000b3e14a..b7bdff6ab 100644 --- a/GliaWidgets/Sources/Interactor/Interactor.swift +++ b/GliaWidgets/Sources/Interactor/Interactor.swift @@ -384,7 +384,7 @@ extension Interactor: CoreSdkClient.Interactable { switch reason { case .visitorHungUp: state = .ended(.byVisitor) - case .operatorHungUp: + case .operatorHungUp, .followUp: state = .ended(.byOperator) case .error: state = .ended(.byError) diff --git a/GliaWidgetsTests/Sources/InteractorTests.swift b/GliaWidgetsTests/Sources/InteractorTests.swift index 0bd8a29b4..b1cceb131 100644 --- a/GliaWidgetsTests/Sources/InteractorTests.swift +++ b/GliaWidgetsTests/Sources/InteractorTests.swift @@ -395,7 +395,32 @@ class InteractorTests: XCTestCase { XCTAssertEqual(callbacks, [.ended]) } - + + func test_endWithFollowUpSetsStateToEnded() throws { + enum Callback: Equatable { + case ended + } + + var callbacks: [Callback] = [] + var interactorEnv = Interactor.Environment.failing + interactorEnv.gcd = .mock + let interactor = Interactor.mock(environment: interactorEnv) + interactor.addObserver(self) { event in + switch event { + case .stateChanged(let state): + if case .ended = state { + callbacks.append(.ended) + } + default: + return + } + } + + interactor.end(with: .followUp) + + XCTAssertEqual(callbacks, [.ended]) + } + func test_sendMessageCallsCoreSdkSendMessageWithAttachment() throws { enum Callback: Equatable { case sendMessageWithAttachment diff --git a/Podfile b/Podfile index 9476f89d6..49b4ff266 100644 --- a/Podfile +++ b/Podfile @@ -18,7 +18,7 @@ target 'TestingApp' do end target 'GliaWidgets' do - pod 'GliaCoreSDK', '2.0.4' + pod 'GliaCoreSDK' swiftlint end