|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Stream License; |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.getstream.chat.android.compose.tests |
| 18 | + |
| 19 | +import io.getstream.chat.android.compose.robots.assertDeletedMessage |
| 20 | +import io.getstream.chat.android.compose.robots.assertMessage |
| 21 | +import io.getstream.chat.android.compose.robots.assertReaction |
| 22 | +import io.getstream.chat.android.compose.sample.ui.InitTestActivity |
| 23 | +import io.getstream.chat.android.e2e.test.mockserver.ReactionType |
| 24 | +import io.qameta.allure.kotlin.Allure.step |
| 25 | +import org.junit.Test |
| 26 | + |
| 27 | +class BackendTests : StreamTestCase() { |
| 28 | + |
| 29 | + override var useMockServer = false |
| 30 | + override fun initTestActivity() = InitTestActivity.UserLogin |
| 31 | + |
| 32 | + @Test |
| 33 | + fun test_message() { |
| 34 | + val originalMessage = "hi" |
| 35 | + val editedMessage = "hello" |
| 36 | + |
| 37 | + step("GIVEN user opens a channel") { |
| 38 | + userRobot.login().openChannel() |
| 39 | + } |
| 40 | + step("WHEN user sends a message") { |
| 41 | + userRobot.sendMessage(originalMessage) |
| 42 | + } |
| 43 | + step("THEN message appears") { |
| 44 | + userRobot.assertMessage(originalMessage) |
| 45 | + } |
| 46 | + step("WHEN user edits the message") { |
| 47 | + userRobot.editMessage(editedMessage) |
| 48 | + } |
| 49 | + step("THEN the message is edited") { |
| 50 | + userRobot.assertMessage(editedMessage) |
| 51 | + } |
| 52 | + step("WHEN user deletes the message") { |
| 53 | + userRobot.deleteMessage() |
| 54 | + } |
| 55 | + step("THEN the message is deleted") { |
| 56 | + userRobot.assertDeletedMessage() |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + fun test_reaction() { |
| 62 | + val message = "test" |
| 63 | + |
| 64 | + step("GIVEN user opens the channel") { |
| 65 | + userRobot.login().openChannel() |
| 66 | + } |
| 67 | + step("WHEN user sends the message") { |
| 68 | + userRobot.sendMessage(message) |
| 69 | + } |
| 70 | + step("AND user adds the reaction") { |
| 71 | + userRobot.addReaction(type = ReactionType.LIKE) |
| 72 | + } |
| 73 | + step("THEN the reaction is added") { |
| 74 | + userRobot.assertReaction(type = ReactionType.LIKE, isDisplayed = true) |
| 75 | + } |
| 76 | + step("WHEN user removes the reaction") { |
| 77 | + userRobot.deleteReaction(type = ReactionType.LIKE) |
| 78 | + } |
| 79 | + step("THEN the reaction is removed") { |
| 80 | + userRobot.assertReaction(type = ReactionType.LIKE, isDisplayed = false) |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments