Skip to content

Commit f8c3041

Browse files
committed
Merge branch 'hotfix/5.257.1'
2 parents 7b37151 + 28fa140 commit f8c3041

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@ class BrowserViewModel @Inject constructor(
509509
) {
510510
val duckAiFullScreenMode = duckAiFeatureState.showFullScreenMode.value
511511
logcat(INFO) { "Duck.ai openDuckChat duckChatSessionActive $duckChatSessionActive" }
512-
sendCommand(OpenDuckChat(duckChatUrl, duckChatSessionActive, withTransition, tabs.value.size, duckAiFullScreenMode))
512+
val tabsCount = tabs.value?.size ?: 0
513+
sendCommand(OpenDuckChat(duckChatUrl, duckChatSessionActive, withTransition, tabsCount, duckAiFullScreenMode))
513514
}
514515
}
515516

app/src/test/java/com/duckduckgo/app/browser/BrowserViewModelTest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,39 @@ class BrowserViewModelTest {
612612
}
613613
}
614614

615+
@Test
616+
fun `when openDuckChat called and tabs are null then command is sent with 0 tabs`() = runTest {
617+
doReturn(MutableLiveData(null)).whenever(mockTabRepository).liveTabs
618+
initTestee()
619+
620+
testee.openDuckChat(duckChatUrl = "duck://chat", duckChatSessionActive = false, withTransition = false)
621+
622+
testee.commands.test {
623+
val command = awaitItem()
624+
assertTrue(command is Command.OpenDuckChat)
625+
command as Command.OpenDuckChat
626+
assertEquals(0, command.tabs)
627+
cancelAndIgnoreRemainingEvents()
628+
}
629+
}
630+
631+
@Test
632+
fun `when openDuckChat called then command is sent with correct tab count`() = runTest {
633+
val tabs = listOf(TabEntity("1", "", "", position = 0))
634+
doReturn(MutableLiveData(tabs)).whenever(mockTabRepository).liveTabs
635+
initTestee()
636+
637+
testee.openDuckChat(duckChatUrl = "duck://chat", duckChatSessionActive = false, withTransition = false)
638+
639+
testee.commands.test {
640+
val command = awaitItem()
641+
assertTrue(command is Command.OpenDuckChat)
642+
command as Command.OpenDuckChat
643+
assertEquals(tabs.size, command.tabs)
644+
cancelAndIgnoreRemainingEvents()
645+
}
646+
}
647+
615648
private fun initTestee() {
616649
testee = BrowserViewModel(
617650
tabRepository = mockTabRepository,

app/version/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=5.257.0
1+
VERSION=5.257.1

0 commit comments

Comments
 (0)