e2e: tests for reactions in community and group chats

This commit is contained in:
Yevheniia Berdnyk 2023-07-03 16:06:16 +03:00
parent 1f6f907d57
commit ef99bf2ad6
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
3 changed files with 171 additions and 11 deletions

View File

@ -406,16 +406,19 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase):
except WebDriverException:
pass
url = 'https://api.%s/rest/v1/%s/jobs/%s/assets/%s' % (apibase, sauce_username, session_id, "log.json")
WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200)
commands = requests_session.get(url).json()
for command in commands:
try:
if command['message'].startswith("Started "):
for test in test_suite_data.tests:
if command['message'] == "Started %s" % test.name:
test.testruns[-1].first_commands[session_id] = commands.index(command) + 1
except KeyError:
continue
try:
WebDriverWait(driver, 60, 2).until(lambda _: requests_session.get(url).status_code == 200)
commands = requests_session.get(url).json()
for command in commands:
try:
if command['message'].startswith("Started "):
for test in test_suite_data.tests:
if command['message'] == "Started %s" % test.name:
test.testruns[-1].first_commands[session_id] = commands.index(command) + 1
except KeyError:
continue
except (RemoteDisconnected, requests.exceptions.ConnectionError):
pass
if cls.loop:
cls.loop.close()
for test in test_suite_data.tests:

View File

@ -1,6 +1,8 @@
import pytest
from _pytest.outcomes import Failed
from selenium.common.exceptions import NoSuchElementException
from tests import marks, run_in_parallel, common_password
from tests import marks, run_in_parallel
from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
from views.chat_view import ChatView
from views.sign_in_view import SignInView
@ -226,6 +228,119 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
self.errors.append('Message %s was not received by admin' % message_to_admin)
self.errors.verify_no_errors()
@marks.testrail_id(703202)
def test_group_chat_reactions(self):
[self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)]
[self.homes[i].get_chat(self.chat_name).click() for i in range(3)]
message = "This is a test message to check some reactions."
self.chats[0].just_fyi("Admin sends a message")
self.chats[0].send_message(message)
self.chats[1].just_fyi("Member_1 sets 2 reactions on the message: 'thumbs-up' and 'love'")
self.chats[1].set_reaction(message=message, emoji="thumbs-up")
self.chats[1].set_reaction(message=message, emoji="love")
self.chats[2].just_fyi("Member_2 sets 2 reactions on the message: 'thumbs-up' and 'laugh'")
self.chats[2].add_remove_same_reaction(message=message, emoji="thumbs-up")
self.chats[2].set_reaction(message=message, emoji="laugh")
for i in range(3):
self.chats[i].just_fyi("Checking reactions count for each group member and admin")
message_element = self.chats[i].chat_element_by_text(message)
message_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(2)
message_element.emojis_below_message(emoji="love").wait_for_element_text(1)
message_element.emojis_below_message(emoji="laugh").wait_for_element_text(1)
self.chats[0].just_fyi("Admin checks info about voted users")
self.chats[0].chat_element_by_text(message).emojis_below_message(
emoji="thumbs-up").long_press_until_element_is_shown(self.chats[0].authors_for_reaction(emoji="thumbs-up"))
if not self.chats[0].user_list_element_by_name(
self.usernames[1]).is_element_displayed() or not self.chats[0].user_list_element_by_name(
self.usernames[2]).is_element_displayed():
self.errors.append("Incorrect users are shown for 'thumbs-up' reaction.")
self.chats[0].authors_for_reaction(emoji="love").click()
if not self.chats[0].user_list_element_by_name(
self.usernames[1]).is_element_displayed() or self.chats[0].user_list_element_by_name(
self.usernames[2]).is_element_displayed():
self.errors.append("Incorrect users are shown for 'love' reaction.")
self.chats[0].authors_for_reaction(emoji="laugh").click()
if self.chats[0].user_list_element_by_name(
self.usernames[1]).is_element_displayed() or not self.chats[0].user_list_element_by_name(
self.usernames[2]).is_element_displayed():
self.errors.append("Incorrect users are shown for 'laugh' reaction.")
self.chats[0].just_fyi("Admin opens member_2 profile")
self.chats[0].user_list_element_by_name(self.usernames[2]).click()
try:
username_shown = self.chats[0].get_profile_view().default_username_text.text
if username_shown != self.usernames[2]:
self.errors.append(
"Incorrect profile is opened from the list of reactions, username is %s but expected to be %s" % (
username_shown, self.usernames[2])
)
except NoSuchElementException:
self.errors.append("User profile was not opened from the list of reactions")
self.chats[0].click_system_back_button_until_element_is_shown(element="chat")
self.chats[1].just_fyi("Member_1 removes 'thumbs-up' reaction and adds 'sad' one")
self.chats[1].add_remove_same_reaction(message=message, emoji="thumbs-up")
self.chats[1].set_reaction(message=message, emoji="sad")
self.chats[2].just_fyi("Member_2 removes 'laugh' reaction and adds 'sad' one")
self.chats[2].add_remove_same_reaction(message=message, emoji="laugh")
self.chats[2].add_remove_same_reaction(message=message, emoji="sad")
for i in range(3):
self.chats[i].just_fyi("Checking reactions count for each group member and admin after they were changed")
message_element = self.chats[i].chat_element_by_text(message)
try:
message_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(1)
message_element.emojis_below_message(emoji="love").wait_for_element_text(1)
message_element.emojis_below_message(emoji="sad").wait_for_element_text(2)
except (Failed, NoSuchElementException):
self.errors.append("Incorrect reactions count for %s after changing the reactions" % self.usernames[i])
self.chats[0].just_fyi("Admin relogins")
self.chats[0].reopen_app()
self.homes[0].get_chat(self.chat_name).click()
self.chats[0].just_fyi("Admin checks reactions count after relogin")
message_element = self.chats[0].chat_element_by_text(message)
try:
message_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(1)
message_element.emojis_below_message(emoji="love").wait_for_element_text(1)
message_element.emojis_below_message(emoji="sad").wait_for_element_text(2)
except (Failed, NoSuchElementException):
self.errors.append("Incorrect reactions count after relogin")
for chat in self.chats[1], self.chats[2]:
chat.just_fyi("Just making the session not to quit")
chat.click_system_back_button_until_element_is_shown()
self.chats[0].just_fyi("Admin checks info about voted users after relogin")
message_element.emojis_below_message(
emoji="thumbs-up").long_press_until_element_is_shown(self.chats[0].authors_for_reaction(emoji="thumbs-up"))
if self.chats[0].user_list_element_by_name(
self.usernames[1]).is_element_displayed() or not self.chats[0].user_list_element_by_name(
self.usernames[2]).is_element_displayed():
self.errors.append("Incorrect users are shown for 'thumbs-up' reaction after relogin.")
self.chats[0].authors_for_reaction(emoji="love").click()
if not self.chats[0].user_list_element_by_name(
self.usernames[1]).is_element_displayed() or self.chats[0].user_list_element_by_name(
self.usernames[2]).is_element_displayed():
self.errors.append("Incorrect users are shown for 'love' reaction after relogin.")
self.chats[0].authors_for_reaction(emoji="sad").click()
if not self.chats[0].user_list_element_by_name(
self.usernames[1]).is_element_displayed() or not self.chats[0].user_list_element_by_name(
self.usernames[2]).is_element_displayed():
self.errors.append("Incorrect users are shown for 'laugh' reaction after relogin.")
self.errors.verify_no_errors()
@marks.testrail_id(702808)
def test_group_chat_offline_pn(self):
[self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)]

