Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ open class MessageListPage {
val unreadMessagesBadge get() = By.res("Stream_UnreadMessagesBadge")
val typingIndicator get() = By.res("Stream_MessageListTypingIndicator")
val scrollToBottomButton get() = By.res("Stream_ScrollToBottomButton")
val scrollToBottomButtonUnreadCount get() = By.res("Stream_ScrollToBottomButtonUnreadCount")
val systemMessage get() = By.res("Stream_SystemMessage")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,14 @@ class UserRobot {
}

fun quoteMessage(text: String, messageCellIndex: Int = 0): UserRobot {
selectReplyFromContextMenu(messageCellIndex)
sendMessage(text)
return this
}

fun selectReplyFromContextMenu(messageCellIndex: Int = 0): UserRobot {
openContextMenu(messageCellIndex)
ContextMenu.reply.waitToAppear().click()
sendMessage(text)
return this
}

Expand Down Expand Up @@ -314,13 +319,18 @@ class UserRobot {
return this
}

fun tapOnGiphyCommandSuggestion(): UserRobot {
Composer.giphyButton.waitToAppear().click()
return this
}

fun uploadGiphy(useComposerCommand: Boolean = false, send: Boolean = true): UserRobot {
val giphyMessageText = "G" // any message text will result in sending a giphy
if (useComposerCommand) {
openComposerCommands()
// Selecting the suggestion prefills '/giphy '; typeText replaces the whole input,
// so the command prefix is set together with the message text.
Composer.giphyButton.waitToAppear().click()
tapOnGiphyCommandSuggestion()
typeText("/giphy $giphyMessageText")
tapOnComposerConfirmButton()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,26 @@ fun UserRobot.assertScrollToBottomButton(isDisplayed: Boolean): UserRobot {
return this
}

fun UserRobot.assertMessageCount(count: Int): UserRobot {
assertEquals(count, MessageListPage.MessageList.messages.waitForCount(count).size)
return this
}

fun UserRobot.assertComposerAttachmentsButton(isDisplayed: Boolean = true): UserRobot {
assertVisibility(Composer.attachmentsButton, isDisplayed)
return this
}

fun UserRobot.assertScrollToBottomButtonUnreadCount(count: Int): UserRobot {
val badge = MessageListPage.MessageList.scrollToBottomButtonUnreadCount
if (count > 0) {
assertEquals(count.toString(), badge.waitForText(count.toString()))
} else {
assertFalse(badge.waitToDisappear().isDisplayed())
}
return this
}

fun UserRobot.assertThreadIsOpen(): UserRobot {
assertTrue(ThreadPage.ThreadList.alsoSendToChannelCheckbox.waitDisplayed())
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import io.getstream.chat.android.compose.robots.assertMediaAttachmentInPreview
import io.getstream.chat.android.compose.robots.assertVideo
import io.getstream.chat.android.compose.sample.ui.InitTestActivity
import io.getstream.chat.android.e2e.test.mockserver.AttachmentType
import io.getstream.chat.android.e2e.test.uiautomator.device
import io.getstream.chat.android.e2e.test.uiautomator.disableInternetConnection
import io.getstream.chat.android.e2e.test.uiautomator.enableInternetConnection
import io.qameta.allure.kotlin.Allure.step
import io.qameta.allure.kotlin.AllureId
import org.junit.Test
Expand Down Expand Up @@ -197,4 +200,26 @@ class AttachmentsTests : StreamTestCase() {
userRobot.assertFile(isDisplayed = true)
}
}

@AllureId("5928")
@Test
fun test_imageUploadRecovers_whenUserComesBackOnline() {
step("GIVEN user opens the channel") {
userRobot.login().openChannel()
}
step("AND user goes offline") {
device.disableInternetConnection()
}
step("WHEN user sends an image while offline") {
userRobot
.attachFile(type = AttachmentType.IMAGE)
.tapOnSendButton()
}
step("AND user comes back online") {
device.enableInternetConnection()
}
step("THEN the image is uploaded") {
userRobot.assertImage(isDisplayed = true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package io.getstream.chat.android.compose.tests

import io.getstream.chat.android.compose.robots.assertChannelAvatar
import io.getstream.chat.android.compose.robots.assertMessageCount
import io.getstream.chat.android.compose.robots.assertMessageDeliveryStatus
import io.getstream.chat.android.compose.robots.assertMessageInChannelPreview
import io.getstream.chat.android.compose.robots.assertMessagePreviewTimestamp
import io.getstream.chat.android.compose.robots.assertScrollToBottomButton
import io.getstream.chat.android.compose.robots.assertScrollToBottomButtonUnreadCount
import io.getstream.chat.android.compose.robots.assertSystemMessage
import io.getstream.chat.android.compose.sample.ui.InitTestActivity
import io.getstream.chat.android.e2e.test.mockserver.MessageDeliveryStatus
import io.getstream.chat.android.e2e.test.uiautomator.device
Expand Down Expand Up @@ -274,4 +278,62 @@ class ChannelListTests : StreamTestCase() {
userRobot.assertMessagePreviewTimestamp(isDisplayed = true)
}
}

@AllureId("5797")
@Test
fun test_messageList_and_channelPreview_AreUpdatedWhenChannelTruncatedWithMessage() {
val message = "Channel truncated"

step("GIVEN user opens the channel") {
backendRobot.generateChannels(channelsCount = 1, messagesCount = 42)
userRobot.login().openChannel()
}
step("WHEN the channel is truncated with a system message") {
backendRobot.truncateChannel(withMessage = true)
}
step("THEN user observes only the system message") {
userRobot
.assertSystemMessage(message)
.assertMessageCount(0)
.assertScrollToBottomButton(isDisplayed = false)
.assertScrollToBottomButtonUnreadCount(0)
}
step("WHEN user goes back to the channel list") {
userRobot.tapOnBackButton()
}
step("THEN the channel preview shows the system message") {
userRobot.assertMessageInChannelPreview(message, fromCurrentUser = true)
}
step("AND the message timestamp is shown") {
userRobot.assertMessagePreviewTimestamp(isDisplayed = true)
}
}

@AllureId("5827")
@Test
fun test_messageList_and_channelPreview_AreUpdatedWhenChannelTruncatedWithoutMessage() {
step("GIVEN user opens the channel") {
backendRobot.generateChannels(channelsCount = 1, messagesCount = 42)
userRobot.login().openChannel()
}
step("WHEN the channel is truncated without a system message") {
backendRobot.truncateChannel(withMessage = false)
}
step("THEN user observes an empty message list") {
userRobot
.assertMessageCount(0)
.assertSystemMessage("Channel truncated", isDisplayed = false)
.assertScrollToBottomButton(isDisplayed = false)
.assertScrollToBottomButtonUnreadCount(0)
}
step("WHEN user goes back to the channel list") {
userRobot.tapOnBackButton()
}
step("THEN the channel preview is empty") {
userRobot.assertMessageInChannelPreview("No messages yet")
}
step("AND the message timestamp is hidden") {
userRobot.assertMessagePreviewTimestamp(isDisplayed = false)
}
}
}
Loading
Loading