e2e: Port the iOS-only tests for slow mode, truncation, scroll, read … · GetStream/stream-chat-android@4338a8e · GitHub
Skip to content

Commit 4338a8e

Browse files
authored
e2e: Port the iOS-only tests for slow mode, truncation, scroll, read events, and attachments (#6572)
* e2e: Port the iOS slow mode tests * e2e: Port the iOS channel truncation tests * e2e: Port the iOS message list scroll and command tests * e2e: Port the iOS read events and member removal tests * e2e: Port the iOS image upload recovery test * e2e: Extend the slow mode cooldown beyond the slowest CI assert window
1 parent 8019222 commit 4338a8e

11 files changed

Lines changed: 566 additions & 4 deletions

File tree

‎stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/pages/MessageListPage.kt‎

Lines changed: 1 addition & 0 deletions

‎stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobot.kt‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,14 @@ class UserRobot {
201201
}
202202

203203
fun quoteMessage(text: String, messageCellIndex: Int = 0): UserRobot {
204+
selectReplyFromContextMenu(messageCellIndex)
205+
sendMessage(text)
206+
return this
207+
}
208+
209+
fun selectReplyFromContextMenu(messageCellIndex: Int = 0): UserRobot {
204210
openContextMenu(messageCellIndex)
205211
ContextMenu.reply.waitToAppear().click()
206-
sendMessage(text)
207212
return this
208213
}
209214

@@ -314,13 +319,18 @@ class UserRobot {
314319
return this
315320
}
316321

322+
fun tapOnGiphyCommandSuggestion(): UserRobot {
323+
Composer.giphyButton.waitToAppear().click()
324+
return this
325+
}
326+
317327
fun uploadGiphy(useComposerCommand: Boolean = false, send: Boolean = true): UserRobot {
318328
val giphyMessageText = "G" // any message text will result in sending a giphy
319329
if (useComposerCommand) {
320330
openComposerCommands()
321331
// Selecting the suggestion prefills '/giphy '; typeText replaces the whole input,
322332
// so the command prefix is set together with the message text.
323-
Composer.giphyButton.waitToAppear().click()
333+
tapOnGiphyCommandSuggestion()
324334
typeText("/giphy $giphyMessageText")
325335
tapOnComposerConfirmButton()
326336
} else {

‎stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotMessageListAsserts.kt‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,26 @@ fun UserRobot.assertScrollToBottomButton(isDisplayed: Boolean): UserRobot {
261261
return this
262262
}
263263

264+
fun UserRobot.assertMessageCount(count: Int): UserRobot {
265+
assertEquals(count, MessageListPage.MessageList.messages.waitForCount(count).size)
266+
return this
267+
}
268+
269+
fun UserRobot.assertComposerAttachmentsButton(isDisplayed: Boolean = true): UserRobot {
270+
assertVisibility(Composer.attachmentsButton, isDisplayed)
271+
return this
272+
}
273+
274+
fun UserRobot.assertScrollToBottomButtonUnreadCount(count: Int): UserRobot {
275+
val badge = MessageListPage.MessageList.scrollToBottomButtonUnreadCount
276+
if (count > 0) {
277+
assertEquals(count.toString(), badge.waitForText(count.toString()))
278+
} else {
279+
assertFalse(badge.waitToDisappear().isDisplayed())
280+
}
281+
return this
282+
}
283+
264284
fun UserRobot.assertThreadIsOpen(): UserRobot {
265285
assertTrue(ThreadPage.ThreadList.alsoSendToChannelCheckbox.waitDisplayed())
266286
return this

‎stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/AttachmentsTests.kt‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import io.getstream.chat.android.compose.robots.assertMediaAttachmentInPreview
2424
import io.getstream.chat.android.compose.robots.assertVideo
2525
import io.getstream.chat.android.compose.sample.ui.InitTestActivity
2626
import io.getstream.chat.android.e2e.test.mockserver.AttachmentType
27+
import io.getstream.chat.android.e2e.test.uiautomator.device
28+
import io.getstream.chat.android.e2e.test.uiautomator.disableInternetConnection
29+
import io.getstream.chat.android.e2e.test.uiautomator.enableInternetConnection
2730
import io.qameta.allure.kotlin.Allure.step
2831
import io.qameta.allure.kotlin.AllureId
2932
import org.junit.Test
@@ -197,4 +200,26 @@ class AttachmentsTests : StreamTestCase() {
197200
userRobot.assertFile(isDisplayed = true)
198201
}
199202
}
203+
204+
@AllureId("5928")
205+
@Test
206+
fun test_imageUploadRecovers_whenUserComesBackOnline() {
207+
step("GIVEN user opens the channel") {
208+
userRobot.login().openChannel()
209+
}
210+
step("AND user goes offline") {
211+
device.disableInternetConnection()
212+
}
213+
step("WHEN user sends an image while offline") {
214+
userRobot
215+
.attachFile(type = AttachmentType.IMAGE)
216+
.tapOnSendButton()
217+
}
218+
step("AND user comes back online") {
219+
device.enableInternetConnection()
220+
}
221+
step("THEN the image is uploaded") {
222+
userRobot.assertImage(isDisplayed = true)
223+
}
224+
}
200225
}

‎stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/ChannelListTests.kt‎

Lines changed: 62 additions & 0 deletions

0 commit comments

Comments
 (0)