View File

@ -3,6 +3,7 @@ from datetime import timedelta
import emoji
import pytest
from _pytest.outcomes import Failed
from dateutil import parser
from selenium.common.exceptions import NoSuchElementException, TimeoutException
@ -500,6 +501,12 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
for channel in (self.channel_1, self.channel_2):
if not channel.element_by_text_part(message_after_edit).is_element_displayed(60):
self.errors.append('Message is not edited')
message_text_after_edit = message_after_edit + ' (Edited)'
self.channel_2.set_reaction(message_text_after_edit)
try:
self.channel_1.chat_element_by_text(message_text_after_edit).emojis_below_message().wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Message reaction is not shown for the sender")
self.errors.verify_no_errors()
@marks.testrail_id(702839)
@ -578,6 +585,21 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
if not chat_element_1.is_element_displayed(sec=60) or chat_element_1.replied_message_text != image_description:
self.errors.append('Reply message was not received by the sender')
self.channel_2.just_fyi("Set a reaction for the image message")
self.channel_2.set_reaction(message=image_description)
try:
self.channel_1.chat_element_by_text(image_description).emojis_below_message().wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Image message reaction is not shown for the sender")
self.channel_1.just_fyi("Set a reaction for the message reply")
self.channel_2.set_reaction(message=image_description, emoji="love")
try:
self.channel_2.chat_element_by_text(message_text).emojis_below_message(
emoji="love").wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Reply message reaction is not shown for the reply sender")
self.errors.verify_no_errors()
@marks.testrail_id(703194)
@ -701,6 +723,15 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
if shown_link != data['link']:
self.errors.append("Link is not equal expected for '%s', actual is '%s'" % (url, shown_link))
self.channel_1.just_fyi("Set reaction and check it")
message_with_reaction = list(preview_urls.values())[-1]['url']
self.channel_1.set_reaction(message=message_with_reaction, emoji="laugh")
try:
self.channel_2.chat_element_by_text(message_with_reaction).emojis_below_message(
emoji="laugh").wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Link message reaction is not shown for the sender")
self.errors.verify_no_errors()
@marks.testrail_id(702841)
@ -852,9 +883,11 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.device_1.just_fyi("Admin gets push notification with the mention and tap it")
self.device_1.open_notification_bar()
message_received = False
if self.home_1.get_pn(self.username_1):
self.device_1.click_upon_push_notification_by_text(self.username_1)
if not self.channel_1.chat_element_by_text(self.username_1).is_element_displayed():
message_received = True
if self.channel_1.chat_message_input.is_element_displayed():
self.errors.append("Message with the mention is not shown in the chat for the admin")
else:
@ -863,6 +896,15 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
else:
self.errors.append("Push notification with the mention was not received by admin")
if message_received:
self.channel_1.just_fyi("Set reaction for the message with a mention")
self.channel_1.set_reaction(message=self.username_1, emoji="sad")
try:
self.channel_2.chat_element_by_text(self.username_1).emojis_below_message(
emoji="sad").wait_for_element_text(1)
except (Failed, NoSuchElementException):
self.errors.append("Message reaction is not shown for the sender")
# ToDo: this part is skipped because of an issue - sent messages stuck without any status for a long time
# and can not be edited during that time
# self.device_2.just_fyi("Sender edits the message with a mention")