2019-01-09 14:54:58 +00:00
|
|
|
import time
|
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-11-26 15:41:31 +00:00
|
|
|
from selenium.common.exceptions import TimeoutException
|
2018-11-21 10:44:30 +00:00
|
|
|
from support.utilities import generate_timestamp
|
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
|
|
|
|
|
|
|
|
|
|
|
@marks.chat
|
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
|
2018-07-03 12:40:44 +00:00
|
|
|
def test_public_chat_messaging(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
|
|
|
public_key_2 = home_2.get_public_key()
|
|
|
|
home_2.home_button.click()
|
|
|
|
|
|
|
|
home_1.add_contact(public_key_2)
|
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
|
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()
|
2019-12-26 11:56:59 +00:00
|
|
|
preselected_chats = ['#status', '#introductions', '#chitchat', '#crypto', '#tech', '#music', '#movies', '#support']
|
|
|
|
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)
|
|
|
|
home_1.element_by_text('#status').click()
|
|
|
|
status_chat = home_1.get_chat_view()
|
|
|
|
if not status_chat.chat_message_input.is_element_displayed():
|
|
|
|
self.errors.append('No redirect to chat if tap on #status chat')
|
|
|
|
status_chat.get_back_to_home_view()
|
|
|
|
|
|
|
|
|
2018-06-29 17:27:30 +00:00
|
|
|
public_chat_name = home_1.get_public_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)
|
|
|
|
|
2018-06-21 16:40:27 +00:00
|
|
|
message = 'hello'
|
|
|
|
chat_1.chat_message_input.send_keys(message)
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
|
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
|
|
|
|
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(5386)
|
|
|
|
@marks.high
|
2018-07-03 12:40:44 +00:00
|
|
|
def test_public_chat_clear_history(self):
|
|
|
|
self.create_drivers(2)
|
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
|
|
|
chat_name = device_1.get_public_chat_name()
|
|
|
|
for sign_in in device_1, device_2:
|
|
|
|
home = sign_in.create_user()
|
|
|
|
home.join_public_chat(chat_name)
|
|
|
|
chat_1, chat_2 = device_1.get_chat_view(), device_2.get_chat_view()
|
|
|
|
message_1, message_2, message_3 = 'm1', 'm2', 'm3'
|
|
|
|
chat_1.chat_message_input.send_keys(message_1)
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
chat_2.element_by_text(message_1).is_element_present()
|
|
|
|
|
|
|
|
chat_2.chat_message_input.send_keys(message_2)
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
chat_1.element_by_text(message_2).is_element_present()
|
|
|
|
chat_1.chat_options.click()
|
|
|
|
chat_1.clear_history_button.click()
|
|
|
|
chat_1.clear_button.click()
|
|
|
|
chat_2.chat_message_input.send_keys(message_3)
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
chat_1.element_by_text(message_3).is_element_present()
|
|
|
|
for message in message_1, message_2:
|
|
|
|
if chat_1.element_starts_with_text(message).is_element_present():
|
2018-08-15 12:51:52 +00:00
|
|
|
chat_1.driver.fail("Message '%s' is shown, but public chat history has been cleared" % message)
|
2018-07-03 12:40:44 +00:00
|
|
|
home_1 = chat_1.get_back_to_home_view()
|
|
|
|
home_1.relogin()
|
|
|
|
home_1.element_by_text('#' + chat_name).click()
|
|
|
|
for message in message_1, message_2:
|
|
|
|
if chat_1.element_starts_with_text(message).is_element_present():
|
2018-08-15 12:51:52 +00:00
|
|
|
chat_1.driver.fail(
|
|
|
|
"Message '%s' is shown after re-login, but public chat history has been cleared" % message)
|
2018-07-19 09:57:45 +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)
|
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
|
|
|
home_1, home_2 = device_1.create_user(), device_2.create_user()
|
|
|
|
|
|
|
|
chat_name = home_1.get_public_chat_name()
|
|
|
|
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()
|
|
|
|
|
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')
|
2018-07-19 09:57:45 +00:00
|
|
|
|
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')
|
2018-07-19 09:57:45 +00:00
|
|
|
|
|
|
|
chat_element.click()
|
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
|
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():
|
|
|
|
self.errors.append('Unread messages badge is shown in public chat while while there are no unread messages')
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|
2018-07-19 09:57:45 +00:00
|
|
|
|
2019-08-02 21:22:23 +00:00
|
|
|
@marks.testrail_id(6202)
|
|
|
|
@marks.low
|
|
|
|
def test_emoji_messages_long_press(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()
|
|
|
|
|
|
|
|
chat_name = home_1.get_public_chat_name()
|
|
|
|
chat_1, chat_2 = home_1.join_public_chat(chat_name), home_2.join_public_chat(chat_name)
|
|
|
|
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()
|
|
|
|
|
|
|
|
chat_1.chat_element_by_text(emoji_unicode).long_press_element()
|
|
|
|
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')
|
|
|
|
|
|
|
|
chat_element_2 = chat_2.chat_element_by_text(emoji_unicode)
|
|
|
|
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')
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|
2019-08-02 21:22:23 +00:00
|
|
|
|
2020-04-03 11:01:55 +00:00
|
|
|
@marks.testrail_id(6275)
|
|
|
|
@marks.medium
|
|
|
|
def test_public_chat_messaging(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()
|
|
|
|
public_chat_name = home_1.get_public_chat_name()
|
|
|
|
chat_1, chat_2 = home_1.join_public_chat(public_chat_name), home_2.join_public_chat(public_chat_name)
|
|
|
|
|
|
|
|
browser = device_1.dapp_tab_button.click()
|
|
|
|
message = 'hello'
|
|
|
|
chat_2.send_message(message)
|
|
|
|
|
|
|
|
if home_1.home_button.public_unread_messages.is_element_displayed():
|
|
|
|
device_1.home_button.click_until_absense_of_element(browser.enter_url_editbox)
|
|
|
|
if not chat_1.chat_element_by_text(message).is_element_displayed():
|
|
|
|
self.driver.fail("No message if it received while another tab opened")
|
|
|
|
|
2018-07-19 09:57:45 +00:00
|
|
|
|
|
|
|
@marks.chat
|
|
|
|
class TestPublicChatSingleDevice(SingleDeviceTestCase):
|
|
|
|
|
2018-11-22 13:36:43 +00:00
|
|
|
@marks.testrail_id(5675)
|
|
|
|
@marks.high
|
|
|
|
def test_redirect_to_public_chat_tapping_tag_message(self):
|
|
|
|
signin = SignInView(self.driver)
|
|
|
|
home_view = signin.create_user()
|
|
|
|
chat = home_view.join_public_chat('montagne-angerufen')
|
|
|
|
tag_message = '#spectentur'
|
|
|
|
chat.send_message(tag_message)
|
|
|
|
chat.element_starts_with_text(tag_message).click()
|
2019-01-09 14:54:58 +00:00
|
|
|
time.sleep(4)
|
2018-11-22 13:36:43 +00:00
|
|
|
if not chat.user_name_text.text == tag_message:
|
|
|
|
self.driver.fail('Could not redirect a user to a public chat tapping the tag message.')
|
|
|
|
home = chat.get_back_to_home_view()
|
|
|
|
if not home.chat_name_text.text == tag_message:
|
|
|
|
self.driver.fail('Could not find the public chat in user chat list.')
|
2019-06-04 11:37:19 +00:00
|
|
|
|
|
|
|
@marks.testrail_id(6205)
|
|
|
|
@marks.high
|
|
|
|
def test_fetch_more_history_in_empty_chat(self):
|
|
|
|
signin = SignInView(self.driver)
|
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'
|
|
|
|
home_view = signin.create_user()
|
|
|
|
chat = home_view.join_public_chat('montagne-angerufen-two')
|
|
|
|
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)
|
|
|
|
chat.element_starts_with_text("↓ Fetch more messages").click()
|
|
|
|
chat.wait_for_element_starts_with_text("↓ Fetch more messages", 30)
|
|
|
|
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)
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|