Skip to content

Commit 3f5094e

Browse files
committed
Cover paneTitle propagation with ThreadsScreen and ChatsScreen tests
ThreadsScreenTest is a new Robolectric Compose UI test class that follows the ChannelsScreenTest / ChatsScreenTest pattern: mocks the chat client + state, renders the screen with default and custom titles, asserts the header text. ChatsScreenTest gains an equivalent custom-title case so the new remember(listContentMode, title) key path is exercised.
1 parent 1a26387 commit 3f5094e

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/chats/ChatsScreenTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,16 @@ internal class ChatsScreenTest : MockedChatClientTest {
8888
composeTestRule.onNodeWithTag("Stream_ThreadListLoading")
8989
.assertExists()
9090
}
91+
92+
@Test
93+
@UiThread
94+
fun `with custom title`() {
95+
composeTestRule.setContent {
96+
ChatTheme {
97+
ChatsScreen(title = "My Chats")
98+
}
99+
}
100+
101+
composeTestRule.onNodeWithText("My Chats").assertExists()
102+
}
91103
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
3+
*
4+
* Licensed under the Stream License;
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.getstream.chat.android.compose.ui.threads
18+
19+
import androidx.annotation.UiThread
20+
import androidx.compose.ui.test.junit4.createComposeRule
21+
import androidx.compose.ui.test.onNodeWithTag
22+
import androidx.compose.ui.test.onNodeWithText
23+
import androidx.test.ext.junit.runners.AndroidJUnit4
24+
import io.getstream.chat.android.client.test.MockedChatClientTest
25+
import io.getstream.chat.android.compose.ui.theme.ChatTheme
26+
import io.getstream.chat.android.models.ConnectionState
27+
import io.getstream.chat.android.randomUser
28+
import kotlinx.coroutines.flow.MutableStateFlow
29+
import org.junit.Before
30+
import org.junit.Rule
31+
import org.junit.Test
32+
import org.junit.runner.RunWith
33+
import org.mockito.kotlin.doReturn
34+
import org.mockito.kotlin.whenever
35+
import org.robolectric.annotation.Config
36+
37+
@RunWith(AndroidJUnit4::class)
38+
@Config(sdk = [33])
39+
internal class ThreadsScreenTest : MockedChatClientTest {
40+
41+
@get:Rule
42+
val composeTestRule = createComposeRule()
43+
44+
@Before
45+
fun prepare() {
46+
whenever(mockClientState.user) doReturn MutableStateFlow(randomUser())
47+
whenever(mockClientState.connectionState) doReturn MutableStateFlow(ConnectionState.Connected)
48+
}
49+
50+
@Test
51+
@UiThread
52+
fun `with default title`() {
53+
composeTestRule.setContent {
54+
ChatTheme {
55+
ThreadsScreen()
56+
}
57+
}
58+
59+
composeTestRule.onNodeWithText("Threads").assertExists()
60+
composeTestRule.onNodeWithTag("Stream_ThreadListLoading").assertExists()
61+
}
62+
63+
@Test
64+
@UiThread
65+
fun `with custom title`() {
66+
composeTestRule.setContent {
67+
ChatTheme {
68+
ThreadsScreen(title = "My Threads")
69+
}
70+
}
71+
72+
composeTestRule.onNodeWithText("My Threads").assertExists()
73+
}
74+
}

0 commit comments

Comments
 (0)