feat(ui): add New Chat to History (#1124)

This commit is contained in:
M57 authored and GitHub committed 2026-09-15 11:06:24 +03:00
1 parent 66ca470880
commit 71463a5a9a
4 files changed
+50 -1

No files matched your search

@@ -5,6 +5,7 @@ import androidx.navigation3.runtime.NavKey
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
@@ -21,12 +22,14 @@ class NavigationControllerTest {
// Start fresh — no pinned back stack from a previous test
NavigationController.backStack = null
NavigationController.consumePendingSessionId()
NavigationController.consumePendingNewChatNavigation()
}
@After
fun tearDown() {
NavigationController.backStack = null
NavigationController.consumePendingSessionId()
NavigationController.consumePendingNewChatNavigation()
}
// ── Dedup guard: navigateTo with same key ──────────────────────────────
@@ -119,6 +122,18 @@ class NavigationControllerTest {
assertNull(NavigationController.consumePendingSessionId())
}
@Test
fun `openNewChat navigates to chat and exposes a consumable request`() {
val backStack = NavBackStack<NavKey>(HistoryScreen)
NavigationController.backStack = backStack
NavigationController.openNewChat()
assertEquals(ChatScreen, backStack.lastOrNull())
assertNotNull(NavigationController.consumePendingNewChatNavigation())
assertNull(NavigationController.consumePendingNewChatNavigation())
}
@Test
fun `openChatSession ignores blank ids`() {
val backStack = NavBackStack<NavKey>(HistoryScreen)