e2e: outgoing CR + new UI

This commit is contained in:
Churikova Tetiana 2023-03-01 12:33:58 +01:00
parent 4a6e42c6f9
commit 06192e7a24
No known key found for this signature in database
GPG Key ID: EDE559EC439D18A0
6 changed files with 95 additions and 203 deletions

View File

@ -184,9 +184,10 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
for i in range(3):
self.public_keys[i], self.usernames[i] = users[i]
self.homes[0].chats_tab.click()
for i in range(1, 3):
self.homes[0].browser_tab.click()
self.profiles[0].add_contact_via_contacts_list(self.public_keys[i])
self.homes[0].add_contact(self.public_keys[i])
for i in range(3):
self.homes[i].chats_tab.click()
@ -205,11 +206,10 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
self.homes[0].just_fyi('Admin creates group chat')
self.chat_name = self.homes[0].get_random_chat_name()
# workaround for issue with checkboxes in bottom sheet
self.homes[0].communities_tab.click()
# self.homes[0].chats_tab.click()
self.homes[0].chats_tab.click()
self.chats[0] = self.homes[0].create_group_chat(user_names_to_add=[self.usernames[1], self.usernames[2]],
group_chat_name=self.chat_name)
group_chat_name=self.chat_name,
new_ui=True)
for i in range(1, 3):
self.chats[i] = ChatView(self.drivers[i])
@ -234,10 +234,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
self.homes[0].get_chat(self.chat_name).click()
self.chats[1].just_fyi('Check message status and message delivery')
# Not available yet
# message_status = self.chats[1].chat_element_by_text(message_to_admin).status
# if message_status != 'delivered':
# self.errors.append('Message status is not delivered, it is %s!' % message_status)
self.chats[1].chat_element_by_text(message_to_admin).wait_for_status_to_be('Delivered', timeout=120)
if not self.chats[0].chat_element_by_text(message_to_admin).is_element_displayed(30):
self.errors.append('Message %s was not received by admin' % message_to_admin)
self.errors.verify_no_errors()

View File

@ -361,9 +361,8 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.public_key_1, self.default_username_1 = self.home_1.get_public_key_and_username(return_username=True)
self.public_key_2, self.default_username_2 = self.home_2.get_public_key_and_username(return_username=True)
self.profile_1 = self.home_1.get_profile_view()
self.profile_1.add_contact_via_contacts_list(self.public_key_2)
self.profile_1.communities_tab.click()
self.home_2.chats_tab.click()
[home.chats_tab.click() for home in (self.home_1, self.home_2)]
self.home_1.add_contact(self.public_key_2)
self.home_2.handle_contact_request(self.default_username_1)
self.text_message = 'hello'

View File

