2019-08-02 21:22:23 +00:00
|
|
|
import emoji
|
|
|
|
import random
|
2019-08-16 10:14:23 +00:00
|
|
|
from dateutil import parser
|
2018-06-21 16:40:27 +00:00
|
|
|
from tests import marks
|
2018-07-19 09:57:45 +00:00
|
|
|
from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase
|
2018-06-21 16:40:27 +00:00
|
|
|
from views.sign_in_view import SignInView
|
2019-06-04 11:37:19 +00:00
|
|
|
from datetime import datetime, timedelta
|
2018-06-21 16:40:27 +00:00
|
|
|
|
|
|
|
|
2018-07-19 09:57:45 +00:00
|
|
|
class TestPublicChatMultipleDevice(MultipleDeviceTestCase):
|
2018-06-21 16:40:27 +00:00
|
|
|
|
2018-09-28 15:30:06 +00:00
|
|
|
@marks.testrail_id(5313)
|
|
|
|
@marks.critical
|
2021-05-13 16:03:01 +00:00
|
|
|
def test_public_chat_messaging_emojis_timestamps(self):
|
2018-06-21 16:40:27 +00:00
|
|
|
self.create_drivers(2)
|
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
2019-05-13 07:58:41 +00:00
|
|
|
home_1, home_2 = device_1.create_user(), device_2.create_user()
|
2018-10-06 12:00:30 +00:00
|
|
|
profile_1 = home_1.profile_button.click()
|
|
|
|
default_username_1 = profile_1.default_username_text.text
|
|
|
|
profile_1.home_button.click()
|
2018-06-28 18:46:51 +00:00
|
|
|
home_2.home_button.click()
|
|
|
|
|
2021-05-13 16:03:01 +00:00
|
|
|
home_1.just_fyi("Check preselected chats, redirect to status chat")
|
2019-12-26 11:56:59 +00:00
|
|
|
home_1.plus_button.click_until_presence_of_element(home_1.join_public_chat_button)
|
2019-12-27 11:34:59 +00:00
|
|
|
home_1.join_public_chat_button.click()
|
2020-07-10 14:39:26 +00:00
|
|
|
preselected_chats = ['#status', '#chitchat', '#defi', '#crypto', '#markets', '#dap-ps']
|
2019-12-26 11:56:59 +00:00
|
|
|
for chat in preselected_chats:
|
|
|
|
if not home_1.element_by_text(chat).is_element_displayed():
|
|
|
|
self.errors.append("'%s' text is not in the list of preselected chats" % chat)
|
2021-05-13 16:03:01 +00:00
|
|
|
home_1.element_by_text(preselected_chats[0]).click()
|
2019-12-26 11:56:59 +00:00
|
|
|
status_chat = home_1.get_chat_view()
|
2021-05-13 16:03:01 +00:00
|
|
|
if not status_chat.user_name_text != preselected_chats[0]:
|
2019-12-26 11:56:59 +00:00
|
|
|
self.errors.append('No redirect to chat if tap on #status chat')
|
2021-05-13 16:03:01 +00:00
|
|
|
status_chat.home_button.click()
|
2019-12-26 11:56:59 +00:00
|
|
|
|
2020-04-10 10:25:46 +00:00
|
|
|
public_chat_name = home_1.get_random_chat_name()
|
2018-06-28 18:46:51 +00:00
|
|
|
chat_1, chat_2 = home_1.join_public_chat(public_chat_name), home_2.join_public_chat(public_chat_name)
|
|
|
|
|
2021-05-13 16:03:01 +00:00
|
|
|
home_1.just_fyi("Check sending text messages, emojis, usernames and timestamps on messages")
|
|
|
|
emoji_name = random.choice(list(emoji.EMOJI_UNICODE))
|
|
|
|
emoji_unicode = emoji.EMOJI_UNICODE[emoji_name]
|
|
|
|
message, emoji_message = 'hello', emoji.emojize(emoji_name)
|
2021-02-18 15:12:54 +00:00
|
|
|
chat_1.send_message(message)
|
2018-06-21 16:40:27 +00:00
|
|
|
|
2021-02-19 13:46:29 +00:00
|
|
|
sent_time_variants = chat_1.convert_device_time_to_chat_timestamp()
|
2021-02-18 15:12:54 +00:00
|
|
|
for chat in chat_1, chat_2:
|
|
|
|
chat.verify_message_is_under_today_text(message, self.errors)
|
|
|
|
timestamp = chat.chat_element_by_text(message).timestamp_message.text
|
2021-02-19 13:46:29 +00:00
|
|
|
if timestamp not in sent_time_variants:
|
|
|
|
self.errors.append("Timestamp is not shown, expected '%s', in fact '%s'" % (sent_time_variants.join(','), timestamp))
|
2019-06-26 14:57:46 +00:00
|
|
|
if chat_2.chat_element_by_text(message).username.text != default_username_1:
|
|
|
|
self.errors.append("Default username '%s' is not shown next to the received message" % default_username_1)
|
2018-06-28 18:46:51 +00:00
|
|
|
|
2021-05-13 16:03:01 +00:00
|
|
|
chat_1.send_message(emoji_message)
|
|
|
|
for chat in chat_1, chat_2:
|
|
|
|
if not chat.chat_element_by_text(emoji_unicode).is_element_displayed():
|
|
|
|
self.errors.append('Message with emoji was not sent or received in public chat')
|
|
|
|
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|
2018-07-03 12:40:44 +00:00
|
|
|
|
2018-09-28 15:30:06 +00:00
|
|
|
@marks.testrail_id(5360)
|
|
|
|
@marks.critical
|
2018-07-19 09:57:45 +00:00
|
|
|
def test_unread_messages_counter_public_chat(self):
|
|
|
|
self.create_drivers(2)
|
2021-03-17 09:28:23 +00:00
|
|
|
driver_2 = self.drivers[1]
|
|
|
|
home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user()
|
2021-05-28 15:39:33 +00:00
|
|
|
profile_1 = home_1.profile_button.click()
|
|
|
|
username_1 = profile_1.default_username_text.text
|
|
|
|
profile_1.home_button.click()
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2020-04-10 10:25:46 +00:00
|
|
|
chat_name = home_1.get_random_chat_name()
|
2018-07-19 09:57:45 +00:00
|
|
|
chat_1, chat_2 = home_1.join_public_chat(chat_name), home_2.join_public_chat(chat_name)
|
2021-05-28 15:39:33 +00:00
|
|
|
chat_1.send_message('пиу')
|
|
|
|
chat_1.home_button.click()
|
2021-03-17 09:28:23 +00:00
|
|
|
message, message_2 = 'test message', 'test message2'
|
|
|
|
chat_2.send_message(message)
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2021-03-17 09:28:23 +00:00
|
|
|
home_1.just_fyi("Check unread message indicator on home, on chat element and that it is not shown after reading messages")
|
2020-03-03 12:06:55 +00:00
|
|
|
if not home_1.home_button.public_unread_messages.is_element_displayed():
|
|
|
|
self.errors.append('New messages public chat badge is not shown on Home button')
|
2020-03-17 17:27:10 +00:00
|
|
|
chat_element = home_1.get_chat('#' + chat_name)
|
2020-03-03 12:06:55 +00:00
|
|
|
if not chat_element.new_messages_public_chat.is_element_displayed():
|
|
|
|
self.errors.append('New messages counter is not shown in public chat')
|
2021-05-28 15:39:33 +00:00
|
|
|
|
|
|
|
home_1.just_fyi("Check unread message counter when mentioned in public chat")
|
|
|
|
chat_2 = home_2.get_chat_view()
|
|
|
|
chat_2.select_mention_from_suggestion_list(username_1, username_1[:2])
|
|
|
|
chat_2.send_message_button.click()
|
2021-07-28 12:42:06 +00:00
|
|
|
chat_element.new_messages_counter.wait_for_element(30)
|
2021-05-28 15:39:33 +00:00
|
|
|
if chat_element.new_messages_counter.text == '1':
|
|
|
|
self.errors.append('Counter is not shown for mention in public chat')
|
|
|
|
|
2018-07-19 09:57:45 +00:00
|
|
|
chat_element.click()
|
2021-03-17 09:28:23 +00:00
|
|
|
home_1.home_button.double_click()
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2020-03-03 12:06:55 +00:00
|
|
|
if home_1.home_button.public_unread_messages.is_element_displayed():
|
|
|
|
self.errors.append('New messages public chat badge is shown on Home button')
|
|
|
|
if chat_element.new_messages_public_chat.is_element_displayed():
|
2021-04-30 09:31:39 +00:00
|
|
|
self.errors.append('Unread messages badge is shown in public chat while there are no unread messages')
|
2021-03-17 09:28:23 +00:00
|
|
|
[home.get_chat('#' + chat_name).click() for home in (home_1,home_2)]
|
|
|
|
chat_1.send_message(message_2)
|
|
|
|
chat_2.chat_element_by_text(message_2).wait_for_element(20)
|
|
|
|
|
|
|
|
home_2.just_fyi("Check that unread message indicator is not reappeared after relogin")
|
|
|
|
driver_2.close_app()
|
|
|
|
driver_2.launch_app()
|
|
|
|
SignInView(driver_2).sign_in()
|
|
|
|
chat_element = home_2.get_chat('#' + chat_name)
|
|
|
|
if chat_element.new_messages_public_chat.is_element_displayed():
|
|
|
|
self.errors.append('New messages counter is shown after relogin')
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2020-04-06 16:21:23 +00:00
|
|
|
@marks.testrail_id(6270)
|
|
|
|
@marks.medium
|
|
|
|
def test_mark_all_messages_as_read_public_chat(self):
|
|
|
|
self.create_drivers(2)
|
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
|
|
|
home_1, home_2 = device_1.create_user(), device_2.create_user()
|
2020-04-10 10:25:46 +00:00
|
|
|
chat_name = home_1.get_random_chat_name()
|
2020-04-06 16:21:23 +00:00
|
|
|
chat_1, chat_2 = home_1.join_public_chat(chat_name), home_2.join_public_chat(chat_name)
|
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
message = 'test message'
|
|
|
|
chat_2.chat_message_input.send_keys(message)
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
|
|
|
|
if not home_1.home_button.public_unread_messages.is_element_displayed():
|
|
|
|
self.errors.append('New messages public chat badge is not shown on Home button')
|
|
|
|
chat_element = home_1.get_chat('#' + chat_name)
|
|
|
|
if not chat_element.new_messages_public_chat.is_element_displayed():
|
|
|
|
self.errors.append('New messages counter is not shown in public chat')
|
|
|
|
|
|
|
|
chat_element.long_press_element()
|
|
|
|
home_1.mark_all_messages_as_read_button.click()
|
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
|
|
|
|
if home_1.home_button.public_unread_messages.is_element_displayed():
|
|
|
|
self.errors.append('New messages public chat badge is shown on Home button')
|
|
|
|
if chat_element.new_messages_public_chat.is_element_displayed():
|
|
|
|
self.errors.append('Unread messages badge is shown in public chat while while there are no unread messages')
|
|
|
|
|
|
|
|
self.errors.verify_no_errors()
|
|
|
|
|
2021-05-10 15:27:22 +00:00
|
|
|
|
|
|
|
@marks.testrail_id(6275)
|
|
|
|
@marks.medium
|
|
|
|
def test_receive_message_while_in_different_tab_and_emoji_messages_long_press(self):
|
2019-08-02 21:22:23 +00:00
|
|
|
self.create_drivers(2)
|
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
|
|
|
home_1, home_2 = device_1.create_user(), device_2.create_user()
|
2021-05-10 15:27:22 +00:00
|
|
|
public_chat_name = home_1.get_random_chat_name()
|
|
|
|
chat_1, chat_2 = home_1.join_public_chat(public_chat_name), home_2.join_public_chat(public_chat_name)
|
2019-08-02 21:22:23 +00:00
|
|
|
|
2021-05-10 15:27:22 +00:00
|
|
|
device_2.just_fyi("Switch to different tab out from chat")
|
|
|
|
device_2.dapp_tab_button.click()
|
2019-08-02 21:22:23 +00:00
|
|
|
emoji_name = random.choice(list(emoji.EMOJI_UNICODE))
|
|
|
|
emoji_unicode = emoji.EMOJI_UNICODE[emoji_name]
|
|
|
|
chat_1.chat_message_input.send_keys(emoji.emojize(emoji_name))
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
|
2021-05-10 15:27:22 +00:00
|
|
|
device_1.just_fyi("Long press emoji message actions")
|
2020-06-09 14:44:44 +00:00
|
|
|
chat_1.element_by_text_part(emoji_unicode).long_press_element()
|
2019-08-02 21:22:23 +00:00
|
|
|
chat_1.element_by_text('Copy').click()
|
|
|
|
chat_1.chat_message_input.paste_text_from_clipboard()
|
|
|
|
if chat_1.chat_message_input.text != emoji_unicode:
|
|
|
|
self.errors.append('Emoji message was not copied')
|
|
|
|
|
2021-05-10 15:27:22 +00:00
|
|
|
home_2.home_button.click(desired_view='chat')
|
2020-06-09 14:44:44 +00:00
|
|
|
chat_element_2 = chat_2.element_by_text_part(emoji_unicode)
|
2019-08-02 21:22:23 +00:00
|
|
|
if not chat_element_2.is_element_displayed(sec=10):
|
|
|
|
self.errors.append('Message with emoji was not received in public chat by the recipient')
|
|
|
|
|
2019-11-08 18:24:55 +00:00
|
|
|
chat_2.quote_message(emoji_unicode)
|
2019-08-02 21:22:23 +00:00
|
|
|
message_text = 'test message'
|
|
|
|
chat_2.chat_message_input.send_keys(message_text)
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
|
|
|
|
chat_element_1 = chat_1.chat_element_by_text(message_text)
|
|
|
|
if not chat_element_1.is_element_displayed(sec=10) or chat_element_1.replied_message_text != emoji_unicode:
|
|
|
|
self.errors.append('Reply message was not received by the sender')
|
|
|
|
|
2021-05-10 15:27:22 +00:00
|
|
|
self.errors.verify_no_errors()
|
2020-04-03 11:01:55 +00:00
|
|
|
|
2018-07-19 09:57:45 +00:00
|
|
|
|
|
|
|
class TestPublicChatSingleDevice(SingleDeviceTestCase):
|
|
|
|
|
2018-11-22 13:36:43 +00:00
|
|
|
@marks.testrail_id(5675)
|
|
|
|
@marks.high
|
2021-05-13 16:03:01 +00:00
|
|
|
def test_redirect_to_public_chat_tapping_tag_message_fetch_more_history(self):
|
2018-11-22 13:36:43 +00:00
|
|
|
signin = SignInView(self.driver)
|
|
|
|
home_view = signin.create_user()
|
2021-05-13 16:03:01 +00:00
|
|
|
chat_name = 'montagne-angerufen'
|
|
|
|
chat = home_view.join_public_chat(chat_name)
|
2018-11-22 13:36:43 +00:00
|
|
|
tag_message = '#spectentur'
|
2021-05-13 16:03:01 +00:00
|
|
|
|
|
|
|
signin.just_fyi("Check that will be redirected to chat view on tap on tag message")
|
2018-11-22 13:36:43 +00:00
|
|
|
chat.send_message(tag_message)
|
|
|
|
chat.element_starts_with_text(tag_message).click()
|
2021-05-13 16:03:01 +00:00
|
|
|
chat.element_by_text_part(chat_name).wait_for_invisibility_of_element()
|
2018-11-22 13:36:43 +00:00
|
|
|
if not chat.user_name_text.text == tag_message:
|
2021-05-13 16:03:01 +00:00
|
|
|
self.errors.append('Could not redirect a user to a public chat tapping the tag message.')
|
2020-06-12 15:32:06 +00:00
|
|
|
|
2021-05-13 16:03:01 +00:00
|
|
|
signin.just_fyi("Check that can fetch previous history")
|
2019-08-16 10:14:23 +00:00
|
|
|
device_time = parser.parse(signin.driver.device_time)
|
|
|
|
yesterday = (device_time - timedelta(days=1)).strftime("%b %-d, %Y")
|
|
|
|
before_yesterday = (device_time - timedelta(days=2)).strftime("%b %-d, %Y")
|
2019-06-04 11:37:19 +00:00
|
|
|
quiet_time_yesterday, quiet_time_before_yesterday = '24 hours', '2 days'
|
2021-05-13 16:03:01 +00:00
|
|
|
fetch_more = signin.get_translation_by_key("load-more-messages")
|
2019-06-04 11:37:19 +00:00
|
|
|
for message in (yesterday, quiet_time_yesterday):
|
|
|
|
if not chat.element_by_text_part(message).is_element_displayed():
|
|
|
|
self.driver.fail('"%s" is not shown' % message)
|
2021-05-13 16:03:01 +00:00
|
|
|
chat.element_by_text_part(fetch_more).wait_and_click(120)
|
|
|
|
chat.element_by_text_part(fetch_more).wait_for_visibility_of_element(180)
|
2019-06-04 11:37:19 +00:00
|
|
|
for message in (before_yesterday, quiet_time_before_yesterday):
|
|
|
|
if not chat.element_by_text_part(message).is_element_displayed():
|
|
|
|
self.driver.fail('"%s" is not shown' % message)
|
2021-05-13 16:03:01 +00:00
|
|
|
|
|
|
|
signin.just_fyi("Check that chat is added to home view")
|
|
|
|
home_view = chat.get_back_to_home_view()
|
|
|
|
if not home_view.element_by_text(tag_message).is_element_displayed():
|
|
|
|
self.errors.append('Could not find the public chat in user chat list.')
|
|
|
|
|
2021-06-29 15:55:55 +00:00
|
|
|
times = {
|
|
|
|
"three-days" : '5 days',
|
|
|
|
"one-week" : '12 days',
|
|
|
|
"one-month" : ['43 days', '42 days', '41 days', '40 days'],
|
|
|
|
}
|
|
|
|
|
|
|
|
signin.just_fyi("Check that can fetch more history")
|
|
|
|
home_view.element_by_text(tag_message).click()
|
|
|
|
profile = home_view.profile_button.click()
|
|
|
|
profile.sync_settings_button.click()
|
|
|
|
profile.sync_history_for_button.click()
|
|
|
|
for period in times:
|
|
|
|
profile.just_fyi("Checking %s period" % period)
|
|
|
|
profile.element_by_translation_id(period).click()
|
|
|
|
profile.home_button.click(desired_view='chat')
|
|
|
|
chat.element_by_text_part(fetch_more).wait_and_click(120)
|
|
|
|
if period != "one-month":
|
|
|
|
if not profile.element_by_text_part(times[period]).is_element_displayed(30):
|
|
|
|
self.errors.append("'Quiet here for %s' is not shown after fetching more history" % times[period])
|
|
|
|
else:
|
|
|
|
variants = times[period]
|
|
|
|
res = any(profile.element_by_text_part(variant).is_element_displayed(30) for variant in variants)
|
|
|
|
if not res:
|
|
|
|
self.errors.append("History is not fetched for one month!" )
|
|
|
|
home_view.profile_button.click(desired_element_text=profile.get_translation_by_key("default-sync-period"))
|
|
|
|
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|