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
|
|
|
|
|
|
|
|
|
|
|
|
@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])
|
2018-06-28 18:46:51 +00:00
|
|
|
username_1, username_2 = 'user_1', 'user_2'
|
|
|
|
home_1, home_2 = device_1.create_user(username=username_1), device_2.create_user(username=username_2)
|
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()
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
chat_2.verify_message_is_under_today_text(message, self.errors)
|
2018-10-06 12:00:30 +00:00
|
|
|
full_username = '%s :: %s' % (username_1, default_username_1)
|
|
|
|
if chat_2.chat_element_by_text(message).username.text != full_username:
|
|
|
|
self.errors.append("Username '%s' is not shown next to the received message" % full_username)
|
2018-06-28 18:46:51 +00:00
|
|
|
|
2018-10-06 12:00:30 +00:00
|
|
|
if chat_1.element_by_text_part(username_1).is_element_displayed():
|
2018-06-28 18:46:51 +00:00
|
|
|
self.errors.append("Username '%s' is shown for the sender" % username_1)
|
|
|
|
|
|
|
|
self.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()
|
|
|
|
|
|
|
|
if home_1.home_button.counter.text != '1':
|
|
|
|
self.errors.append('New messages counter is not shown on Home button')
|
|
|
|
|
|
|
|
chat_element = home_1.get_chat_with_user('#' + chat_name)
|
|
|
|
if chat_element.new_messages_counter.text != '1':
|
|
|
|
self.errors.append('New messages counter is not shown on chat element')
|
|
|
|
|
|
|
|
chat_element.click()
|
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
|
|
|
|
if home_1.home_button.counter.is_element_displayed():
|
|
|
|
self.errors.append('New messages counter is shown on Home button for already seen message')
|
|
|
|
|
|
|
|
if chat_element.new_messages_counter.is_element_displayed():
|
|
|
|
self.errors.append('New messages counter is shown on chat element for already seen message')
|
|
|
|
self.verify_no_errors()
|
|
|
|
|
|
|
|
|
|
|
|
@marks.chat
|
|
|
|
class TestPublicChatSingleDevice(SingleDeviceTestCase):
|
|
|
|
|
|
|
|
@marks.skip
|
2018-09-28 15:30:06 +00:00
|
|
|
@marks.testrail_id(5392)
|
|
|
|
@marks.high
|
2018-07-19 09:57:45 +00:00
|
|
|
def test_send_korean_characters(self):
|
|
|
|
sign_in = SignInView(self.driver)
|
|
|
|
home = sign_in.create_user()
|
|
|
|
chat_name = home.get_public_chat_name()
|
|
|
|
public_chat = home.join_public_chat(chat_name)
|
|
|
|
message = '파란하늘'
|
|
|
|
public_chat.chat_message_input.send_keys(message)
|
|
|
|
if public_chat.chat_message_input.text != message:
|
|
|
|
self.errors.append('Korean characters are not displayed properly in the chat message input')
|
|
|
|
public_chat.send_message_button.click()
|
|
|
|
if not public_chat.chat_element_by_text(message).is_element_displayed():
|
|
|
|
self.errors.append('Message with korean characters is not shown')
|
|
|
|
self.verify_no_errors()
|
2018-11-21 10:44:30 +00:00
|
|
|
|
|
|
|
@marks.testrail_id(5336)
|
2018-11-26 15:41:31 +00:00
|
|
|
@marks.critical
|
2018-11-21 10:44:30 +00:00
|
|
|
def test_user_can_interact_with_public_chat(self):
|
|
|
|
signin = SignInView(self.driver)
|
|
|
|
home_view = signin.create_user()
|
|
|
|
chat = home_view.join_public_chat('evripidis-middellijn')
|
|
|
|
|
2018-11-26 15:41:31 +00:00
|
|
|
try:
|
|
|
|
chat.empty_public_chat_message.wait_for_invisibility_of_element()
|
|
|
|
except TimeoutException:
|
2018-11-21 10:44:30 +00:00
|
|
|
self.driver.fail('Empty chat: history is not fetched!')
|
|
|
|
|
|
|
|
# just to generate random text to be sent
|
|
|
|
text = generate_timestamp()
|
|
|
|
chat.send_message(text)
|
|
|
|
|
|
|
|
if not chat.chat_element_by_text(text).is_element_displayed():
|
|
|
|
self.errors.append('User sent message but it did not appear in chat!')
|
|
|
|
|
|
|
|
chat.move_to_messages_by_time_marker('Today')
|
2018-11-26 15:41:31 +00:00
|
|
|
if not chat.element_by_text('Today').is_element_displayed():
|
|
|
|
self.errors.append("'Today' chat marker is not shown")
|
2018-11-21 10:44:30 +00:00
|
|
|
if len(chat.chat_item.find_elements()) <= 1:
|
2018-11-26 15:41:31 +00:00
|
|
|
self.errors.append('No messages fetched for today!')
|
2018-11-21 10:44:30 +00:00
|
|
|
|
|
|
|
chat.move_to_messages_by_time_marker('Yesterday')
|
2018-11-26 15:41:31 +00:00
|
|
|
if not chat.element_by_text('Yesterday').is_element_displayed():
|
|
|
|
self.errors.append("'Yesterday' chat marker is not shown")
|
2018-11-21 10:44:30 +00:00
|
|
|
if len(chat.chat_item.find_elements()) <= 1:
|
2018-11-26 15:41:31 +00:00
|
|
|
self.errors.append('No messages fetched for yesterday!')
|
2018-11-21 10:44:30 +00:00
|
|
|
|
|
|
|
self.verify_no_errors()
|
|
|
|
|
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()
|
|
|
|
chat.empty_public_chat_message.wait_for_visibility_of_element()
|
|
|
|
|
|
|
|
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.')
|