From 996be6ffb8effc2220a11362bbe9110e9b15b6bd Mon Sep 17 00:00:00 2001 From: Andriy Shevtsov Date: Wed, 18 Dec 2024 12:56:40 +0200 Subject: [PATCH] fixup! Implement Entry Widget for ongoing engagement cases --- ...HasOngoingSecureConversationUseCaseTest.kt | 7 +- .../engagement/domain/EngagementDomainTest.kt | 28 ++++--- .../entrywidget/EntryWidgetControllerTest.kt | 79 +++++++++++++------ 3 files changed, 78 insertions(+), 36 deletions(-) diff --git a/widgetssdk/src/test/java/com/glia/widgets/core/secureconversations/domain/HasOngoingSecureConversationUseCaseTest.kt b/widgetssdk/src/test/java/com/glia/widgets/core/secureconversations/domain/HasOngoingSecureConversationUseCaseTest.kt index ad8d15d4f..54011661b 100644 --- a/widgetssdk/src/test/java/com/glia/widgets/core/secureconversations/domain/HasOngoingSecureConversationUseCaseTest.kt +++ b/widgetssdk/src/test/java/com/glia/widgets/core/secureconversations/domain/HasOngoingSecureConversationUseCaseTest.kt @@ -1,5 +1,6 @@ package com.glia.widgets.core.secureconversations.domain +import com.glia.widgets.chat.domain.IsAuthenticatedUseCase import com.glia.widgets.core.secureconversations.SecureConversationsRepository import com.glia.widgets.engagement.State import com.glia.widgets.engagement.domain.EngagementStateUseCase @@ -20,6 +21,7 @@ class HasOngoingSecureConversationUseCaseTest { private lateinit var repository: SecureConversationsRepository private lateinit var useCase: HasOngoingSecureConversationUseCase private lateinit var engagementStateUseCase: EngagementStateUseCase + private lateinit var isAuthenticatedUseCase: IsAuthenticatedUseCase @Before fun setUp() { @@ -27,7 +29,8 @@ class HasOngoingSecureConversationUseCaseTest { RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() } repository = mockk() engagementStateUseCase = mockk() - useCase = HasOngoingSecureConversationUseCase(repository, engagementStateUseCase) + isAuthenticatedUseCase = mockk() + useCase = HasOngoingSecureConversationUseCase(repository, isAuthenticatedUseCase, engagementStateUseCase) } @After @@ -40,6 +43,7 @@ class HasOngoingSecureConversationUseCaseTest { every { repository.pendingSecureConversationsStatusObservable } returns Flowable.just(pendingSC) every { repository.unreadMessagesCountObservable } returns Flowable.just(unreadMessagesCount) every { engagementStateUseCase() } returns Flowable.just(if (transferredSC) State.TransferredToSecureConversation else State.NoEngagement) + every { isAuthenticatedUseCase() } returns true } @Test @@ -93,6 +97,7 @@ class HasOngoingSecureConversationUseCaseTest { every { repository.pendingSecureConversationsStatusObservable } returns pendingSC every { repository.unreadMessagesCountObservable } returns Flowable.just(0) every { engagementStateUseCase() } returns Flowable.just(State.NoEngagement) + every { isAuthenticatedUseCase() } returns true useCase().test().assertValue(false) val callback = mockk<(Boolean) -> Unit>() diff --git a/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt b/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt index dedce5011..bd416534e 100644 --- a/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt +++ b/widgetssdk/src/test/java/com/glia/widgets/engagement/domain/EngagementDomainTest.kt @@ -214,9 +214,10 @@ class EngagementDomainTest { } @Test - fun `EngagementTypeUseCase isCallVisualizerScreenSharing returns true when current engagement is call visualizer and has no media`() { + fun `EngagementTypeUseCase isCallVisualizerScreenSharing returns true when current engagement is call visualizer`() { val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase = mockk(relaxUnitFun = true) val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase = mockk(relaxUnitFun = true) + val screenSharingUseCase: ScreenSharingUseCase = mockk(relaxUnitFun = true) val operatorMediaUseCase: OperatorMediaUseCase = mockk(relaxUnitFun = true) val visitorMediaUseCase: VisitorMediaUseCase = mockk(relaxUnitFun = true) val isOperatorPresentUseCase: IsOperatorPresentUseCase = mockk(relaxUnitFun = true) @@ -224,10 +225,12 @@ class EngagementDomainTest { every { isCurrentEngagementCallVisualizerUseCase() } returns true every { visitorMediaUseCase.hasMedia } returns false every { operatorMediaUseCase.hasMedia } returns false + every { screenSharingUseCase.isSharing } returns true val useCase: EngagementTypeUseCase = EngagementTypeUseCaseImpl( isQueueingOrLiveEngagementUseCase = isQueueingOrLiveEngagementUseCase, isCurrentEngagementCallVisualizerUseCase = isCurrentEngagementCallVisualizerUseCase, + screenSharingUseCase = screenSharingUseCase, operatorMediaUseCase = operatorMediaUseCase, visitorMediaUseCase = visitorMediaUseCase, isOperatorPresentUseCase = isOperatorPresentUseCase @@ -237,32 +240,36 @@ class EngagementDomainTest { } @Test - fun `EngagementTypeUseCase isCallVisualizerScreenSharing returns false when engagement has media`() { + fun `EngagementTypeUseCase isCallVisualizerScreenSharing returns true even when engagement has media`() { val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase = mockk(relaxUnitFun = true) val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase = mockk(relaxUnitFun = true) + val screenSharingUseCase: ScreenSharingUseCase = mockk(relaxUnitFun = true) val operatorMediaUseCase: OperatorMediaUseCase = mockk(relaxUnitFun = true) val visitorMediaUseCase: VisitorMediaUseCase = mockk(relaxUnitFun = true) val isOperatorPresentUseCase: IsOperatorPresentUseCase = mockk(relaxUnitFun = true) every { isCurrentEngagementCallVisualizerUseCase() } returns true every { visitorMediaUseCase.hasMedia } returns true - every { operatorMediaUseCase.hasMedia } returns false + every { operatorMediaUseCase.hasMedia } returns true + every { screenSharingUseCase.isSharing } returns true val useCase: EngagementTypeUseCase = EngagementTypeUseCaseImpl( isQueueingOrLiveEngagementUseCase = isQueueingOrLiveEngagementUseCase, isCurrentEngagementCallVisualizerUseCase = isCurrentEngagementCallVisualizerUseCase, + screenSharingUseCase = screenSharingUseCase, operatorMediaUseCase = operatorMediaUseCase, visitorMediaUseCase = visitorMediaUseCase, isOperatorPresentUseCase = isOperatorPresentUseCase ) - assertFalse(useCase.isCallVisualizerScreenSharing) + assertTrue(useCase.isCallVisualizerScreenSharing) } @Test fun `EngagementTypeUseCase isChatEngagement returns true when engagement has no media, is not a cv and operator is present`() { val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase = mockk(relaxUnitFun = true) val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase = mockk(relaxUnitFun = true) + val screenSharingUseCase: ScreenSharingUseCase = mockk(relaxUnitFun = true) val operatorMediaUseCase: OperatorMediaUseCase = mockk(relaxUnitFun = true) val visitorMediaUseCase: VisitorMediaUseCase = mockk(relaxUnitFun = true) val isOperatorPresentUseCase: IsOperatorPresentUseCase = mockk(relaxUnitFun = true) @@ -276,6 +283,7 @@ class EngagementDomainTest { val useCase: EngagementTypeUseCase = EngagementTypeUseCaseImpl( isQueueingOrLiveEngagementUseCase = isQueueingOrLiveEngagementUseCase, isCurrentEngagementCallVisualizerUseCase = isCurrentEngagementCallVisualizerUseCase, + screenSharingUseCase = screenSharingUseCase, operatorMediaUseCase = operatorMediaUseCase, visitorMediaUseCase = visitorMediaUseCase, isOperatorPresentUseCase = isOperatorPresentUseCase @@ -288,6 +296,7 @@ class EngagementDomainTest { fun `EngagementTypeUseCase isMediaEngagement returns true when engagement has media and operator is present`() { val isQueueingOrLiveEngagementUseCase: IsQueueingOrLiveEngagementUseCase = mockk(relaxUnitFun = true) val isCurrentEngagementCallVisualizerUseCase: IsCurrentEngagementCallVisualizerUseCase = mockk(relaxUnitFun = true) + val screenSharingUseCase: ScreenSharingUseCase = mockk(relaxUnitFun = true) val operatorMediaUseCase: OperatorMediaUseCase = mockk(relaxUnitFun = true) val visitorMediaUseCase: VisitorMediaUseCase = mockk(relaxUnitFun = true) val isOperatorPresentUseCase: IsOperatorPresentUseCase = mockk(relaxUnitFun = true) @@ -300,6 +309,7 @@ class EngagementDomainTest { val useCase: EngagementTypeUseCase = EngagementTypeUseCaseImpl( isQueueingOrLiveEngagementUseCase = isQueueingOrLiveEngagementUseCase, isCurrentEngagementCallVisualizerUseCase = isCurrentEngagementCallVisualizerUseCase, + screenSharingUseCase = screenSharingUseCase, operatorMediaUseCase = operatorMediaUseCase, visitorMediaUseCase = visitorMediaUseCase, isOperatorPresentUseCase = isOperatorPresentUseCase @@ -385,7 +395,7 @@ class EngagementDomainTest { } @Test - fun `OperatorMediaUseCase invoke will emit data only when data is present`() { + fun `OperatorMediaUseCase invoke will emit empty media state even when data is absent`() { val video = mockk