Skip to content

Commit 9ca08b8

Browse files
joshliebeanikiki
authored andcommitted
Fix disable Duck.ai in Duck.ai onboarding (#6500)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1200204095367872/task/1210939806484672?focus=true ### Description - Fixes the "Disable Duck.ai" button on the Duck.ai onboarding screen. ### Steps to test this PR - [x] Fresh install - [x] Go to Duck.ai and click “Disable Duck.ai" - [x] Verify that it navigates to the Duck.ai settings screen
1 parent 3187aa1 commit 9ca08b8

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/RealDuckChat.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,12 @@ class RealDuckChat @Inject constructor(
320320
}
321321

322322
override fun openDuckChatSettings() {
323-
// todo what happens with this interaction? closeDuckChat() would go back to browser activity
324323
val intent = globalActivityStarter.startIntent(context, DuckChatSettingsNoParams)
325324
intent?.flags = Intent.FLAG_ACTIVITY_NEW_TASK
326325
context.startActivity(intent)
327-
closeDuckChat()
326+
appCoroutineScope.launch {
327+
closeChatFlow.emit(Unit)
328+
}
328329
}
329330

330331
override fun closeDuckChat() {

duckchat/duckchat-impl/src/test/kotlin/com/duckduckgo/duckchat/impl/RealDuckChatTest.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,15 @@ class RealDuckChatTest {
414414
fun whenOpenDuckChatSettingsCalledThenGlobalActivityStarterCalledWithDuckChatSettings() = runTest {
415415
whenever(mockGlobalActivityStarter.startIntent(any(), any<ActivityParams>())).thenReturn(Intent())
416416

417+
val testLifecycleOwner = TestLifecycleOwner(initialState = CREATED)
418+
419+
var onCloseCalled = false
420+
testee.observeCloseEvent(testLifecycleOwner) {
421+
onCloseCalled = true
422+
}
423+
424+
testLifecycleOwner.currentState = Lifecycle.State.STARTED
425+
417426
testee.openDuckChatSettings()
418427

419428
verify(mockGlobalActivityStarter).startIntent(mockContext, DuckChatSettingsNoParams)
@@ -424,7 +433,9 @@ class RealDuckChatTest {
424433

425434
assertEquals(Intent.FLAG_ACTIVITY_NEW_TASK, capturedIntent.flags)
426435

427-
verify(testee).closeDuckChat()
436+
advanceUntilIdle()
437+
438+
assertTrue(onCloseCalled)
428439
}
429440

430441
@Test

0 commit comments

Comments
 (0)