2017-08-31 13:39:41 +00:00
|
|
|
import pytest
|
|
|
|
from tests.basetestcase import MultiplyDeviceTestCase
|
|
|
|
from tests.preconditions import set_password_as_new_user
|
|
|
|
from views.home import HomeView
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sanity
|
2017-09-11 10:43:42 +00:00
|
|
|
class TestGroupChats(MultiplyDeviceTestCase):
|
2017-08-31 13:39:41 +00:00
|
|
|
|
2017-09-13 14:34:42 +00:00
|
|
|
def test_group_chat_send_receive_messages_and_remove_user(self):
|
|
|
|
|
2017-08-31 13:39:41 +00:00
|
|
|
device_1, device_2 = HomeView(self.driver_1), \
|
|
|
|
HomeView(self.driver_2)
|
|
|
|
set_password_as_new_user(device_2, device_1)
|
2017-09-13 14:34:42 +00:00
|
|
|
|
2017-08-31 13:39:41 +00:00
|
|
|
device_1.back_button.click()
|
|
|
|
chats_d1 = device_1.get_chats()
|
|
|
|
chats_d1.profile_button.click()
|
|
|
|
profile_d1 = chats_d1.profile_icon.click()
|
|
|
|
key = profile_d1.public_key_text.text
|
|
|
|
|
|
|
|
device_2.back_button.click()
|
|
|
|
chats_d2 = device_2.get_chats()
|
|
|
|
chats_d2.plus_button.click()
|
|
|
|
chats_d2.add_new_contact.click()
|
|
|
|
chats_d2.public_key_edit_box.send_keys(key)
|
|
|
|
chats_d2.confirm()
|
|
|
|
chats_d2.confirm_public_key_button.click()
|
2017-09-13 14:34:42 +00:00
|
|
|
user_name_d1 = chats_d2.user_name_text.text
|
2017-08-31 13:39:41 +00:00
|
|
|
|
|
|
|
device_2.back_button.click()
|
|
|
|
chats_d2.new_group_chat_button.click()
|
|
|
|
|
2017-09-13 14:34:42 +00:00
|
|
|
user_contact = chats_d2.element_by_text(user_name_d1, 'button')
|
2017-08-31 13:39:41 +00:00
|
|
|
user_contact.scroll_to_element()
|
|
|
|
user_contact.click()
|
|
|
|
chats_d2.next_button.click()
|
2017-09-11 10:43:42 +00:00
|
|
|
|
|
|
|
chat_name = 'new_chat'
|
2017-09-13 14:34:42 +00:00
|
|
|
message_1 = 'first SOMETHING'
|
|
|
|
message_2 = 'second SOMETHING'
|
|
|
|
message_3 = 'third SOMETHING'
|
2017-09-11 10:43:42 +00:00
|
|
|
|
|
|
|
chats_d2.name_edit_box.send_keys(chat_name)
|
2017-08-31 13:39:41 +00:00
|
|
|
chats_d2.save_button.click()
|
2017-09-13 14:34:42 +00:00
|
|
|
|
|
|
|
# send_and_receive_messages
|
|
|
|
|
2017-09-11 10:43:42 +00:00
|
|
|
chats_d2.chat_message_input.send_keys(message_1)
|
|
|
|
chats_d2.send_message_button.click()
|
|
|
|
|
2017-09-13 14:34:42 +00:00
|
|
|
profile_d1.back_button.click()
|
|
|
|
chats_d1 = profile_d1.get_chats()
|
|
|
|
chats_d1.find_full_text(message_1)
|
|
|
|
group_chat_d1 = chats_d1.element_by_text(chat_name, 'button')
|
|
|
|
group_chat_d1.click()
|
2017-08-31 13:39:41 +00:00
|
|
|
|
2017-09-11 10:43:42 +00:00
|
|
|
chats_d2.chat_message_input.send_keys(message_2)
|
2017-08-31 13:39:41 +00:00
|
|
|
chats_d2.send_message_button.click()
|
|
|
|
|
2017-09-13 14:34:42 +00:00
|
|
|
chats_d1.find_full_text(message_2)
|
|
|
|
|
|
|
|
# remove_user
|
|
|
|
|
|
|
|
chats_d2.group_chat_options.click()
|
|
|
|
chats_d2.chat_settings.click()
|
|
|
|
chats_d2.confirm()
|
|
|
|
chats_d2.user_options.click()
|
|
|
|
chats_d2.remove_button.click()
|
|
|
|
device_2.back_button.click()
|
|
|
|
|
|
|
|
# chats_d2.find_full_text("You\'ve removed " + user_name_d1)
|
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
chats_d2.chat_message_input.send_keys(message_3)
|
2017-09-13 14:34:42 +00:00
|
|
|
chats_d2.send_message_button.click()
|
|
|
|
|
|
|
|
chats_d1.find_text_part("removed you from group chat")
|
|
|
|
message_text = chats_d1.element_by_text(message_3, 'text')
|
|
|
|
if message_text.is_element_present(20):
|
|
|
|
pytest.fail('Message is shown for the user which has been removed from the GroupChat', False)
|