diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelItemTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelItemTest.kt index 3a1e1d76392..ce4e3264c46 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelItemTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelItemTest.kt @@ -28,18 +28,18 @@ class ChannelItemTest : ComposeScreenshotTest() { fun channelItemWithUnreadCount() = runScreenshotTest { ChannelItem( channelItem = ChannelItemState( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), TestData.message2(), - ) - unreadCount = 2 - lastMessageAt = TestData.date2() - }, + ), + unreadCount = 2, + lastMessageAt = TestData.date2(), + ), ), currentUser = TestData.user1(), onChannelClick = {}, @@ -51,17 +51,17 @@ class ChannelItemTest : ComposeScreenshotTest() { fun channelItemWithoutCurrentUser() = runScreenshotTest { ChannelItem( channelItem = ChannelItemState( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), TestData.message2(), - ) - lastMessageAt = TestData.date2() - }, + ), + lastMessageAt = TestData.date2(), + ), ), currentUser = null, onChannelClick = {}, @@ -73,17 +73,17 @@ class ChannelItemTest : ComposeScreenshotTest() { fun channelItemForMutedChannel() = runScreenshotTest { ChannelItem( channelItem = ChannelItemState( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), TestData.message2(), - ) - lastMessageAt = TestData.date2() - }, + ), + lastMessageAt = TestData.date2(), + ), isMuted = true, ), currentUser = TestData.user1(), @@ -96,12 +96,12 @@ class ChannelItemTest : ComposeScreenshotTest() { fun channelItemForChannelWithoutMessages() = runScreenshotTest { ChannelItem( channelItem = ChannelItemState( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) - }, + ), + ), ), currentUser = TestData.user1(), onChannelClick = {}, diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListHeaderTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListHeaderTest.kt index 809337029ec..42ad7eaf023 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListHeaderTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListHeaderTest.kt @@ -29,7 +29,7 @@ class ChannelListHeaderTest : ComposeScreenshotTest() { ChannelListHeader( title = "Stream Chat", currentUser = TestData.user1(), - connectionState = ConnectionState.CONNECTED, + connectionState = ConnectionState.Connected, ) } @@ -38,7 +38,7 @@ class ChannelListHeaderTest : ComposeScreenshotTest() { ChannelListHeader( title = "Stream Chat", currentUser = TestData.user1(), - connectionState = ConnectionState.CONNECTING, + connectionState = ConnectionState.Connecting, ) } @@ -47,7 +47,7 @@ class ChannelListHeaderTest : ComposeScreenshotTest() { ChannelListHeader( title = "Stream Chat", currentUser = TestData.user1(), - connectionState = ConnectionState.OFFLINE, + connectionState = ConnectionState.Offline, ) } @@ -56,7 +56,7 @@ class ChannelListHeaderTest : ComposeScreenshotTest() { ChannelListHeader( title = "Stream Chat", currentUser = null, - connectionState = ConnectionState.CONNECTED, + connectionState = ConnectionState.Connected, ) } @@ -65,7 +65,7 @@ class ChannelListHeaderTest : ComposeScreenshotTest() { ChannelListHeader( title = "", currentUser = TestData.user1(), - connectionState = ConnectionState.CONNECTED, + connectionState = ConnectionState.Connected, ) } } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListTest.kt index c768ecb7843..11e4f7c23e5 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/ChannelListTest.kt @@ -36,52 +36,52 @@ class ChannelListTest : ComposeScreenshotTest() { isLoadingMore = false, channelItems = listOf( ChannelItemState( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), - ) - lastMessageAt = TestData.date1() - }, + ), + lastMessageAt = TestData.date1(), + ), ), ChannelItemState( - channel = TestData.channel2().apply { + channel = TestData.channel2().copy( members = listOf( TestData.member1(), TestData.member3(), - ) + ), messages = listOf( TestData.message2(), - ) - lastMessageAt = TestData.date2() - }, + ), + lastMessageAt = TestData.date2(), + ), ), ChannelItemState( - channel = TestData.channel3().apply { + channel = TestData.channel3().copy( members = listOf( TestData.member1(), TestData.member4(), - ) + ), messages = listOf( TestData.message3(), - ) - lastMessageAt = TestData.date3() - }, + ), + lastMessageAt = TestData.date3(), + ), ), ChannelItemState( - channel = TestData.channel4().apply { + channel = TestData.channel4().copy( members = listOf( TestData.member1(), TestData.member5(), - ) + ), messages = listOf( TestData.message4(), - ) - lastMessageAt = TestData.date4() - }, + ), + lastMessageAt = TestData.date4(), + ), ), ), ), @@ -111,52 +111,52 @@ class ChannelListTest : ComposeScreenshotTest() { isLoadingMore = true, channelItems = listOf( ChannelItemState( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), - ) - lastMessageAt = TestData.date1() - }, + ), + lastMessageAt = TestData.date1(), + ), ), ChannelItemState( - channel = TestData.channel2().apply { + channel = TestData.channel2().copy( members = listOf( TestData.member1(), TestData.member3(), - ) + ), messages = listOf( TestData.message2(), - ) - lastMessageAt = TestData.date2() - }, + ), + lastMessageAt = TestData.date2(), + ), ), ChannelItemState( - channel = TestData.channel3().apply { + channel = TestData.channel3().copy( members = listOf( TestData.member1(), TestData.member4(), - ) + ), messages = listOf( TestData.message3(), - ) - lastMessageAt = TestData.date3() - }, + ), + lastMessageAt = TestData.date3(), + ), ), ChannelItemState( - channel = TestData.channel4().apply { + channel = TestData.channel4().copy( members = listOf( TestData.member1(), TestData.member5(), - ) + ), messages = listOf( TestData.message4(), - ) - lastMessageAt = TestData.date4() - }, + ), + lastMessageAt = TestData.date4(), + ), ), ), ), diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/SelectedChannelMenuTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/SelectedChannelMenuTest.kt index 2d21d061986..cb42c863f97 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/SelectedChannelMenuTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/channels/SelectedChannelMenuTest.kt @@ -32,16 +32,16 @@ class SelectedChannelMenuTest : ComposeScreenshotTest() { Box(modifier = Modifier.fillMaxSize()) { SelectedChannelMenu( modifier = Modifier.align(Alignment.BottomCenter), - selectedChannel = TestData.channel1().apply { + selectedChannel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), TestData.member4(), TestData.member5(), - ) - messages = listOf(TestData.message1()) - }, + ), + messages = listOf(TestData.message1()), + ), isMuted = false, currentUser = TestData.user1(), onChannelOptionClick = {}, diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/ChannelAvatarTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/ChannelAvatarTest.kt index 42630867501..0152600ca3a 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/ChannelAvatarTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/ChannelAvatarTest.kt @@ -30,15 +30,15 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithFiveMembers() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), TestData.member4(), TestData.member5(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -47,14 +47,14 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithFourMembers() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), TestData.member4(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -63,13 +63,13 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithThreeMembers() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -78,12 +78,12 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithTwoMembers() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -92,11 +92,11 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithOneMember() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -105,15 +105,15 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithFiveMembersWithoutImages() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - TestData.member3().apply { user.image = "" }, - TestData.member4().apply { user.image = "" }, - TestData.member5().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member3().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member4().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member5().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -122,14 +122,14 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithFourMembersWithoutImages() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - TestData.member3().apply { user.image = "" }, - TestData.member4().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member3().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member4().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -138,13 +138,13 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithThreeMembersWithoutImages() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - TestData.member3().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member3().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -153,12 +153,12 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithTwoMembersWithoutImages() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -167,11 +167,11 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithOneMemberWithoutImage() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -180,12 +180,12 @@ class ChannelAvatarTest : ComposeScreenshotTest() { fun channelAvatarForChannelWithoutCurrentUser() = runScreenshotTest { ChannelAvatar( modifier = Modifier.size(40.dp), - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) - }, + ), + ), currentUser = null, ) } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/MessageReadStatusIconTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/MessageReadStatusIconTest.kt index 3ad766ebfba..7624d91c148 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/MessageReadStatusIconTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/components/MessageReadStatusIconTest.kt @@ -35,7 +35,7 @@ class MessageReadStatusIconTest : ComposeScreenshotTest() { @Test fun messageReadStatusIconForSentMessage() = runScreenshotTest { MessageReadStatusIcon( - message = TestData.message1().apply { syncStatus = SyncStatus.COMPLETED }, + message = TestData.message1().copy(syncStatus = SyncStatus.COMPLETED), isMessageRead = false, ) } @@ -43,7 +43,7 @@ class MessageReadStatusIconTest : ComposeScreenshotTest() { @Test fun messageReadStatusIconForSyncNeededMessage() = runScreenshotTest { MessageReadStatusIcon( - message = TestData.message1().apply { syncStatus = SyncStatus.SYNC_NEEDED }, + message = TestData.message1().copy(syncStatus = SyncStatus.SYNC_NEEDED), isMessageRead = false, ) } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/MessageListHeaderTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/MessageListHeaderTest.kt index df00aa3f10f..e5e05d9d271 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/MessageListHeaderTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/MessageListHeaderTest.kt @@ -28,31 +28,31 @@ class MessageListHeaderTest : ComposeScreenshotTest() { @Test fun messageListHeaderForConnectedState() = runScreenshotTest { MessageListHeader( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), - ) - memberCount = 3 - }, + ), + memberCount = 3, + ), currentUser = TestData.user1(), - connectionState = ConnectionState.CONNECTED, + connectionState = ConnectionState.Connected, ) } @Test fun messageListHeaderForThreadMode() = runScreenshotTest { MessageListHeader( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), - ) - }, + ), + ), currentUser = TestData.user1(), - connectionState = ConnectionState.CONNECTED, + connectionState = ConnectionState.Connected, messageMode = MessageMode.MessageThread(TestData.message1(), null), ) } @@ -60,15 +60,15 @@ class MessageListHeaderTest : ComposeScreenshotTest() { @Test fun messageListHeaderForOfflineState() = runScreenshotTest { MessageListHeader( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), - ) - }, + ), + ), currentUser = TestData.user1(), - connectionState = ConnectionState.OFFLINE, + connectionState = ConnectionState.Offline, messageMode = MessageMode.Normal, ) } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/SelectedReactionsMenuTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/SelectedReactionsMenuTest.kt index bdc332e4d11..8886171b54b 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/SelectedReactionsMenuTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/compose/messages/SelectedReactionsMenuTest.kt @@ -37,9 +37,9 @@ class SelectedReactionsMenuTest : ComposeScreenshotTest() { fun selectedReactionsMenuForOneReaction() { selectedReactionsMenu( currentUser = TestData.user1(), - selectedMessage = TestData.message1().apply { - latestReactions = mutableListOf(TestData.reaction1()) - }, + selectedMessage = TestData.message1().copy( + latestReactions = mutableListOf(TestData.reaction1()), + ), ) } @@ -47,14 +47,14 @@ class SelectedReactionsMenuTest : ComposeScreenshotTest() { fun selectedReactionsMenuForManyReactions() { selectedReactionsMenu( currentUser = TestData.user1(), - selectedMessage = TestData.message1().apply { + selectedMessage = TestData.message1().copy( latestReactions = mutableListOf( TestData.reaction1(), TestData.reaction2(), TestData.reaction3(), TestData.reaction4(), - ) - }, + ), + ), ) } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListItemViewTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListItemViewTest.kt index f5aa4bf5f45..a1cbafff633 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListItemViewTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListItemViewTest.kt @@ -24,6 +24,7 @@ import io.getstream.chat.android.core.internal.InternalStreamChatApi import io.getstream.chat.android.models.Channel import io.getstream.chat.android.ui.ChatUI import io.getstream.chat.android.ui.common.images.internal.StreamCoil +import io.getstream.chat.android.ui.feature.channels.list.adapter.ChannelListItem import io.getstream.chat.android.ui.feature.channels.list.adapter.ChannelListItemViewType import io.getstream.chat.android.ui.feature.channels.list.adapter.ChannelListPayloadDiff import io.getstream.chat.android.ui.feature.channels.list.adapter.viewholder.ChannelListItemViewHolderFactory @@ -47,35 +48,38 @@ class ChannelListItemViewTest : ScreenshotTest { @Test fun channelItemWithUnreadCount() { renderChannelListItemView( - TestData.channel1().apply { + TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), TestData.message2(), - ) - unreadCount = 2 - lastMessageAt = TestData.date2() - }, + ), + unreadCount = 2, + lastMessageAt = TestData.date2(), + ), ) } @Test fun channelItemForMutedChannel() { renderChannelListItemView( - TestData.channel1().apply { - members = listOf( - TestData.member1(), - TestData.member2(), + TestData.channel1().let { + it.copy( + members = listOf( + TestData.member1(), + TestData.member2(), + ), + messages = listOf( + TestData.message1(), + TestData.message2(), + ), + lastMessageAt = TestData.date2(), + extraData = it.extraData + mapOf("mutedChannel" to true), + // extraData = extraData["mutedChannel"] = true, ) - messages = listOf( - TestData.message1(), - TestData.message2(), - ) - lastMessageAt = TestData.date2() - extraData["mutedChannel"] = true }, ) } @@ -83,12 +87,12 @@ class ChannelListItemViewTest : ScreenshotTest { @Test fun channelItemForChannelWithoutMessages() { renderChannelListItemView( - TestData.channel1().apply { + TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) - }, + ), + ), ) } @@ -96,7 +100,8 @@ class ChannelListItemViewTest : ScreenshotTest { val viewHolder = ChannelListItemViewHolderFactory() .createViewHolder(FrameLayout(context), ChannelListItemViewType.DEFAULT) - viewHolder.bind(channel, CHANNEL_LIST_PAYLOAD_DIFF) + val channelListItem = ChannelListItem.ChannelItem(channel, emptyList()) + viewHolder.bind(channelListItem, CHANNEL_LIST_PAYLOAD_DIFF) compareScreenshot(viewHolder.itemView) } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListViewTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListViewTest.kt index 532e203d673..36c902d51fa 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListViewTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/channels/ChannelListViewTest.kt @@ -44,52 +44,56 @@ class ChannelListViewTest : ScreenshotTest { setChannels( listOf( ChannelListItem.ChannelItem( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), - ) - lastMessageAt = TestData.date1() - }, + ), + lastMessageAt = TestData.date1(), + ), + emptyList(), ), ChannelListItem.ChannelItem( - channel = TestData.channel2().apply { + channel = TestData.channel2().copy( members = listOf( TestData.member1(), TestData.member3(), - ) + ), messages = listOf( TestData.message2(), - ) - lastMessageAt = TestData.date2() - }, + ), + lastMessageAt = TestData.date2(), + ), + emptyList(), ), ChannelListItem.ChannelItem( - channel = TestData.channel3().apply { + channel = TestData.channel3().copy( members = listOf( TestData.member1(), TestData.member4(), - ) + ), messages = listOf( TestData.message3(), - ) - lastMessageAt = TestData.date3() - }, + ), + lastMessageAt = TestData.date3(), + ), + emptyList(), ), ChannelListItem.ChannelItem( - channel = TestData.channel4().apply { + channel = TestData.channel4().copy( members = listOf( TestData.member1(), TestData.member5(), - ) + ), messages = listOf( TestData.message4(), - ) - lastMessageAt = TestData.date4() - }, + ), + lastMessageAt = TestData.date4(), + ), + emptyList(), ), ChannelListItem.LoadingMoreItem, ), @@ -110,52 +114,56 @@ class ChannelListViewTest : ScreenshotTest { setChannels( listOf( ChannelListItem.ChannelItem( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) + ), messages = listOf( TestData.message1(), - ) - lastMessageAt = TestData.date1() - }, + ), + lastMessageAt = TestData.date1(), + ), + emptyList(), ), ChannelListItem.ChannelItem( - channel = TestData.channel2().apply { + channel = TestData.channel2().copy( members = listOf( TestData.member1(), TestData.member3(), - ) + ), messages = listOf( TestData.message2(), - ) - lastMessageAt = TestData.date2() - }, + ), + lastMessageAt = TestData.date2(), + ), + emptyList(), ), ChannelListItem.ChannelItem( - channel = TestData.channel3().apply { + channel = TestData.channel3().copy( members = listOf( TestData.member1(), TestData.member4(), - ) + ), messages = listOf( TestData.message3(), - ) - lastMessageAt = TestData.date3() - }, + ), + lastMessageAt = TestData.date3(), + ), + emptyList(), ), ChannelListItem.ChannelItem( - channel = TestData.channel4().apply { + channel = TestData.channel4().copy( members = listOf( TestData.member1(), TestData.member5(), - ) + ), messages = listOf( TestData.message4(), - ) - lastMessageAt = TestData.date4() - }, + ), + lastMessageAt = TestData.date4(), + ), + emptyList(), ), ChannelListItem.LoadingMoreItem, ), diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/components/ChannelAvatarTest.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/components/ChannelAvatarTest.kt index 491634ea590..90121a2f673 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/components/ChannelAvatarTest.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/snapshot/uicomponents/components/ChannelAvatarTest.kt @@ -30,15 +30,15 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithFiveMembers() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), TestData.member4(), TestData.member5(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -46,14 +46,14 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithFourMembers() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), TestData.member4(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -61,13 +61,13 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithThreeMembers() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), TestData.member3(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -75,12 +75,12 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithTwoMembers() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -88,11 +88,11 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithOneMember() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), - ) - }, + ), + ), currentUser = TestData.user1(), ) } @@ -100,15 +100,15 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithFiveMembersWithoutImages() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - TestData.member3().apply { user.image = "" }, - TestData.member4().apply { user.image = "" }, - TestData.member5().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member3().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member4().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member5().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -116,14 +116,14 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithFourMembersWithoutImages() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - TestData.member3().apply { user.image = "" }, - TestData.member4().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member3().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member4().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -131,13 +131,13 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithThreeMembersWithoutImages() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - TestData.member3().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member3().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -145,12 +145,12 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithTwoMembersWithoutImages() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - TestData.member2().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + TestData.member2().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -158,11 +158,11 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithOneMemberWithoutImage() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( - TestData.member1().apply { user.image = "" }, - ) - }, + TestData.member1().let { it.copy(user = it.user.copy(image = "")) }, + ), + ), currentUser = TestData.user1(), ) } @@ -170,12 +170,12 @@ class ChannelAvatarTest : UiComponentsScreenshotTest() { @Test fun channelAvatarForChannelWithoutCurrentUser() { renderChannelAvatarView( - channel = TestData.channel1().apply { + channel = TestData.channel1().copy( members = listOf( TestData.member1(), TestData.member2(), - ) - }, + ), + ), currentUser = null, ) } diff --git a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/util/TestData.kt b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/util/TestData.kt index ac7f00b3795..3e8ecf2e41d 100644 --- a/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/util/TestData.kt +++ b/stream-chat-android-ui-uitests/src/androidTest/java/io/getstream/chat/android/uitests/util/TestData.kt @@ -33,36 +33,36 @@ import java.util.Date @OptIn(InternalStreamChatApi::class) object TestData { - fun user1(): User = User().apply { - id = "jc" - name = "Jc Miñarro" - image = FakeImageLoader.AVATAR_JC - online = true - } + fun user1(): User = User().copy( + id = "jc", + name = "Jc Miñarro", + image = FakeImageLoader.AVATAR_JC, + online = true, + ) - fun user2(): User = User().apply { - id = "amit" - name = "Amit Kumar" - image = FakeImageLoader.AVATAR_AMIT - } + fun user2(): User = User().copy( + id = "amit", + name = "Amit Kumar", + image = FakeImageLoader.AVATAR_AMIT, + ) - fun user3(): User = User().apply { - id = "filip" - name = "Filip Babić" - image = FakeImageLoader.AVATAR_FILIP - } + fun user3(): User = User().copy( + id = "filip", + name = "Filip Babić", + image = FakeImageLoader.AVATAR_FILIP, + ) - fun user4(): User = User().apply { - id = "rafal" - name = "Rafal Adasiewicz" - image = FakeImageLoader.AVATAR_RAFAL - } + fun user4(): User = User().copy( + id = "rafal", + name = "Rafal Adasiewicz", + image = FakeImageLoader.AVATAR_RAFAL, + ) - fun user5(): User = User().apply { - id = "belal" - name = "Belal Khan" - image = FakeImageLoader.AVATAR_BELAL - } + fun user5(): User = User().copy( + id = "belal", + name = "Belal Khan", + image = FakeImageLoader.AVATAR_BELAL, + ) fun member1() = Member( user = user1(), @@ -89,61 +89,61 @@ object TestData { isInvited = false, ) - fun message1(): Message = Message().apply { - id = "message1" - text = "Ladies and gentlemen, we have liftoff" - createdAt = date1() - type = MessageType.REGULAR - user = user1() - } + fun message1(): Message = Message().copy( + id = "message1", + text = "Ladies and gentlemen, we have liftoff", + createdAt = date1(), + type = MessageType.REGULAR, + user = user1(), + ) - fun message2(): Message = Message().apply { - id = "message2" - text = "Space!" - createdAt = date2() - type = MessageType.REGULAR - user = user2() - } + fun message2(): Message = Message().copy( + id = "message2", + text = "Space!", + createdAt = date2(), + type = MessageType.REGULAR, + user = user2(), + ) - fun message3(): Message = Message().apply { - id = "message3" - text = "They ain't in space yet" - createdAt = date3() - type = MessageType.REGULAR - user = user3() - } + fun message3(): Message = Message().copy( + id = "message3", + text = "They ain't in space yet", + createdAt = date3(), + type = MessageType.REGULAR, + user = user3(), + ) - fun message4(): Message = Message().apply { - id = "message4" - text = "OK, not to be that guy, but by my calculations, they’re technically in space now" - createdAt = date4() - type = MessageType.REGULAR - user = user4() - } + fun message4(): Message = Message().copy( + id = "message4", + text = "OK, not to be that guy, but by my calculations, they’re technically in space now", + createdAt = date4(), + type = MessageType.REGULAR, + user = user4(), + ) - fun channel1() = Channel().apply { - type = "messaging" - id = "channel1" - unreadCount = 0 - } + fun channel1() = Channel().copy( + type = "messaging", + id = "channel1", + unreadCount = 0, + ) - fun channel2() = Channel().apply { - type = "messaging" - id = "channel2" - unreadCount = 0 - } + fun channel2() = Channel().copy( + type = "messaging", + id = "channel2", + unreadCount = 0, + ) - fun channel3() = Channel().apply { - type = "messaging" - id = "channel3" - unreadCount = 0 - } + fun channel3() = Channel().copy( + type = "messaging", + id = "channel3", + unreadCount = 0, + ) - fun channel4() = Channel().apply { - type = "messaging" - id = "channel4" - unreadCount = 0 - } + fun channel4() = Channel().copy( + type = "messaging", + id = "channel4", + unreadCount = 0, + ) fun date1() = LocalDateTime.of(2020, 12, 7, 9, 0).toDate() diff --git a/stream-chat-android-ui-utils/detekt-baseline.xml b/stream-chat-android-ui-utils/detekt-baseline.xml index ea6c97131cf..dba38f7b560 100644 --- a/stream-chat-android-ui-utils/detekt-baseline.xml +++ b/stream-chat-android-ui-utils/detekt-baseline.xml @@ -2,6 +2,7 @@ + LongMethod:ChannelKtTest.kt$ChannelKtTest.Companion$@JvmStatic fun arguments() LongParameterList:Channel.kt$( context: Context, currentUser: User?, @StringRes userOnlineResId: Int, @StringRes userLastSeenJustNowResId: Int, @StringRes userLastSeenResId: Int, @PluralsRes memberCountResId: Int, @StringRes memberCountWithOnlineResId: Int, ) diff --git a/stream-chat-android-ui-utils/src/test/kotlin/io/getstream/chat/android/uiutils/extension/ChannelKtTest.kt b/stream-chat-android-ui-utils/src/test/kotlin/io/getstream/chat/android/uiutils/extension/ChannelKtTest.kt index 4586e255f54..42f3e0878e2 100644 --- a/stream-chat-android-ui-utils/src/test/kotlin/io/getstream/chat/android/uiutils/extension/ChannelKtTest.kt +++ b/stream-chat-android-ui-utils/src/test/kotlin/io/getstream/chat/android/uiutils/extension/ChannelKtTest.kt @@ -63,15 +63,28 @@ internal class ChannelKtTest { @ParameterizedTest @MethodSource("arguments") fun `Should return proper channel name`( + argSetNum: Int, channel: Channel, maxMembers: Int, expectedName: String, ) { - channel.getDisplayName(context, currentUser, fallbackResource, maxMembers) `should be equal to` expectedName + try { + channel.getDisplayName(context, currentUser, fallbackResource, maxMembers) `should be equal to` expectedName + } catch (e: Throwable) { + System.err.println("Failed on test #$argSetNum") + throw e + } } companion object { + private const val ARG_SET_1 = 1 + private const val ARG_SET_2 = 2 + private const val ARG_SET_3 = 3 + private const val ARG_SET_4 = 4 + private const val ARG_SET_5 = 5 + private const val ARG_SET_6 = 6 + private val context: Context = mock() private val fallbackResource: Int = positiveRandomInt() private val fallbackText: String = randomString() @@ -79,9 +92,17 @@ internal class ChannelKtTest { @JvmStatic fun arguments() = listOf( - randomChannel().let { Arguments.of(it, positiveRandomInt(), it.name) }, + randomChannel().let { + Arguments.of( + ARG_SET_1, + it, + positiveRandomInt(), + it.name, + ) + }, randomUser().let { Arguments.of( + ARG_SET_2, randomChannel(name = "", members = listOf(randomMember(user = it))), positiveRandomInt(), it.name, @@ -89,14 +110,17 @@ internal class ChannelKtTest { }, List(positiveRandomInt(4)) { randomUser() }.let { Arguments.of( + ARG_SET_3, randomChannel(name = "", members = it.map { user -> randomMember(user = user) }), 4, - it.joinToString(", ") { user -> user.name }, + it.sortedBy(User::name) + .joinToString(", ") { user -> user.name }, ) }, List(5) { randomUser() }.let { val maxMembers = positiveRandomInt(4) Arguments.of( + ARG_SET_4, randomChannel(name = "", members = it.map { user -> randomMember(user = user) }), maxMembers, "${ @@ -107,6 +131,7 @@ internal class ChannelKtTest { ) }, Arguments.of( + ARG_SET_5, randomChannel( name = "", members = listOf( @@ -117,6 +142,7 @@ internal class ChannelKtTest { currentUser.name, ), Arguments.of( + ARG_SET_6, randomChannel( name = "", members = emptyList(),