@@ -20,6 +20,7 @@ import com.duckduckgo.browser.api.autocomplete.AutoCompleteFactory
2020import com.duckduckgo.browser.api.autocomplete.AutoCompleteSettings
2121import com.duckduckgo.common.test.CoroutineTestRule
2222import com.duckduckgo.common.utils.extensions.toBinaryString
23+ import com.duckduckgo.duckchat.api.DuckAiFeatureState
2324import com.duckduckgo.duckchat.api.DuckChat
2425import com.duckduckgo.duckchat.impl.inputscreen.ui.InputScreenConfigResolver
2526import com.duckduckgo.duckchat.impl.inputscreen.ui.command.Command
@@ -42,6 +43,7 @@ import com.duckduckgo.history.api.NavigationHistory
4243import com.duckduckgo.voice.api.VoiceSearchAvailability
4344import kotlinx.coroutines.ExperimentalCoroutinesApi
4445import kotlinx.coroutines.flow.MutableSharedFlow
46+ import kotlinx.coroutines.flow.MutableStateFlow
4547import kotlinx.coroutines.flow.flow
4648import kotlinx.coroutines.flow.flowOf
4749import kotlinx.coroutines.test.advanceTimeBy
@@ -86,6 +88,11 @@ class InputScreenViewModelTest {
8688 private val inputScreenConfigResolver: InputScreenConfigResolver = mock()
8789 private val omnibarRepository: OmnibarRepository = mock()
8890
91+ private val duckAiFeatureState: DuckAiFeatureState = mock()
92+ private val fullScreenModeDisabledFlow = MutableStateFlow (false )
93+ private val fullScreenModeEnabledFlow = MutableStateFlow (true )
94+ private val duckChatURL = " https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=5"
95+
8996 @Before
9097 fun setup () =
9198 runTest {
@@ -95,9 +102,11 @@ class InputScreenViewModelTest {
95102 flowOf(AutoCompleteResult (" " , listOf (AutoCompleteDefaultSuggestion (" suggestion" )))),
96103 )
97104 whenever(duckChat.wasOpenedBefore()).thenReturn(false )
105+ whenever(duckChat.getDuckChatUrl(any(), any())).thenReturn(duckChatURL)
98106 whenever(inputScreenConfigResolver.useTopBar()).thenReturn(true )
99107 whenever(voiceSearchAvailability.isVoiceSearchAvailable).thenReturn(true )
100108 whenever(omnibarRepository.omnibarType).thenReturn(OmnibarType .SINGLE_TOP )
109+ whenever(duckAiFeatureState.showFullScreenMode).thenReturn(fullScreenModeDisabledFlow)
101110 }
102111
103112 private fun createViewModel (currentOmnibarText : String = ""): InputScreenViewModel =
@@ -116,6 +125,7 @@ class InputScreenViewModelTest {
116125 inputScreenSessionUsageMetric = inputScreenSessionUsageMetric,
117126 inputScreenConfigResolver = inputScreenConfigResolver,
118127 omnibarRepository = omnibarRepository,
128+ duckAiFeatureState = duckAiFeatureState,
119129 )
120130
121131 @Test
@@ -2000,4 +2010,19 @@ class InputScreenViewModelTest {
20002010
20012011 assertFalse(viewModel.visibilityState.value.mainButtonsVisible)
20022012 }
2013+
2014+ @Test
2015+ fun `when fullscreen mode enabled submitting chat sends a query to the main fragment` () =
2016+ runTest {
2017+ whenever(duckAiFeatureState.showFullScreenMode).thenReturn(fullScreenModeEnabledFlow)
2018+ whenever(inputScreenSessionStore.hasUsedSearchMode()).thenReturn(false )
2019+ whenever(inputScreenSessionStore.hasUsedChatMode()).thenReturn(false )
2020+
2021+ val viewModel = createViewModel()
2022+ val query = " example"
2023+
2024+ viewModel.onChatSubmitted(query)
2025+
2026+ assertEquals(SubmitSearch (duckChatURL), viewModel.command.value)
2027+ }
20032028}
0 commit comments