-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AND-304] Add snapshot tests for ThreadList and related components. (#…
…5610) * [AND-304] Add snapshot tests for ThreadList and related components. * [AND-304] Update CHANGELOG.md. --------- Co-authored-by: PetarVelikov <[email protected]>
- Loading branch information
1 parent
efde80e
commit 649148b
Showing
17 changed files
with
391 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...id-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/threads/ThreadItemTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
* | ||
* Licensed under the Stream License; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.getstream.chat.android.compose.ui.threads | ||
|
||
import app.cash.paparazzi.DeviceConfig | ||
import app.cash.paparazzi.Paparazzi | ||
import io.getstream.chat.android.compose.ui.SnapshotTest | ||
import io.getstream.chat.android.previewdata.PreviewThreadData | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class ThreadItemTest : SnapshotTest { | ||
|
||
@get:Rule | ||
override val paparazzi = Paparazzi(deviceConfig = DeviceConfig.PIXEL_2) | ||
|
||
@Test | ||
fun threadItem() { | ||
snapshotWithDarkMode { | ||
ThreadItem( | ||
thread = PreviewThreadData.thread, | ||
currentUser = PreviewThreadData.participant2, | ||
onThreadClick = { }, | ||
) | ||
} | ||
} | ||
} |
124 changes: 124 additions & 0 deletions
124
...id-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/threads/ThreadListTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. | ||
* | ||
* Licensed under the Stream License; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.getstream.chat.android.compose.ui.threads | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.ui.Modifier | ||
import app.cash.paparazzi.DeviceConfig | ||
import app.cash.paparazzi.Paparazzi | ||
import io.getstream.chat.android.compose.ui.SnapshotTest | ||
import io.getstream.chat.android.compose.ui.theme.ChatTheme | ||
import io.getstream.chat.android.previewdata.PreviewThreadData | ||
import io.getstream.chat.android.ui.common.state.threads.ThreadListState | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class ThreadListTest : SnapshotTest { | ||
|
||
@get:Rule | ||
override val paparazzi = Paparazzi(deviceConfig = DeviceConfig.PIXEL_2) | ||
|
||
@Test | ||
fun `loading threads`() { | ||
snapshotWithDarkMode { | ||
ThreadList( | ||
modifier = Modifier.background(ChatTheme.colors.appBackground), | ||
state = ThreadListState( | ||
threads = emptyList(), | ||
isLoading = true, | ||
isLoadingMore = false, | ||
unseenThreadsCount = 0, | ||
), | ||
onUnreadThreadsBannerClick = {}, | ||
onThreadClick = { }, | ||
onLoadMore = {}, | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun `empty threads`() { | ||
snapshotWithDarkMode { | ||
ThreadList( | ||
modifier = Modifier.background(ChatTheme.colors.appBackground), | ||
state = ThreadListState( | ||
threads = emptyList(), | ||
isLoading = false, | ||
isLoadingMore = false, | ||
unseenThreadsCount = 0, | ||
), | ||
onUnreadThreadsBannerClick = {}, | ||
onThreadClick = { }, | ||
onLoadMore = {}, | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun `loaded threads`() { | ||
snapshotWithDarkMode { | ||
ThreadList( | ||
modifier = Modifier.background(ChatTheme.colors.appBackground), | ||
state = ThreadListState( | ||
threads = PreviewThreadData.threadList, | ||
isLoading = false, | ||
isLoadingMore = false, | ||
unseenThreadsCount = 0, | ||
), | ||
onUnreadThreadsBannerClick = {}, | ||
onThreadClick = { }, | ||
onLoadMore = {}, | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun `loaded threads with unread banner`() { | ||
snapshotWithDarkMode { | ||
ThreadList( | ||
modifier = Modifier.background(ChatTheme.colors.appBackground), | ||
state = ThreadListState( | ||
threads = PreviewThreadData.threadList, | ||
isLoading = false, | ||
isLoadingMore = false, | ||
unseenThreadsCount = 1, | ||
), | ||
onUnreadThreadsBannerClick = {}, | ||
onThreadClick = { }, | ||
onLoadMore = {}, | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun `loading more threads`() { | ||
snapshotWithDarkMode { | ||
ThreadList( | ||
modifier = Modifier.background(ChatTheme.colors.appBackground), | ||
state = ThreadListState( | ||
threads = PreviewThreadData.threadList, | ||
isLoading = false, | ||
isLoadingMore = true, | ||
unseenThreadsCount = 0, | ||
), | ||
onUnreadThreadsBannerClick = {}, | ||
onThreadClick = { }, | ||
onLoadMore = {}, | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.