@ -4,7 +4,7 @@ from tests import marks, run_in_parallel
from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
from views.sign_in_view import SignInView
from views.chat_view import CommunityView
from selenium.common.exceptions import TimeoutException
@pytest.mark.xdist_group(name="four_2")
@marks.medium
@ -22,115 +22,6 @@ class TestActivityCenterMultipleDeviceMedium(MultipleSharedDeviceTestCase):
self.home_2.home_button.double_click()
self.device_2_one_to_one_chat = self.home_2.add_contact(self.public_key_user_1)
@marks.testrail_id(702183)
def test_activity_center_reject_chats_no_pn(self):
self.device_2.just_fyi('Device2 sends a message in 1-1 chat to Device1')
self.device_2_one_to_one_chat.send_message(self.message_from_sender)
self.device_1.just_fyi("Device 2: check there is no PN when receiving new message to activity centre")
self.device_1.put_app_to_background()
self.device_1.open_notification_bar()
if self.home_1.element_by_text(self.message_from_sender).is_element_displayed():
self.errors.append("Push notification with text was received for new message in activity centre")
self.device_1.click_system_back_button(2)
[home.home_button.double_click() for home in [self.home_1, self.home_2]]
self.device_1.just_fyi('Device1 rejects chat and verifies it disappeared and not in Chats too')
self.home_1.notifications_unread_badge.wait_and_click(20)
self.home_1.notifications_select_button.click()
self.home_1.element_by_text_part(self.username_2[:10]).click()
self.home_1.element_by_text_part("Please add me to your contacts").click()
self.home_1.notifications_reject_and_delete_button.click()
if self.home_1.element_by_text_part(self.username_2[:20]).is_element_displayed(2):
self.errors.append("1-1 chat is on Activity Center view after action made on it")
if self.home_1.element_by_text_part(self.username_2[:20]).is_element_displayed(2):
self.errors.append("1-1 chat is added on home after rejection")
self.home_1.just_fyi("Verify there is still no chat after relogin")
self.home_1.reopen_app()
if self.home_1.element_by_text_part(self.username_2[:20]).is_element_displayed(2):
self.errors.append("1-1 chat appears on Chats view after relogin")
self.home_1.notifications_button.click()
if self.home_1.element_by_text_part(self.username_2[:20]).is_element_displayed(2):
self.errors.append("1-1 chat request reappears back in Activity Center view after relogin")
self.errors.verify_no_errors()
@marks.testrail_id(702184)
def test_activity_center_accept_chats(self):
[home.home_button.double_click() for home in [self.home_1, self.home_2]]
self.device_2.just_fyi('Device2 sends a message in 1-1')
self.home_2.get_chat_from_home_view(self.username_1).click()
self.device_2_one_to_one_chat.send_message(self.message_from_sender)
self.device_2_one_to_one_chat.home_button.double_click()
self.device_1.just_fyi('Device1 accepts chat (via Select All button) and verifies it disappeared '
'from activity center view but present on Chats view')
self.home_1.notifications_unread_badge.wait_and_click(20)
self.home_1.notifications_select_button.click()
self.home_1.notifications_select_all.click()
self.home_1.notifications_accept_and_add_button.click()
if self.home_1.element_by_text_part(self.username_2[:20]).is_element_displayed(2):
self.errors.append("1-1 chat request stays on Activity Center view after it was accepted")
self.home_1.home_button.double_click()
if not self.home_1.element_by_text_part(self.username_2[:20]).is_element_displayed(2):
self.errors.append("1-1 chat is not added on home after accepted from Activity Center")
self.errors.verify_no_errors()
@marks.testrail_id(702187)
def test_activity_center_accept_chats_only_from_contacts(self):
[home.home_button.double_click() for home in [self.home_1, self.home_2]]
if self.home_1.get_chat_from_home_view(self.username_2).is_element_displayed():
self.home_1.delete_chat_long_press(self.username_2)
self.device_1.just_fyi('Device1 sets permissions to accept chat requests only from trusted contacts')
profile_1 = self.home_1.profile_button.click()
profile_1.privacy_and_security_button.click()
profile_1.accept_new_chats_from.click()
profile_1.accept_new_chats_from_contacts_only.click()
profile_1.profile_button.click()
self.device_1.just_fyi('Device2 creates 1-1 chat')
self.home_2.home_button.double_click()
self.home_2.get_chat(self.username_1).click()
self.device_2_one_to_one_chat.send_message(self.message_from_sender)
self.device_2_one_to_one_chat.home_button.double_click()
self.device_1.just_fyi('Device1 check there are no any chats in Activity Center nor Chats view')
self.home_1.home_button.double_click()
if self.home_1.element_by_text_part(self.username_2).is_element_displayed():
self.errors.append("Chats are present on Chats view despite they created by non-contact")
self.home_1.notifications_button.click()
if self.home_1.element_by_text_part(self.username_2).is_element_displayed():
self.errors.append("Chat is present in Activity Center view despite they created by non-contact")
self.device_1.just_fyi('Device1 adds Device2 in Contacts so chat requests should be visible now')
self.home_1.home_button.double_click()
self.home_1.add_contact(self.public_key_user_2)
self.device_1.just_fyi('Device2 creates 1-1 chat Group chats once again')
self.home_2.home_button.double_click()
self.home_2.get_chat_from_home_view(self.username_1).click()
self.device_2_one_to_one_chat.send_message(self.message_from_sender)
self.device_2_one_to_one_chat.home_button.double_click()
self.home_2.create_group_chat([self.username_1], group_chat_name=self.group_chat_name_2)
self.device_1.just_fyi('Device1 verifies 1-1 chat Group chats are visible')
self.home_1.home_button.double_click()
if not self.home_1.element_by_text_part(
self.username_2).is_element_displayed() or not self.home_1.element_by_text_part(
self.group_chat_name_2).is_element_displayed():
self.errors.append("Chats are not present on Chats view while they have to!")
self.errors.verify_no_errors()
@marks.testrail_id(702185)
def test_activity_center_notifications_on_mentions_in_groups_and_empty_state(self):
[home.home_button.double_click() for home in [self.home_1, self.home_2]]
@ -202,14 +93,12 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase):
self.profile_1.just_fyi("Enabling PNs")
self.profile_1.switch_push_notifications()
@marks.testrail_id(702850)
@marks.xfail(reason="blocked with 15180")
def test_activity_center_decline_contact_request_no_pn(self):
@marks.testrail_id(702871)
def test_activity_center_cancel_outgoing_contact_request_no_pn(self):
[home.chats_tab.click() for home in [self.home_1, self.home_2]]
self.device_1.put_app_to_background()
self.device_2.just_fyi('Device2 sends a contact request to Device1')
self.profile_2.click_system_back_button_until_element_is_shown(self.profile_2.contacts_button)
self.profile_2.add_contact_via_contacts_list(self.public_key_1)
self.profile_2.click_system_back_button_until_element_is_shown(self.profile_2.contacts_button)
self.home_2.add_contact(self.public_key_1)
self.device_1.just_fyi("Device 2: check there is no PN when receiving new message to activity centre")
self.device_1.open_notification_bar()
@ -217,18 +106,46 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase):
self.errors.append("Push notification with text was received for new message in activity centre")
self.device_1.click_system_back_button(2)
[home.chats_tab.double_click() for home in [self.home_1, self.home_2]]
self.profile_2.just_fyi("Check outgoing contact request and cancel it")
for indicator in (self.home_2.notifications_unread_badge, self.home_2.contact_new_badge):
if not indicator.is_element_displayed():
self.errors.append("Unread indicator on contacts tab or on activity center is not shown for outgoing CR!")
self.home_2.contacts_tab.click()
if self.home_2.pending_contact_request_text.text != '1':
self.errors.append("The amount of contact requests is not shown for outgoing CR!")
self.home_2.pending_contact_request_button.click()
outgoing_cr = self.home_2.get_chat_from_activity_center_view(self.default_username_1)
outgoing_cr.cancel_contact_request()
self.home_2.close_activity_centre.click()
self.profile_1.just_fyi("Check there is no unread indicator and pending CR")
self.device_1.chats_tab.click()
try:
self.home_1.pending_contact_request_button.wait_for_invisibility_of_element(30)
self.home_1.notifications_unread_badge.wait_for_invisibility_of_element(30)
except TimeoutException:
self.errors.append("Cancelled request is not disappeared!")
self.errors.verify_no_errors()
@marks.testrail_id(702850)
def test_activity_center_decline_contact_request(self):
[home.chats_tab.click() for home in [self.home_1, self.home_2]]
self.home_2.just_fyi("Device2 sends pending contact request after cancelling")
# self.home_2.browser_tab.click() # temp
self.home_2.add_contact(self.public_key_1)
self.device_1.just_fyi('Device1 verifies pending contact request')
self.home_1.contacts_tab.click()
for indicator in (self.home_1.notifications_unread_badge, self.home_1.contact_new_badge):
if not indicator.is_element_displayed():
self.errors.append("Unread indicator on contacts tab or on activity center is not shown!")
self.errors.append("Unread indicator on contacts tab or on activity center is not shown for incoming CR!")
if self.home_1.pending_contact_request_text.text != '1':
self.errors.append("The amount of contact requests is not shown!")
self.errors.append("The amount of contact requests is not shown for incoming CR!")
self.device_1.just_fyi('Device1 declines pending contact request')
self.home_1.handle_contact_request(username=self.default_username_2, accept=False)
self.home_1.handle_contact_request(username=self.default_username_2, action='decline')
for indicator in (self.home_1.notifications_unread_badge, self.home_1.contact_new_badge, self.home_1.pending_contact_request_text):
if indicator.is_element_displayed():
self.errors.append("Unread indicator on contacts tab or on activity center is shown after declining contact request!")
@ -238,19 +155,7 @@ class TestActivityCenterMultipleDevicePR(MultipleSharedDeviceTestCase):
@marks.testrail_id(702851)
def test_activity_center_mentions_in_community_jump_to(self):
self.device_2.just_fyi('Device2 re-sends a contact request to Device1')
self.home_2.browser_tab.click()
self.profile_2.click_system_back_button_until_element_is_shown(self.profile_2.contacts_button)
self.profile_2.contacts_button.wait_and_click(30)
self.profile_2.add_new_contact_button.wait_and_click()
chat = self.profile_2.get_chat_view()
chat.public_key_edit_box.click()
chat.public_key_edit_box.send_keys(self.public_key_1)
chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact)
if chat.profile_remove_from_contacts.is_element_displayed(20):
chat.profile_remove_from_contacts.click()
chat.profile_add_to_contacts.click()
self.profile_2.click_system_back_button_until_element_is_shown()
self.home_2.add_contact(self.public_key_1, remove_from_contacts=True)
self.device_1.just_fyi('Device1 accepts pending contact request and check contact list')
self.home_1.chats_tab.click()

