Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple committed Jan 8, 2025
1 parent b8674ad commit 2b8aad0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,6 @@ class UserRobot {
}

fun tapOnMessageList() {
if (MessageList.messageList.isDisplayed()) {
MessageList.messageList.waitToAppear().click()
} else {
device.tapOnScreenCenter()
}
device.tapOnScreenCenter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ fun UserRobot.assertMessageAuthor(isCurrentUser: Boolean): UserRobot {
return this
}

fun UserRobot.assertMessageTimestamps(count: Int): UserRobot {
assertEquals(count, Message.timestamp.findObjects().size)
return this
}

fun UserRobot.assertMessageReadStatus(status: MessageReadStatus): UserRobot {
when (status) {
MessageReadStatus.READ -> assertTrue(Message.readStatusIsRead.wait().isDisplayed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import io.getstream.chat.android.compose.robots.assertMessageAuthor
import io.getstream.chat.android.compose.robots.assertMessageFailedIcon
import io.getstream.chat.android.compose.robots.assertMessageReadStatus
import io.getstream.chat.android.compose.robots.assertMessageSizeChangesAfterEditing
import io.getstream.chat.android.compose.robots.assertMessageTimestamps
import io.getstream.chat.android.compose.robots.assertScrollToBottomButton
import io.getstream.chat.android.compose.robots.assertThreadMessage
import io.getstream.chat.android.compose.robots.assertThreadReplyLabelOnParentMessage
Expand All @@ -41,6 +42,7 @@ import io.getstream.chat.android.compose.uiautomator.enableInternetConnection
import io.getstream.chat.android.compose.uiautomator.goToBackground
import io.getstream.chat.android.compose.uiautomator.goToForeground
import io.getstream.chat.android.e2e.test.mockserver.MessageReadStatus
import io.getstream.chat.android.e2e.test.mockserver.forbiddenWords
import io.qameta.allure.kotlin.Allure.step
import io.qameta.allure.kotlin.AllureId
import org.junit.Ignore
Expand Down Expand Up @@ -769,86 +771,68 @@ class MessageListTests : StreamTestCase() {
}
}

//
// // MARK: - Message grouping
//
// extension MessageList_Tests {
// func test_messageEndsGroup_whenFollowedByErrorMessage() {
// linkToScenario(withId: 218)
//
// let message = "Hey there"
// let messageWithForbiddenContent = server.forbiddenWords.first ?? ""
//
// GIVEN("user opens the channel") {
// userRobot
// .login()
// .openChannel()
// }
// AND("user sends the 1st message") {
// userRobot.sendMessage(message)
// }
// AND("the timestamp is shown under the 1st message") {
// userRobot.assertMessageHasTimestamp()
// }
// WHEN("user sends a message that does not pass moderation") {
// userRobot.sendMessage(messageWithForbiddenContent, waitForAppearance: false)
// }
// THEN("messages are not grouped, 1st message shows the timestamp") {
// userRobot.assertMessageHasTimestamp(at: 1)
// }
// }
//
// func test_messageEndsGroup_whenFollowedByEphemeralMessage() {
// linkToScenario(withId: 221)
//
// let message = "Hey there"
//
// GIVEN("user opens the channel") {
// userRobot
// .login()
// .openChannel()
// }
// AND("user sends the 1st message") {
// userRobot.sendMessage(message)
// }
// AND("the timestamp is shown under the 1st message") {
// userRobot.assertMessageHasTimestamp()
// }
// WHEN("user sends an ephemeral message") {
// userRobot
// .sendGiphy(send: false)
// .scrollMessageListDown() // to hide the keyboard
// }
// THEN("messages are not grouped, 1st message shows the timestamp") {
// userRobot
// .assertMessageCount(2)
// .assertMessageHasTimestamp(at: 1)
// }
// }
//
// func test_messageRendersTimestampAgain_whenMessageLastInGroupIsHardDeleted() {
// linkToScenario(withId: 288)
//
// GIVEN("user opens the channel") {
// backendRobot
// .generateChannels(count: 1, messagesCount: 1)
// userRobot
// .login()
// .openChannel()
// }
// AND("user inserts 3 group messages") {
// userRobot.sendMessage("Hey")
// userRobot.sendMessage("Hey2")
// userRobot.sendMessage("Hey3")
// userRobot.assertMessageHasTimestamp()
// }
// WHEN("user deletes last message") {
// userRobot.deleteMessage(hard: true)
// }
// THEN("previous message should re-render timestamp") {
// userRobot.assertMessageHasTimestamp(at: 0)
// }
// }
// }
//
// MARK: - Message grouping

@AllureId("")
@Test
fun test_messageEndsGroup_whenFollowedByErrorMessage() {
step("GIVEN user opens the channel") {
userRobot.login().openChannel()
}
step("AND user sends the 1st message") {
userRobot.sendMessage(sampleText)
}
step("AND the timestamp is shown under the 1st message") {
userRobot.assertMessageTimestamps(1)
}
step("WHEN user sends a message that does not pass moderation") {
userRobot.sendMessage(forbiddenWords[0])
}
step("THEN messages are not grouped, 1st message shows the timestamp") {
userRobot.assertMessageTimestamps(1)
}
}

@AllureId("")
@Test
fun test_messageRendersTimestampAgain_whenMessageLastInGroupIsHardDeleted() {
step("GIVEN user opens the channel") {
userRobot.login().openChannel()
}
step("AND participant inserts 3 group messages") {
participantRobot
.sendMessage("1")
.sendMessage("2")
.sendMessage("3")
userRobot.assertMessageTimestamps(1)
}
step("WHEN participant hard deletes last message") {
participantRobot.deleteMessage(hard = true)
}
step("THEN previous message should re-render timestamp") {
userRobot.assertMessageTimestamps(1)
}
}

@AllureId("")
@Ignore("https://linear.app/stream/issue/AND-211")
@Test
fun test_messageRendersTimestampAgain_whenMessageLastInGroupIsSoftDeleted() {
step("GIVEN user opens the channel") {
userRobot.login().openChannel()
}
step("AND participant inserts 3 group messages") {
participantRobot
.sendMessage("1")
.sendMessage("2")
.sendMessage("3")
userRobot.assertMessageTimestamps(1)
}
step("WHEN participant hard deletes last message") {
participantRobot.deleteMessage(hard = false)
}
step("THEN previous message should re-render timestamp") {
userRobot.assertMessageTimestamps(1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import okhttp3.ResponseBody
public var mockServerUrl: String? = null
private const val driverUrl: String = "http://10.0.2.2:4567"
private val okHttp: OkHttpClient = OkHttpClient()
public val forbiddenWords: Array<String> = arrayOf("wth")

public class MockServer {

Expand Down

0 comments on commit 2b8aad0

Please sign in to comment.