2018-02-14 13:48:18 +00:00
|
|
|
import random
|
|
|
|
import string
|
|
|
|
import emoji
|
2018-05-16 19:59:36 +00:00
|
|
|
import time
|
2018-02-14 13:48:18 +00:00
|
|
|
from tests.base_test_case import MultipleDeviceTestCase
|
2018-04-26 12:34:15 +00:00
|
|
|
from tests import group_chat_users, get_current_time, marks
|
2018-03-01 13:22:01 +00:00
|
|
|
from views.sign_in_view import SignInView
|
2018-02-14 13:48:18 +00:00
|
|
|
|
|
|
|
unicode_text_message = '%s%s%s%s %s%s%s%s%s%s%s' % (chr(355), chr(275), chr(353), chr(539), chr(1084), chr(949),
|
|
|
|
chr(349), chr(353), chr(513), chr(485), chr(283))
|
|
|
|
unicode_chinese = '%s%s' % (chr(29320), chr(22909))
|
|
|
|
emoji_name = random.choice(list(emoji.EMOJI_UNICODE))
|
|
|
|
emoji_unicode = emoji.EMOJI_UNICODE[emoji_name]
|
|
|
|
emoji_name_1 = random.choice(list(emoji.EMOJI_UNICODE))
|
|
|
|
emoji_unicode_1 = emoji.EMOJI_UNICODE[emoji_name_1]
|
|
|
|
message_with_new_line = 'message' '\n' 'with new line'
|
|
|
|
|
|
|
|
|
2018-04-26 12:34:15 +00:00
|
|
|
@marks.all
|
|
|
|
@marks.chat
|
2018-02-14 13:48:18 +00:00
|
|
|
class TestMessages(MultipleDeviceTestCase):
|
|
|
|
|
2018-04-26 12:34:15 +00:00
|
|
|
@marks.pr
|
|
|
|
@marks.testrail_case_id(3390)
|
2018-04-26 06:22:11 +00:00
|
|
|
def test_one_to_one_chat_messages(self):
|
2018-02-14 13:48:18 +00:00
|
|
|
self.create_drivers(2)
|
2018-03-01 13:22:01 +00:00
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
|
|
|
for sign_in in device_1, device_2:
|
|
|
|
sign_in.create_user()
|
2018-02-14 13:48:18 +00:00
|
|
|
device_1_home, device_2_home = device_1.get_home_view(), device_2.get_home_view()
|
|
|
|
device_2_public_key = device_2_home.get_public_key()
|
|
|
|
device_1_home.add_contact(device_2_public_key)
|
|
|
|
device_1_chat = device_1_home.get_chat_view()
|
|
|
|
|
|
|
|
message = 'hello'
|
|
|
|
device_1_chat.chat_message_input.send_keys(message)
|
|
|
|
device_1_chat.send_message_button.click()
|
|
|
|
device_2_home.home_button.click()
|
|
|
|
device_2_home.element_by_text(message, 'button').click()
|
|
|
|
device_2_chat = device_2_home.get_chat_view()
|
|
|
|
|
|
|
|
device_2_chat.chat_message_input.send_keys('~abc~ !@#$%%^&(() *bold*')
|
|
|
|
device_2_chat.send_message_button.click()
|
|
|
|
device_1_chat.wait_for_message_in_one_to_one_chat('abc !@#$%%^&(() bold', self.errors)
|
|
|
|
|
|
|
|
device_1_chat.chat_message_input.send_keys(unicode_text_message)
|
|
|
|
device_1_chat.send_message_button.click()
|
|
|
|
device_2_chat.wait_for_message_in_one_to_one_chat(unicode_text_message, self.errors)
|
|
|
|
|
|
|
|
device_2_chat.chat_message_input.send_keys(unicode_chinese)
|
|
|
|
device_2_chat.send_message_button.click()
|
|
|
|
device_1_chat.wait_for_message_in_one_to_one_chat(unicode_chinese, self.errors)
|
|
|
|
|
|
|
|
device_1_chat.chat_message_input.send_keys(emoji.emojize(emoji_name))
|
|
|
|
device_1_chat.send_message_button.click()
|
|
|
|
device_2_chat.wait_for_message_in_one_to_one_chat(emoji_unicode, self.errors)
|
|
|
|
|
|
|
|
message_with_emoji = 'message with emoji'
|
|
|
|
device_2_chat.chat_message_input.send_keys(emoji.emojize('%s %s' % (message_with_emoji, emoji_name_1)))
|
|
|
|
device_2_chat.send_message_button.click()
|
|
|
|
device_1_chat.wait_for_message_in_one_to_one_chat('%s %s' % (message_with_emoji, emoji_unicode_1), self.errors)
|
|
|
|
|
2018-03-28 10:21:39 +00:00
|
|
|
device_1_chat.chat_message_input.click()
|
2018-02-14 13:48:18 +00:00
|
|
|
device_1_chat.send_as_keyevent(message_with_new_line)
|
|
|
|
device_1_chat.send_message_button.click()
|
|
|
|
device_2_chat.wait_for_message_in_one_to_one_chat(message_with_new_line, self.errors)
|
|
|
|
|
|
|
|
url_message = 'status.im'
|
|
|
|
device_2_chat.chat_message_input.send_keys(url_message)
|
|
|
|
device_2_chat.send_message_button.click()
|
|
|
|
device_1_chat.wait_for_message_in_one_to_one_chat(url_message, self.errors)
|
|
|
|
if device_1_chat.element_by_text(url_message, 'button').is_element_present():
|
|
|
|
device_1_chat.element_by_text(url_message, 'button').click()
|
2018-07-12 19:41:50 +00:00
|
|
|
web_view = device_1_chat.open_in_status_button.click()
|
2018-03-28 10:21:39 +00:00
|
|
|
web_view.find_full_text('Status, the Ethereum discovery tool.')
|
2018-02-14 13:48:18 +00:00
|
|
|
device_1_chat.back_button.click()
|
|
|
|
|
|
|
|
self.verify_no_errors()
|
|
|
|
|
2018-04-26 12:34:15 +00:00
|
|
|
@marks.pr
|
|
|
|
@marks.testrail_case_id(3391)
|
2018-05-23 13:02:45 +00:00
|
|
|
@marks.skip
|
2018-03-15 16:07:25 +00:00
|
|
|
def test_group_chat_messages_and_delete_chat(self):
|
2018-02-14 13:48:18 +00:00
|
|
|
self.create_drivers(3)
|
2018-02-19 11:51:53 +00:00
|
|
|
|
|
|
|
device_1, device_2, device_3 = \
|
|
|
|
SignInView(self.drivers[0]), SignInView(self.drivers[1]), SignInView(self.drivers[2])
|
|
|
|
|
|
|
|
for data in (device_1, group_chat_users['A_USER']), \
|
|
|
|
(device_2, group_chat_users['B_USER']), \
|
|
|
|
(device_3, group_chat_users['C_USER']):
|
|
|
|
data[0].recover_access(data[1]['passphrase'], data[1]['password'])
|
|
|
|
|
2018-02-19 18:39:54 +00:00
|
|
|
home_1, home_2, home_3 = device_1.get_home_view(), device_2.get_home_view(), device_3.get_home_view()
|
2018-02-19 11:51:53 +00:00
|
|
|
|
|
|
|
public_key_2, public_key_3 = \
|
|
|
|
group_chat_users['B_USER']['public_key'], \
|
|
|
|
group_chat_users['C_USER']['public_key']
|
|
|
|
|
|
|
|
username_1, username_2, username_3 = \
|
|
|
|
group_chat_users['A_USER']['username'], \
|
|
|
|
group_chat_users['B_USER']['username'], \
|
|
|
|
group_chat_users['C_USER']['username']
|
|
|
|
|
2018-02-14 13:48:18 +00:00
|
|
|
for public_key in public_key_2, public_key_3:
|
|
|
|
home_1.add_contact(public_key)
|
2018-02-19 11:51:53 +00:00
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
|
2018-03-15 20:01:08 +00:00
|
|
|
chat_name = 'a_chat_%s' % get_current_time()
|
2018-02-14 13:48:18 +00:00
|
|
|
home_1.create_group_chat(sorted([username_2, username_3]), chat_name)
|
|
|
|
chat_1 = home_1.get_chat_view()
|
|
|
|
text_message = 'This is text message!'
|
|
|
|
chat_1.chat_message_input.send_keys(text_message)
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
for home in home_2, home_3:
|
|
|
|
home.element_by_text(chat_name, 'button').click()
|
|
|
|
|
|
|
|
chat_2, chat_3 = home_2.get_chat_view(), home_3.get_chat_view()
|
|
|
|
for chat in chat_2, chat_3:
|
2018-03-15 20:01:08 +00:00
|
|
|
chat.wait_for_messages(username_1, text_message, self.errors)
|
2018-02-14 13:48:18 +00:00
|
|
|
|
|
|
|
chat_2.chat_message_input.send_keys(emoji.emojize(emoji_name))
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
for chat in chat_1, chat_3:
|
2018-03-15 20:01:08 +00:00
|
|
|
chat.wait_for_messages(username_2, emoji_unicode, self.errors)
|
2018-02-14 13:48:18 +00:00
|
|
|
|
|
|
|
message_with_emoji = 'message with emoji'
|
|
|
|
chat_3.chat_message_input.send_keys(emoji.emojize('%s %s' % (message_with_emoji, emoji_name_1)))
|
|
|
|
chat_3.send_message_button.click()
|
|
|
|
for chat in chat_1, chat_2:
|
2018-03-15 20:01:08 +00:00
|
|
|
chat.wait_for_messages(username_3, '%s %s' % (message_with_emoji, emoji_unicode_1), self.errors)
|
2018-02-14 13:48:18 +00:00
|
|
|
|
|
|
|
chat_1.chat_message_input.send_keys(unicode_text_message)
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
|
|
|
|
for chat in chat_2, chat_3:
|
2018-03-15 20:01:08 +00:00
|
|
|
chat.wait_for_messages(username_1, unicode_text_message, self.errors)
|
2018-02-14 13:48:18 +00:00
|
|
|
|
2018-03-15 20:01:08 +00:00
|
|
|
# for chat in chat_1, chat_2, chat_3:
|
|
|
|
# chat.delete_chat(chat_name, self.errors)
|
2018-03-15 16:07:25 +00:00
|
|
|
|
2018-02-14 13:48:18 +00:00
|
|
|
self.verify_no_errors()
|
|
|
|
|
2018-04-26 12:34:15 +00:00
|
|
|
@marks.pr
|
|
|
|
@marks.testrail_case_id(3392)
|
2018-02-14 13:48:18 +00:00
|
|
|
def test_public_chat(self):
|
|
|
|
self.create_drivers(2)
|
2018-03-01 13:22:01 +00:00
|
|
|
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
2018-06-28 18:46:51 +00:00
|
|
|
users = ['user_1', 'user_2']
|
|
|
|
home_1, home_2 = device_1.create_user(username=users[0]), device_2.create_user(username=users[1])
|
2018-06-29 17:27:30 +00:00
|
|
|
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(chat_name), home_2.join_public_chat(chat_name)
|
2018-02-14 13:48:18 +00:00
|
|
|
|
2018-05-16 19:59:36 +00:00
|
|
|
chat_1.chat_message_input.send_keys('/command')
|
|
|
|
chat_1.send_message_button.click()
|
2018-02-14 13:48:18 +00:00
|
|
|
|
|
|
|
message_with_emoji = 'message with emoji'
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
chat_2.chat_message_input.send_keys(emoji.emojize(emoji_name))
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
|
|
|
|
chat_1.chat_message_input.send_keys('%s %s' % (unicode_text_message, unicode_chinese))
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
|
|
|
|
chat_2.chat_message_input.send_keys('%s %s' % (message_with_emoji, emoji_unicode_1))
|
|
|
|
chat_2.send_message_button.click()
|
|
|
|
|
|
|
|
chat_1.chat_message_input.send_keys('This is text message.')
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
|
2018-03-28 10:21:39 +00:00
|
|
|
chat_2.chat_message_input.click()
|
2018-02-14 13:48:18 +00:00
|
|
|
chat_2.send_as_keyevent(message_with_new_line)
|
|
|
|
chat_2.send_message_button.click()
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
messages_from_user_2 = [emoji_unicode, '%s %s' % (message_with_emoji, emoji_unicode_1), message_with_new_line]
|
|
|
|
chat_1.wait_for_messages(users[1], messages_from_user_2, self.errors)
|
|
|
|
|
|
|
|
messages_from_user_1 = ['/command', '%s %s' % (unicode_text_message, unicode_chinese), 'This is text message.']
|
|
|
|
chat_2.wait_for_messages(users[0], messages_from_user_1, self.errors)
|
|
|
|
|
2018-03-15 16:07:25 +00:00
|
|
|
for chat in chat_1, chat_2:
|
|
|
|
chat.delete_chat(chat_name, self.errors)
|
2018-02-14 13:48:18 +00:00
|
|
|
self.verify_no_errors()
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
@marks.testrail_case_id(3423)
|
|
|
|
def test_username_and_profile_picture_in_chats(self):
|
|
|
|
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-05-16 19:59:36 +00:00
|
|
|
device_2_public_key = home_2.get_public_key()
|
|
|
|
profile_2 = home_2.get_profile_view()
|
|
|
|
file_name = 'sauce_logo.png'
|
|
|
|
profile_2.edit_profile_picture(file_name)
|
|
|
|
home_1.add_contact(device_2_public_key)
|
2018-05-18 09:52:25 +00:00
|
|
|
chat_1 = home_1.get_chat_view()
|
|
|
|
chat_1.chat_message_input.send_keys('ping')
|
|
|
|
chat_1.send_message_button.click()
|
2018-05-16 19:59:36 +00:00
|
|
|
profile_2.home_button.click()
|
|
|
|
chat_2 = home_2.get_chat_with_user(username_1).click()
|
|
|
|
chat_2.add_to_contacts.click()
|
|
|
|
time.sleep(3)
|
|
|
|
if chat_1.user_name_text.text != username_2:
|
|
|
|
self.errors.append("Real username '%s' is not shown in one-to-one chat" % username_2)
|
|
|
|
chat_1.chat_options.click()
|
|
|
|
chat_1.view_profile_button.click()
|
|
|
|
if not chat_1.contact_profile_picture.is_element_image_equals_template(file_name):
|
|
|
|
self.errors.append("Updated profile picture is not shown in one-to-one chat")
|
|
|
|
|
2018-05-23 13:02:45 +00:00
|
|
|
# home_1.get_back_to_home_view()
|
|
|
|
# chat_name = 'a_chat_%s' % get_current_time()
|
|
|
|
# home_1.create_group_chat([username_2], chat_name)
|
|
|
|
# group_chat_1 = home_1.get_chat_view()
|
|
|
|
#
|
|
|
|
# home_2.get_back_to_home_view()
|
|
|
|
# group_chat_2 = home_2.get_chat_with_user(chat_name).click()
|
|
|
|
# message_text = 'test message'
|
|
|
|
# group_chat_2.chat_message_input.send_keys(message_text)
|
|
|
|
# group_chat_2.send_message_button.click()
|
|
|
|
#
|
|
|
|
# group_chat_1.wait_for_messages(username_2, message_text, self.errors)
|
|
|
|
# group_chat_1.verify_username_is_shown_per_message(username_2, message_text, self.errors)
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
self.verify_no_errors()
|
|
|
|
|
|
|
|
@marks.testrail_case_id(3429)
|
|
|
|
def test_copy_and_paste_messages(self):
|
|
|
|
self.create_drivers(1)
|
|
|
|
sign_in = SignInView(self.drivers[0])
|
|
|
|
sign_in.create_user()
|
|
|
|
home = sign_in.get_home_view()
|
2018-06-29 17:27:30 +00:00
|
|
|
home.join_public_chat(home.get_public_chat_name())
|
2018-05-16 19:59:36 +00:00
|
|
|
chat = sign_in.get_chat_view()
|
|
|
|
message_text = 'test'
|
|
|
|
message_input = chat.chat_message_input
|
|
|
|
message_input.send_keys(message_text)
|
|
|
|
chat.send_message_button.click()
|
|
|
|
|
|
|
|
# copy text message
|
|
|
|
chat.chat_element_by_text(message_text).long_press_element()
|
|
|
|
chat.element_by_text('Copy to clipboard').click()
|
|
|
|
|
|
|
|
# paste text into the input field
|
|
|
|
message_input.paste_text_from_clipboard()
|
|
|
|
assert message_input.text == message_text
|
|
|
|
|
|
|
|
# delete part of the message
|
|
|
|
message_input.delete_last_symbols(2)
|
|
|
|
assert message_input.text == message_text[:-2]
|
|
|
|
|
|
|
|
# cut message text
|
|
|
|
message_input.cut_text()
|
|
|
|
|
|
|
|
# paste selected text
|
|
|
|
message_input.paste_text_from_clipboard()
|
|
|
|
chat.send_message_button.click()
|
|
|
|
|
|
|
|
# verify correct text is sent
|
2018-06-28 18:46:51 +00:00
|
|
|
chat.chat_element_by_text(message_text[:-2] + ' ').wait_for_visibility_of_element(2)
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
@marks.all
|
|
|
|
@marks.chat
|
|
|
|
class TestOfflineMessages(MultipleDeviceTestCase):
|
|
|
|
|
|
|
|
@marks.testrail_case_id(3420)
|
|
|
|
def test_offline_messaging_1_1_chat(self):
|
2018-03-31 20:05:11 +00:00
|
|
|
self.create_drivers(2, offline_mode=True)
|
2018-05-16 19:59:36 +00:00
|
|
|
device_1, device_2 = self.drivers[0], self.drivers[1]
|
|
|
|
sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2)
|
|
|
|
username_1 = sign_in_1.create_user()
|
|
|
|
sign_in_2.create_user()
|
|
|
|
home_1, home_2 = sign_in_1.get_home_view(), sign_in_2.get_home_view()
|
|
|
|
device_2_public_key = home_2.get_public_key()
|
|
|
|
home_1.add_contact(device_2_public_key)
|
|
|
|
chat_1 = home_1.get_chat_view()
|
2018-05-18 09:52:25 +00:00
|
|
|
chat_1.chat_message_input.send_keys('ping')
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
home_2.home_button.click()
|
|
|
|
home_2.get_chat_with_user(username_1).is_element_present(20)
|
|
|
|
profile_2 = home_2.profile_button.click()
|
2018-05-16 19:59:36 +00:00
|
|
|
profile_2.logout()
|
|
|
|
device_2.set_network_connection(1) # airplane mode
|
|
|
|
message_text = 'test message'
|
|
|
|
chat_1.chat_message_input.send_keys(message_text)
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
sign_in_2.click_account_by_position(0)
|
2018-06-01 16:37:44 +00:00
|
|
|
sign_in_2.sign_in()
|
2018-05-16 19:59:36 +00:00
|
|
|
sign_in_2.home_button.wait_for_visibility_of_element()
|
2018-06-21 16:40:27 +00:00
|
|
|
if home_2.connection_status.text != 'Offline':
|
2018-05-16 19:59:36 +00:00
|
|
|
self.errors.append('Offline label is not shown on Home view while being offline')
|
|
|
|
chat_2 = home_2.get_chat_with_user(username_1).click()
|
2018-06-21 16:40:27 +00:00
|
|
|
if chat_2.connection_status.text != 'Offline':
|
2018-05-16 19:59:36 +00:00
|
|
|
self.errors.append('Offline label is not shown on Chat view while being offline')
|
|
|
|
device_2.set_network_connection(2) # turning on WiFi connection
|
|
|
|
chat_2.wait_for_message_in_one_to_one_chat(message_text, self.errors, wait_time=120)
|
|
|
|
self.verify_no_errors()
|
|
|
|
|
|
|
|
@marks.testrail_case_id(3430)
|
2018-05-23 13:02:45 +00:00
|
|
|
@marks.skip
|
2018-05-16 19:59:36 +00:00
|
|
|
def test_offline_messaging_group_chat(self):
|
2018-03-31 20:05:11 +00:00
|
|
|
self.create_drivers(2, offline_mode=True)
|
2018-05-16 19:59:36 +00:00
|
|
|
device_1, device_2 = self.drivers[0], self.drivers[1]
|
|
|
|
sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2)
|
2018-06-28 18:46:51 +00:00
|
|
|
username_1, username_2 = 'user_1', 'user_2'
|
|
|
|
home_1, home_2 = sign_in_1.create_user(), sign_in_2.create_user()
|
2018-05-16 19:59:36 +00:00
|
|
|
|
|
|
|
device_2_public_key = home_2.get_public_key()
|
|
|
|
home_1.add_contact(device_2_public_key)
|
|
|
|
home_1.get_back_to_home_view()
|
|
|
|
|
|
|
|
home_2.home_button.click()
|
|
|
|
chat_view_2 = home_2.get_chat_with_user(username_1).click()
|
|
|
|
chat_view_2.add_to_contacts.click()
|
|
|
|
chat_view_2.get_back_to_home_view()
|
|
|
|
|
|
|
|
chat_name = 'a_chat_%s' % get_current_time()
|
|
|
|
home_1.create_group_chat([username_2], chat_name)
|
|
|
|
chat_1 = home_1.get_chat_view()
|
|
|
|
|
|
|
|
chat_element_2 = home_2.get_chat_with_user(chat_name)
|
|
|
|
chat_element_2.wait_for_visibility_of_element()
|
|
|
|
device_2.set_network_connection(1) # airplane mode
|
|
|
|
|
2018-06-21 16:40:27 +00:00
|
|
|
if home_2.connection_status.text != 'Offline':
|
2018-05-16 19:59:36 +00:00
|
|
|
self.errors.append('Offline label is not shown on Home view while being offline')
|
|
|
|
chat_2 = chat_element_2.click()
|
2018-06-21 16:40:27 +00:00
|
|
|
if chat_2.connection_status.text != 'Offline':
|
2018-05-16 19:59:36 +00:00
|
|
|
self.errors.append('Offline label is not shown on Chat view while being offline')
|
|
|
|
|
|
|
|
message_text = 'test message'
|
|
|
|
chat_1.chat_message_input.send_keys(message_text)
|
|
|
|
chat_1.send_message_button.click()
|
|
|
|
|
|
|
|
chat_1.get_back_to_home_view()
|
|
|
|
profile_1 = home_1.profile_button.click()
|
|
|
|
profile_1.logout()
|
|
|
|
|
|
|
|
device_2.set_network_connection(2) # turning on WiFi connection
|
|
|
|
chat_2.wait_for_messages(username_1, message_text, self.errors, wait_time=120)
|
|
|
|
self.verify_no_errors()
|