View File

@ -1096,19 +1096,3 @@ class TestMutualContactRequests(MultipleSharedDeviceTestCase):
self.errors.verify_no_errors()
@marks.testrail_id(702377)
def test_mutual_cr_decline_contact_request(self):
[home.home_button.double_click() for home in (self.home_1, self.home_2)]
self.chat_1 = self.home_1.add_contact(self.public_key_2, add_in_contacts=False)
self.chat_1.send_contact_request('Contact request to decline')
self.home_2.handle_contact_request(self.default_username_1, accept=False)
self.home_2.home_button.click()
chat_2 = self.home_2.add_contact(self.public_key_1, add_in_contacts=False)
self.chat_1.just_fyi('Verify cannot send messages to user who declined contact request')
if self.chat_1.chat_message_input.is_element_displayed():
self.drivers[0].fail('Chat input field is displayed despite contact request has been declined')
chat_2.just_fyi('Verify cannot send messages to user whos request has been declined')
if chat_2.chat_message_input.is_element_displayed():
self.drivers[1].fail('Chat input field is displayed in 1-1 chat with user whos cr was declined')

View File

@ -623,8 +623,7 @@ class PinnedMessagesList(BaseElement):
return message_element
def get_message_pinned_by_text(self, text):
xpath = "//*[starts-with(@text,'%s')]/ancestor::*[@content-desc='message-sent']/" % text + \
"preceding-sibling::*[@content-desc='pinned-by']/android.widget.TextView"
xpath = "//*[starts-with(@text,'%s')]/../../*[@content-desc='pinned-by']/android.widget.TextView" % text
pinned_by_element = Text(self.driver, prefix=self.locator, xpath=xpath)
self.driver.info("Looking for a pinned by message with text: %s" % text)
return pinned_by_element

