Decline group invites

Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
Churikova Tetiana 2019-03-18 14:48:55 +01:00 committed by Serhy
parent 7f76e2fbf0
commit f8dfc82dd4
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
2 changed files with 77 additions and 33 deletions

View File

@ -3,6 +3,14 @@ from tests.base_test_case import MultipleDeviceTestCase
from tests.users import chat_users
from views.sign_in_view import SignInView
def return_left_chat_system_message(default_username):
return "*%s* left the group" % default_username
def return_created_chat_system_message(username, chat_name):
return "*%s* created the group *%s*" % (username, chat_name)
def return_joined_chat_system_message(default_username):
return "*%s* has joined the group" % default_username
def create_users(driver_1, driver_2, username_1=None, username_2=None):
device_1_sign_in, device_2_sign_in = SignInView(driver_1), SignInView(driver_2)
@ -10,13 +18,16 @@ def create_users(driver_1, driver_2, username_1=None, username_2=None):
return device_1_sign_in.create_user(username_1), device_2_sign_in.create_user(username_1)
return device_1_sign_in.create_user(), device_2_sign_in.create_user()
def get_default_username(device_home):
device_profile_view = device_home.profile_button.click()
device_default_username = device_profile_view.default_username_text.text
device_home.home_button.click()
return device_default_username
def create_and_join_group_chat(device_1_home, device_2_home, chat_name):
def create_new_group_chat(device_1_home, device_2_home, chat_name):
# device 2: get public key and default username
device_2_public_key = device_2_home.get_public_key()
device_2_profile_view = device_2_home.profile_button.click()
device_2_default_username = device_2_profile_view.default_username_text.text
device_2_home.home_button.click()
device_2_default_username = get_default_username(device_2_home)
# device 1: add device 2 as contact
device_1_chat = device_1_home.add_contact(device_2_public_key)
@ -27,10 +38,15 @@ def create_and_join_group_chat(device_1_home, device_2_home, chat_name):
# device 2: open group chat
device_2_chat = device_2_home.get_chat_with_user(chat_name).click()
device_2_chat.join_chat_button.click()
return device_1_chat, device_2_chat
def create_and_join_group_chat(device_1_home, device_2_home, chat_name):
device_1_chat, device_2_chat = create_new_group_chat(device_1_home, device_2_home, chat_name)
device_2_chat.join_chat_button.click()
return device_1_chat, device_2_chat
@marks.chat
class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
@ -53,22 +69,21 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
@marks.testrail_id(3993)
@marks.critical
def test_send_message_in_group_chat(self):
message_from_device_1 = 'Hello from device 1'
message_from_device_2 = 'Hi there! Sent from device 2'
self.create_drivers(2)
device_1_home, device_2_home = create_users(self.drivers[0], self.drivers[1])
chat_name = device_1_home.get_public_chat_name()
device_1_chat, device_2_chat = create_and_join_group_chat(device_1_home, device_2_home, chat_name)
for chat in (device_1_chat, device_2_chat):
chat.send_message("Message from device: %s" % chat.driver.number)
device_1_chat.send_message(message_from_device_1)
device_2_chat.send_message(message_from_device_2)
for chat in (device_1_chat, device_2_chat):
for chat_driver in (device_1_chat, device_2_chat):
if not chat.chat_element_by_text(
"Message from device: %s" % chat_driver.driver.number).is_element_displayed():
self.errors.append("Message from device '%s' was not received" % chat_driver.driver.number)
if not device_2_chat.chat_element_by_text(message_from_device_1).is_element_displayed():
self.errors.append("Message with test '%s' was not received" % message_from_device_1)
if not device_1_chat.chat_element_by_text(message_from_device_2).is_element_displayed():
self.errors.append("Message with test '%s' was not received" % message_from_device_2)
self.verify_no_errors()
@marks.testrail_id(5674)
@ -81,28 +96,24 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
device_1_home, device_2_home = create_users(self.drivers[0], self.drivers[1], username_1, username_2)
chat_name = device_1_home.get_public_chat_name()
device_2_profile = device_2_home.profile_button.click()
device_2_default_username = device_2_profile.default_username_text.text
device_2_default_username = get_default_username(device_2_home)
device_1_chat, device_2_chat = create_and_join_group_chat(device_1_home, device_2_home, chat_name)
admin_created_chat_system_message = "*%s* created the group *%s*" % (username_1, chat_name)
user2_joined_chat_system_message = "*%s* has joined the group" % device_2_default_username
user2_left_chat_system_message = "*%s* left the group" % device_2_default_username
# device 2: delete group chat
device_2_chat = device_2_home.get_chat_with_user(chat_name).click()
device_2_chat.delete_chat()
# device 1: check system messages in the group chat
if not device_1_chat.element_by_text(admin_created_chat_system_message).is_element_displayed():
self.errors.append("System message: '%s' in group chat is not shown" % admin_created_chat_system_message)
if not device_1_chat.element_by_text(user2_joined_chat_system_message).is_element_displayed():
self.errors.append(
"System message: '%s' in group chat is not shown" % user2_joined_chat_system_message)
if not device_1_chat.element_by_text(user2_left_chat_system_message).is_element_displayed():
self.errors.append(
"System message: '%s' in group chat is not shown" % user2_left_chat_system_message)
system_messages = [
return_created_chat_system_message(username_1, chat_name),
return_joined_chat_system_message(device_2_default_username),
return_left_chat_system_message(device_2_default_username)
]
for message in system_messages:
if not device_1_chat.chat_element_by_text(message).is_element_displayed():
self.errors.append("Message with test '%s' was not received" % message)
self.verify_no_errors()
@marks.testrail_id(3997)
@ -125,7 +136,8 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
# device_1: check if chat is was deleted
if device_1_home.element_by_text(chat_name).is_element_displayed():
self.errors.append("Public chat '%s' is shown, but the chat has been deleted" % chat_name)
self.errors.append("Group chat '%s' is shown, but the chat has been deleted" % chat_name)
self.verify_no_errors()
@marks.testrail_id(3998)
@ -144,9 +156,7 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
# device 2: get public key and default username
device_2_public_key = device_2_home.get_public_key()
device_2_profile_view = device_2_home.profile_button.click()
device_2_default_username = device_2_profile_view.default_username_text.text
device_2_home.home_button.click()
device_2_default_username = get_default_username(device_2_home)
# device 1: add contacts
device_1_home.add_contact(chat_member['public_key'])
@ -168,5 +178,33 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase):
device_2_chat.join_chat_button.click()
if device_2_chat.chat_element_by_text(message_for_device_2).is_element_displayed():
self.errors.append('Message that was sent after device 2 has joined is visible')
self.verify_no_errors()
@marks.testrail_id(5756)
@marks.high
def test_decline_invitation_to_group_chat(self):
self.create_drivers(2)
message_for_device_2 = 'This message should not be visible for device 2'
device_1_home, device_2_home = create_users(self.drivers[0], self.drivers[1])
chat_name = device_1_home.get_public_chat_name()
device_1_chat, device_2_chat = create_new_group_chat(device_1_home, device_2_home, chat_name)
device_2_chat.decline_invitation_button.click()
# device 2: check that chat is deleted
if device_2_home.element_by_text(chat_name).is_element_displayed():
self.errors.append("Group chat '%s' is shown, but the chat has been deleted" % chat_name)
# device 1: check system message about leaving a group chat
device_2_default_username = get_default_username(device_2_home)
user2_left_chat_system_message = return_left_chat_system_message(device_2_default_username)
if not device_1_chat.chat_element_by_text(user2_left_chat_system_message).is_element_displayed():
self.errors.append("Message with text '%s' was not received" % user2_left_chat_system_message)
# device 1: send some message to group chat
device_1_chat.send_message(message_for_device_2)
# device 2: check that chat doesn't reappear
if device_2_home.element_by_text(chat_name).is_element_displayed():
self.errors.append("Group chat '%s' is shown, but the chat has been deleted" % chat_name)
self.verify_no_errors()

View File

@ -205,6 +205,11 @@ class JoinChatButton(BaseButton):
super(JoinChatButton, self).__init__(driver)
self.locator = self.Locator.text_part_selector('JOIN GROUP')
class DeclineChatButton(BaseButton):
def __init__(self, driver):
super(DeclineChatButton, self).__init__(driver)
self.locator = self.Locator.text_part_selector('Decline invitation')
class ChatElementByText(BaseText):
def __init__(self, driver, text):
@ -319,6 +324,7 @@ class ChatView(BaseView):
self.leave_chat_button = LeaveChatButton(self.driver)
self.leave_button = LeaveButton(self.driver)
self.join_chat_button = JoinChatButton(self.driver)
self.decline_invitation_button = DeclineChatButton(self.driver)
self.chat_settings = ChatSettings(self.driver)
self.view_profile_button = ViewProfileButton(self.driver)