diff --git a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/pages/ChannelListPage.kt b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/pages/ChannelListPage.kt index fcec222b047..a5f8192e082 100644 --- a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/pages/ChannelListPage.kt +++ b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/pages/ChannelListPage.kt @@ -43,7 +43,10 @@ class ChannelListPage { val initialsAvatar = By.res("Stream_InitialsAvatar") val name = By.res("Stream_ChannelName") val messagePreview = By.res("Stream_MessagePreview") - val readStatus = By.res("Stream_ReadStatusIcon") + val readStatusIsRead = By.res("Stream_MessageReadStatus_isRead") + val readStatusIsPending = By.res("Stream_MessageReadStatus_isPending") + val readStatusIsSent = By.res("Stream_MessageReadStatus_isSent") + val readCount = By.res("Stream_MessageReadCount") val unreadCountIndicator = By.res("Stream_UnreadCountIndicator") val timestamp = By.res("Stream_Timestamp") val typingIndicator = By.res("Stream_ChannelListTypingIndicator") diff --git a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt index 211e3cade4e..cc5c7a1fb41 100644 --- a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt +++ b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt @@ -18,8 +18,11 @@ package io.getstream.chat.android.compose.robots import io.getstream.chat.android.compose.pages.ChannelListPage.ChannelList.Channel import io.getstream.chat.android.compose.uiautomator.exists +import io.getstream.chat.android.compose.uiautomator.findObject +import io.getstream.chat.android.compose.uiautomator.wait import io.getstream.chat.android.compose.uiautomator.waitToAppear import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue fun UserRobot.assertChannelAvatar(): UserRobot { @@ -33,3 +36,14 @@ fun UserRobot.assertMessageInChannelPreview(text: String, fromCurrentUser: Boole assertTrue(Channel.timestamp.exists()) return this } + +fun UserRobot.assertMessageDeliveryStatus(shouldBeVisible: Boolean, shouldBeRead: Boolean = false) : UserRobot { + if (shouldBeVisible) { + val readStatus = if (shouldBeRead) Channel.readStatusIsRead else Channel.readStatusIsSent + assertTrue(readStatus.wait().exists()) + } else { + assertFalse(Channel.readStatusIsRead.exists()) + assertFalse(Channel.readStatusIsSent.exists()) + } + return this +} diff --git a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/ChannelListTests.kt b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/ChannelListTests.kt index 960168ae578..baad3bd0a3b 100644 --- a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/ChannelListTests.kt +++ b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/ChannelListTests.kt @@ -17,14 +17,17 @@ package io.getstream.chat.android.compose.tests import io.getstream.chat.android.compose.robots.assertChannelAvatar +import io.getstream.chat.android.compose.robots.assertMessageDeliveryStatus import io.getstream.chat.android.compose.robots.assertMessageInChannelPreview import io.qameta.allure.kotlin.Allure.step +import io.qameta.allure.kotlin.AllureId import org.junit.Test class ChannelListTests : StreamTestCase() { private val sampleText = "Test" + @AllureId("6343") @Test fun test_channelPreviewUpdates_whenParticipantSendsMessage() { step("GIVEN user opens a channel") { @@ -41,10 +44,12 @@ class ChannelListTests : StreamTestCase() { step("THEN user observes the new message in preview") { userRobot .assertMessageInChannelPreview(sampleText, false) + .assertMessageDeliveryStatus(shouldBeVisible = false) .assertChannelAvatar() } } + @AllureId("6344") @Test fun test_channelPreviewUpdates_whenUserSendsMessage() { step("GIVEN user opens a channel") { @@ -61,7 +66,14 @@ class ChannelListTests : StreamTestCase() { step("THEN user observes the new message in preview") { userRobot .assertMessageInChannelPreview(sampleText, true) + .assertMessageDeliveryStatus(shouldBeVisible = true, shouldBeRead = false) .assertChannelAvatar() } + step("WHEN participant reads the message") { + participantRobot.readMessage() + } + step("THEN user observes the new message in preview") { + userRobot.assertMessageDeliveryStatus(shouldBeVisible = true, shouldBeRead = true) + } } } diff --git a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/MessageListTests.kt b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/MessageListTests.kt index 3e9a4de34bd..7d53bc1b60b 100644 --- a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/MessageListTests.kt +++ b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/MessageListTests.kt @@ -19,12 +19,14 @@ package io.getstream.chat.android.compose.tests import io.getstream.chat.android.compose.robots.assertMessage import io.getstream.chat.android.compose.robots.assertMessageAuthor import io.qameta.allure.kotlin.Allure.step +import io.qameta.allure.kotlin.AllureId import org.junit.Test class MessageListTests : StreamTestCase() { private val sampleText = "Test" + @AllureId("5661") @Test fun test_messageListUpdates_whenParticipantSendsMessage() { step("GIVEN user opens a channel") { @@ -42,6 +44,7 @@ class MessageListTests : StreamTestCase() { } } + @AllureId("5660") @Test fun test_messageListUpdates_whenUserSendsMessage() { step("GIVEN user opens a channel") { diff --git a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/StreamTestCase.kt b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/StreamTestCase.kt index fcec6d1c015..ff7629c7fa1 100644 --- a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/StreamTestCase.kt +++ b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/StreamTestCase.kt @@ -16,7 +16,6 @@ package io.getstream.chat.android.compose.tests -import android.Manifest.permission import android.Manifest.permission.POST_NOTIFICATIONS import android.Manifest.permission.READ_MEDIA_IMAGES import android.Manifest.permission.READ_MEDIA_VIDEO diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/ChannelItem.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/ChannelItem.kt index 3f8b3b7e74f..b67cd3b7248 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/ChannelItem.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/ChannelItem.kt @@ -260,7 +260,7 @@ private fun UserTypingIndicator(users: List) { /** * Represents the default trailing content for the channel item. By default it shows - * the the information about the last message for the channel item, such as its read state, + * the information about the last message for the channel item, such as its read state, * timestamp and how many unread messages the user has. * * @param channel The channel to show the info for. diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/MessageReadStatusIcon.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/MessageReadStatusIcon.kt index eee4b5ff596..a12b81222da 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/MessageReadStatusIcon.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/MessageReadStatusIcon.kt @@ -52,14 +52,13 @@ public fun MessageReadStatusIcon( currentUser: User?, modifier: Modifier = Modifier, ) { - val readStatues = channel.getReadStatuses(userToIgnore = currentUser) - val readCount = readStatues.count { it.time >= message.getCreatedAtOrThrow().time } + val readStatuses = channel.getReadStatuses(userToIgnore = currentUser) + val readCount = readStatuses.count { it.time >= message.getCreatedAtOrThrow().time } val isMessageRead = readCount != 0 MessageReadStatusIcon( message = message, isMessageRead = isMessageRead, - modifier = modifier.testTag("Stream_ReadStatusIcon"), readCount = readCount, ) } diff --git a/stream-chat-android-e2e-test/src/main/kotlin/io/getstream/chat/android/e2e/test/uiautomator/Wait.kt b/stream-chat-android-e2e-test/src/main/kotlin/io/getstream/chat/android/e2e/test/uiautomator/Wait.kt index b446a008a9f..260a3ccc7c4 100644 --- a/stream-chat-android-e2e-test/src/main/kotlin/io/getstream/chat/android/e2e/test/uiautomator/Wait.kt +++ b/stream-chat-android-e2e-test/src/main/kotlin/io/getstream/chat/android/e2e/test/uiautomator/Wait.kt @@ -25,12 +25,12 @@ public fun sleep(timeOutMillis: Long = defaultTimeout) { } public fun BySelector.waitToAppear(timeOutMillis: Long = defaultTimeout): UiObject2 { - device.wait(Until.hasObject(this), timeOutMillis) + wait(timeOutMillis) return findObject() } public fun BySelector.waitToAppear(withIndex: Int, timeOutMillis: Long = defaultTimeout): UiObject2 { - device.wait(Until.hasObject(this), timeOutMillis) + wait(timeOutMillis) return findObjects()[withIndex] } @@ -39,6 +39,7 @@ public fun BySelector.wait(timeOutMillis: Long = defaultTimeout): BySelector { return this } -public fun BySelector.waitToDisappear(timeOutMillis: Long = defaultTimeout) { +public fun BySelector.waitToDisappear(timeOutMillis: Long = defaultTimeout): BySelector { device.wait(Until.gone(this), timeOutMillis) + return this }