View File

@ -112,21 +112,23 @@ class ActivityCenterElement(SilentButton):
super().__init__(driver,
xpath="//*[contains(@text, '%s')]/ancestor::*[@content-desc='activity']" % username)
def accept_contact_request(self):
def handle_cr(self, element_accessibility: str):
try:
accept_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="accept-contact-request"]').find_element()
accept_element = Button(self.driver,
xpath=self.locator + '/*[@content-desc="%s"]' % element_accessibility).find_element()
except NoSuchElementException:
return ''
if accept_element:
accept_element.click()
def accept_contact_request(self):
self.handle_cr("accept-contact-request")
def decline_contact_request(self):
try:
decline_element = Button(self.driver, xpath=self.locator + '/*[@content-desc="decline-contact-request"]').find_element()
except NoSuchElementException:
return ''
if decline_element:
decline_element.click()
self.handle_cr("decline-contact-request")
def cancel_contact_request(self):
self.handle_cr("cancel-contact-request")
class PushNotificationElement(SilentButton):
@ -197,6 +199,7 @@ class HomeView(BaseView):
self.groups_tab = Button(self.driver, accessibility_id="tab-groups")
self.contacts_tab = Button(self.driver, accessibility_id="tab-contacts")
self.contact_new_badge = Button(self.driver, accessibility_id="notification-dot")
self.pending_contact_request_button = Button(self.driver, accessibility_id="open-activity-center-contact-requests")
self.pending_contact_request_text = Text(self.driver, xpath='//*[@content-desc="pending-contact-requests-count"]/android.widget.TextView')
@ -232,7 +235,7 @@ class HomeView(BaseView):
# New UI bottom sheet
self.start_a_new_chat_bottom_sheet_button = Button(self.driver, accessibility_id="start-a-new-chat")
self.add_a_contact_chat_bottom_sheet_button = Button(self.driver, accessibility_id="add-a-contact")
self.setup_chat_button = Button(self.driver, accessibility_id="next-button")
def wait_for_syncing_complete(self):
self.driver.info('Waiting for syncing to complete')
@ -267,16 +270,21 @@ class HomeView(BaseView):
chat_element = ActivityCenterElement(self.driver, chat_name[:25])
return chat_element
def handle_contact_request(self, username: str, accept=True):
def handle_contact_request(self, username: str, action='accept'):
if self.notifications_unread_badge.is_element_displayed(30):
self.open_activity_center_button.click()
chat_element = ActivityCenterElement(self.driver, username[:25])
if accept:
self.driver.info("Accepting contact request for %s" % username)
if action == 'accept':
self.driver.info("Accepting incoming CR for %s" % username)
chat_element.accept_contact_request()
else:
self.driver.info("Rejecting contact request for %s" % username)
elif action == 'decline':
self.driver.info("Rejecting incoming CR for %s" % username)
chat_element.decline_contact_request()
elif action == 'cancel':
self.driver.info("Canceling outgoing CR for %s" % username)
chat_element.cancel_contact_request()
else:
self.driver.fail("Illegal option for CR!")
self.close_activity_centre.click()
self.chats_tab.wait_for_visibility_of_element()
@ -284,46 +292,46 @@ class HomeView(BaseView):
return Text(self.driver,
xpath="//*[@content-desc='enter-contact-code-input']/../..//*[starts-with(@text,'%s')]" % username_part)
def add_contact(self, public_key, add_in_contacts=True, nickname=''):
self.driver.info("## Starting 1-1 chat, add in contacts:%s" % str(add_in_contacts), device=False)
self.plus_button.click_until_presence_of_element(self.start_new_chat_button)
chat = self.start_new_chat_button.click()
def add_contact(self, public_key, nickname='', remove_from_contacts=False):
self.driver.info("Adding user to Contacts via chats > add new contact")
self.new_chat_button.click_until_presence_of_element(self.add_a_contact_chat_bottom_sheet_button)
self.add_a_contact_chat_bottom_sheet_button.click()
chat = self.get_chat_view()
chat.public_key_edit_box.click()
chat.public_key_edit_box.send_keys(public_key)
one_to_one_chat = self.get_chat_view()
chat.confirm()
# chat.confirm_until_presence_of_element(one_to_one_chat.chat_message_input)
if add_in_contacts and one_to_one_chat.add_to_contacts.is_element_displayed():
one_to_one_chat.add_to_contacts.click()
chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact)
if remove_from_contacts and chat.profile_remove_from_contacts.is_element_displayed():
chat.profile_remove_from_contacts.click()
chat.profile_add_to_contacts.click()
if nickname:
one_to_one_chat.chat_options.click()
one_to_one_chat.view_profile_button.click()
one_to_one_chat.set_nickname(nickname)
self.driver.info("## 1-1 chat is created successfully!", device=False)
return one_to_one_chat
chat.set_nickname(nickname)
self.click_system_back_button_until_element_is_shown()
def create_group_chat(self, user_names_to_add: list, group_chat_name: str = 'new_group_chat', new_ui=False):
self.driver.info("## Creating group chat '%s'" % group_chat_name, device=False)
self.new_chat_button.click()
chat_view = self.get_chat_view()
chat = self.get_chat_view()
if new_ui:
self.start_a_new_chat_bottom_sheet_button.click()
[chat_view.get_username_checkbox(user_name).click() for user_name in user_names_to_add]
[chat.get_username_checkbox(user_name).click() for user_name in user_names_to_add]
self.setup_chat_button.click()
else:
chat_view = self.new_group_chat_button.click()
chat = self.new_group_chat_button.click()
if user_names_to_add:
for user_name in user_names_to_add:
if len(user_names_to_add) > 5:
chat_view.search_by_keyword(user_name[:5])
chat_view.get_username_checkbox(user_name).click()
chat_view.search_input.clear()
chat.search_by_keyword(user_name[:5])
chat.get_username_checkbox(user_name).click()
chat.search_input.clear()
else:
chat_view.get_username_checkbox(user_name).click()
chat_view.next_button.click()
chat_view.chat_name_editbox.send_keys(group_chat_name)
chat_view.create_button.click()
chat.get_username_checkbox(user_name).click()
chat.next_button.click()
chat.chat_name_editbox.send_keys(group_chat_name)
chat.create_button.click()
self.driver.info("## Group chat %s is created successfully!" % group_chat_name, device=False)
return chat_view
return chat
def send_contact_request_via_bottom_sheet(self, key:str):
chat = self.get_chat_view()