From 99c35da72a7fd56290e11045bed79cb07565dae7 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Tue, 29 Mar 2022 15:45:31 +0200 Subject: [PATCH] e2e: chat group in medium + testrail --- test/appium/support/testrail_report.py | 49 +-- .../atomic/chats/test_chats_management.py | 49 --- .../tests/atomic/chats/test_group_chat.py | 79 ----- .../tests/atomic/chats/test_one_to_one.py | 255 -------------- .../tests/atomic/test_public_chat_browsing.py | 314 +++++++++++++++++- 5 files changed, 333 insertions(+), 413 deletions(-) diff --git a/test/appium/support/testrail_report.py b/test/appium/support/testrail_report.py index 7b4b130611..af03f80058 100644 --- a/test/appium/support/testrail_report.py +++ b/test/appium/support/testrail_report.py @@ -97,23 +97,24 @@ class TestrailReport(BaseTestReport): def get_regression_cases(self): test_cases = dict() - test_cases['critical'] = 730 - test_cases['medium'] = 736 - test_cases['upgrade'] = 881 - ## tests pr - test_cases['public_chat'] = 50654 - test_cases['one_to_one_chat'] = 50655 - test_cases['group_chat'] = 50656 - test_cases['onboarding'] = 50659 - test_cases['recovery'] = 50660 - test_cases['wallet'] = 50661 - test_cases['send_tx'] = 50662 - test_cases['keycard_tx'] = 50663 - test_cases['browser'] = 50812 - test_pr = list() - for key in test_cases: - if key != 'medium' and key != 'upgrade': - test_pr.append(test_cases[key]) + test_cases['pr'] = dict() + test_cases['nightly'] = dict() + test_cases['upgrade'] = dict() + ## PR e2e + test_cases['pr']['critical'] = 730 + test_cases['pr']['public_chat'] = 50654 + test_cases['pr']['one_to_one_chat'] = 50655 + test_cases['pr']['group_chat'] = 50656 + test_cases['pr']['onboarding'] = 50659 + test_cases['pr']['recovery'] = 50660 + test_cases['pr']['wallet'] = 50661 + test_cases['pr']['send_tx'] = 50662 + test_cases['pr']['keycard_tx'] = 50663 + ## Nightly e2e + test_cases['nightly']['medium'] = 736 + test_cases['nightly']['chat'] = 50811 + ## Upgrade e2e + test_cases['upgrade']['general'] = 881 case_ids = list() for arg in argv: @@ -122,16 +123,20 @@ class TestrailReport(BaseTestReport): case_ids = value.split(',') if len(case_ids) == 0: if 'critical or high' in argv: - for case in self.get_cases(test_pr): - case_ids.append(case['id']) + for category in test_cases['pr']: + for case in self.get_cases([test_cases['pr'][category]]): + case_ids.append(case['id']) elif 'upgrade' in argv and 'not upgrade' not in argv: - for case in self.get_cases([test_cases['upgrade']]): + for case in self.get_cases([test_cases['upgrade']['general']]): case_ids.append(case['id']) else: for phase in test_cases: if phase != 'upgrade': - for case in self.get_cases([test_cases[phase]]): - case_ids.append(case['id']) + print("For %s phase" % phase) + for category in test_cases[phase]: + print("For %s category" % category) + for case in self.get_cases([test_cases[phase][category]]): + case_ids.append(case['id']) return case_ids def add_results(self): diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index d49ff47ea0..762b1f5661 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -869,55 +869,6 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): self.errors.verify_no_errors() - @marks.testrail_id(6267) - @marks.medium - def test_open_user_profile_long_press_on_message(self): - self.create_drivers(2) - device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - message_from_sender = "Message sender" - message_from_receiver = "Message receiver" - home_1, home_2 = device_1.create_user(), device_2.create_user() - - device_1.just_fyi('Both devices join to 1-1 chat') - device_2_public_key = home_2.get_public_key_and_username() - device_1_profile = home_1.profile_button.click() - device_1_username = device_1_profile.default_username_text.text - home_1.home_button.click() - - device_1.just_fyi("1-1 chat: sender adds receiver and send a message") - device_1_chat = home_1.add_contact(device_2_public_key) - device_1_chat.send_message(message_from_sender) - device_1_chat.chat_element_by_text(message_from_sender).long_press_element() - if device_1_chat.view_profile_by_avatar_button.is_element_displayed(): - self.errors.append('Member photo is shown on long tap on sent message from 1-1 chat') - device_1_chat.click_system_back_button(2) - - device_2.just_fyi("1-1 chat: receiver verifies that can open sender profile on long tap on message") - home_2.home_button.click() - device_2_chat_item = home_2.get_chat(device_1_username) - device_2_chat_item.wait_for_visibility_of_element(20) - device_2_chat = device_2_chat_item.click() - device_2_chat.chat_element_by_text(message_from_sender).long_press_element() - if device_2_chat.view_profile_by_avatar_button.is_element_displayed(): - self.errors.append('1-1 chat: another user profile is opened on long tap on received message') - device_2_chat.click_system_back_button(2) - - device_1.just_fyi( - 'Public chat: send message and verify that user profile can be opened on long press on message') - chat_name = device_1.get_random_chat_name() - for home in home_1, home_2: - home.join_public_chat(chat_name) - chat_public_1, chat_public_2 = home_1.get_chat_view(), home_2.get_chat_view() - chat_public_2.send_message(message_from_receiver) - chat_public_2.chat_element_by_text(message_from_receiver).long_press_element() - if chat_public_2.view_profile_by_avatar_button.is_element_displayed(): - self.errors.append('Public chat: "view profile" is shown on long tap on sent message') - chat_public_1.view_profile_long_press(message_from_receiver) - if not chat_public_1.remove_from_contacts.is_element_displayed(): - self.errors.append('Public chat: another user profile is not opened on long tap on received message') - - self.errors.verify_no_errors() - @marks.testrail_id(6326) @marks.medium def test_mention_users_not_in_chats_if_not_in_contacts(self): diff --git a/test/appium/tests/atomic/chats/test_group_chat.py b/test/appium/tests/atomic/chats/test_group_chat.py index 3ceca22f9f..b94ca586ca 100644 --- a/test/appium/tests/atomic/chats/test_group_chat.py +++ b/test/appium/tests/atomic/chats/test_group_chat.py @@ -59,42 +59,6 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase): self.errors.verify_no_errors() - @marks.testrail_id(6280) - @marks.medium - def test_rename_group_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() - device_1_key, device_1_username = device_1.get_public_key_and_username(True) - device_1.home_button.click() - initial_chat_name = home_1.get_random_chat_name() - - device_2.just_fyi('Create and join group chat') - public_key_2, username_2 = device_2.get_public_key_and_username(True) - device_2.home_button.click() - home_1.add_contact(public_key_2) - home_1.get_back_to_home_view() - device_1_chat = home_1.create_group_chat([username_2], initial_chat_name) - device_2_chat = home_2.get_chat(initial_chat_name).click() - device_2_chat.join_chat_button.click() - - device_2.just_fyi('Rename chat and check system messages') - new_chat_name = device_1_chat.get_random_chat_name() - device_1_chat.rename_chat_via_group_info(new_chat_name) - for chat in (device_1_chat, device_2_chat): - if not chat.element_by_text( - chat.create_system_message(device_1_username, initial_chat_name)).is_element_displayed(): - self.errors.append('Initial system message about creating chta was changed!') - if not chat.element_by_text( - chat.changed_group_name_system_message(device_1_username, new_chat_name)).is_element_displayed(): - self.errors.append('Message about changing chat name is not shown') - - device_2.just_fyi('Check that you can see renamed chat') - device_2_chat.back_button.click() - home_2.get_chat(new_chat_name).wait_for_visibility_of_element(60) - - self.errors.verify_no_errors() - @marks.testrail_id(6327) @marks.medium def test_nicknames_ens_group_chats(self): @@ -200,49 +164,6 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase): self.errors.verify_no_errors() - @marks.testrail_id(5752) - @marks.medium - def test_block_and_unblock_user_from_group_chat_via_group_info(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() - initial_chat_name = home_1.get_random_chat_name() - - device_2.just_fyi('Create and join group chat') - public_key_2, username_2 = device_2.get_public_key_and_username(True) - device_2.home_button.click() - home_1.add_contact(public_key_2) - home_1.get_back_to_home_view() - chat_1 = home_1.create_group_chat([username_2], initial_chat_name) - chat_2 = home_2.get_chat(initial_chat_name).click() - chat_2.join_chat_button.click() - - device_2.just_fyi('Send message and block user via Group Info') - message_before_block = 'message from device2' - chat_2.send_message(message_before_block) - options_2 = chat_1.get_user_options(username_2) - options_2.view_profile_button.click() - options_2.block_contact() - home_1.close_button.click() - if chat_1.chat_element_by_text(message_before_block).is_element_displayed(10): - self.errors.append('User was blocked, but past message are shown') - message_after_block = 'message from device2 after block' - chat_2.send_message(message_after_block) - if chat_1.chat_element_by_text(message_after_block).is_element_displayed(10): - self.errors.append('User was blocked, but new messages still received') - - device_1.just_fyi('Unblock user via group info and check that new messages will arrive') - options_2 = chat_1.get_user_options(username_2) - options_2.view_profile_button.click() - options_2.unblock_contact_button.click() - [options_2.close_button.click() for _ in range(2)] - message_after_unblock = 'message from device2 after unblock' - chat_2.send_message(message_after_unblock) - if not chat_1.chat_element_by_text(message_after_unblock).is_element_displayed(20): - self.errors.append('User was unblocked, but new messages are not received') - - self.errors.verify_no_errors() - class TestCommandsSingleDevices(SingleDeviceTestCase): diff --git a/test/appium/tests/atomic/chats/test_one_to_one.py b/test/appium/tests/atomic/chats/test_one_to_one.py index e65539b817..e1cb0b2e34 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -447,112 +447,6 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): self.errors.verify_no_errors() - @marks.testrail_id(695847) - @marks.medium - def test_can_pin_messages_in_one_to_one_and_group_chats(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() - public_key_1, username_1 = home_1.get_public_key_and_username(return_username=True) - public_key_2, username_2 = home_2.get_public_key_and_username(return_username=True) - home_1.home_button.click() - chat_1 = home_1.add_contact(public_key_2) - - home_1.just_fyi("Check that Device1 can pin own message in 1-1 chat") - message_1, message_2, message_3, message_4 = "Message1", "Message2", "Message3", "Message4", - chat_1.send_message(message_1) - chat_1.send_message(message_2) - chat_1.pin_message(message_1) - if not chat_1.chat_element_by_text(message_1).pinned_by_label.is_element_present(): - self.drivers[0].fail("Message is not pinned!") - - home_1.just_fyi("Check that Device2 can pin Device1 message in 1-1 chat and two pinned " - "messages are in Device1 profile") - home_2.home_button.click() - chat_2 = home_2.get_chat(username_1).click() - chat_2.pin_message(message_2) - chat_2.chat_options.click() - chat_2.view_profile_button.click() - if not chat_2.pinned_messages_button.count == "2": - self.drivers[0].fail("Pinned message count is not 2 as expected!") - - home_1.just_fyi("Check pinned message are visible in Pinned panel for both users") - chat_1.chat_options.click() - chat_1.view_profile_button.click() - chat_1.pinned_messages_button.click() - if not (chat_1.chat_element_by_text(message_1).pinned_by_label.is_element_present() and - chat_1.chat_element_by_text(message_2).pinned_by_label.is_element_present() and - chat_1.chat_element_by_text(message_1).is_element_present() and - chat_1.chat_element_by_text(message_2).is_element_present()): - self.drivers[0].fail("Something missed on Pinned messaged on Device 1!") - chat_2.pinned_messages_button.click() - if not (chat_1.chat_element_by_text(message_1).pinned_by_label.is_element_present() and - chat_2.chat_element_by_text(message_2).pinned_by_label.is_element_present() and - chat_2.chat_element_by_text(message_1).is_element_present() and - chat_2.chat_element_by_text(message_2).is_element_present()): - self.drivers[0].fail("Something missed on Pinned messaged on Device 2!") - chat_1.close_button.click() - - home_1.just_fyi("Check that Device1 can not pin more than 3 messages and 'Unpin' dialog appears" - "messages are in Device1 profile") - chat_1.send_message(message_3) - chat_1.send_message(message_4) - chat_1.pin_message(message_3) - chat_1.pin_message(message_4) - if not chat_1.unpin_message_popup.is_element_present(): - self.drivers[0].fail("No 'Unpin' dialog appears when pining 4th message") - - home_1.just_fyi("Unpin one message so that another could be pinned") - chat_1.unpin_message_popup.message_text(message_1).click() - chat_1.unpin_message_popup.click_unpin_message_button() - - if chat_1.unpin_message_popup.is_element_present(): - self.drivers[0].fail("Unpin message pop up keep staying after Unpin button pressed") - if chat_1.chat_element_by_text(message_1).pinned_by_label.is_element_present(): - self.drivers[0].fail("Message is not unpinned!") - if not chat_1.chat_element_by_text(message_4).pinned_by_label.is_element_present(): - self.drivers[0].fail("Message is not pinned!") - - home_1.just_fyi("Unpin another message and check it's unpinned for another user") - chat_2.close_button.click() - chat_2.pin_message(message_4, action="unpin") - chat_1.chat_element_by_text(message_4).pinned_by_label.wait_for_invisibility_of_element() - if chat_1.chat_element_by_text(message_4).pinned_by_label.is_element_present(): - self.drivers[0].fail("Message_4 is not unpinned!") - - home_1.just_fyi("Create group chat and pin message there. It's pinned for both members.") - chat_2.home_button.click() - chat_1.home_button.click() - group_chat_name = "GroupChat" - group_chat_1 = home_1.create_group_chat(user_names_to_add=[username_2], group_chat_name=group_chat_name) - home_2.get_chat(group_chat_name).click() - group_chat_2 = home_2.get_chat_view() - group_chat_2.join_chat_button.click() - group_chat_1.send_message(message_1) - group_chat_1.pin_message(message_1) - if not (group_chat_1.chat_element_by_text(message_1).pinned_by_label.is_element_present(30) and - group_chat_2.chat_element_by_text(message_1).pinned_by_label.is_element_present(30)): - self.errors.append("Message is not pinned in group chat!") - - home_1.just_fyi("Check that non admin user can not unpin messages") - group_chat_2.chat_element_by_text(message_1).long_press_element() - if group_chat_2.element_by_translation_id("unpin").is_element_present(): - self.errors.append("Unpin option is available for non-admin user") - - home_1.just_fyi("Grant another user with admin rights and check he can unpin message now") - group_chat_1.chat_options.click() - group_info = group_chat_1.group_info.click() - options = group_info.get_username_options(username_2).click() - options.make_admin_button.click() - group_chat_2.click_system_back_button() - group_chat_2.pin_message(message_1, action="unpin") - if (group_chat_1.chat_element_by_text(message_1).pinned_by_label.is_element_present() and - group_chat_2.chat_element_by_text(message_1).pinned_by_label.is_element_present()): - self.errors.append("Message failed be unpinned by user who granted admin permissions!") - - self.errors.verify_no_errors() - @marks.testrail_id(5373) @marks.high def test_send_and_open_emoji_link_in_one_to_one(self): @@ -586,7 +480,6 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): self.errors.append('URL was not opened from 1-1 chat') self.errors.verify_no_errors() - @marks.testrail_id(5362) @marks.medium def test_unread_messages_counter_preview_highlited_1_1_chat(self): @@ -633,154 +526,6 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): self.errors.append("Preview message is still highlighted after opening ") self.errors.verify_no_errors() - @marks.testrail_id(6321) - @marks.medium - def test_push_notifications_reactions_for_messages_in_stickers_audio_image(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(enable_notifications=True), device_2.create_user() - public_key_1, default_username_1 = home_1.get_public_key_and_username(return_username=True) - public_key_2, default_username_2 = home_2.get_public_key_and_username(return_username=True) - home_1.home_button.click() - profile_2 = home_2.get_profile_view() - profile_2.switch_network() - chat_2 = home_2.add_contact(public_key_1) - - home_2.just_fyi('Install free sticker pack and use it in 1-1 chat') - chat_2.install_sticker_pack_by_name() - chat_1 = home_1.add_contact(public_key_2) - - # methods with steps to use later in loop - def navigate_to_start_state_of_both_devices(): - chat_1.put_app_to_background() - device_1.open_notification_bar() - chat_2.get_back_to_home_view(2) - home_2.get_chat_from_home_view(default_username_1).click() - - def device_2_sends_sticker(): - chat_2.just_fyi("Sending Sticker in chat") - chat_2.show_stickers_button.click() - chat_2.sticker_icon.click() - - def device_2_sends_image(): - chat_2.just_fyi("Sending Image in chat") - chat_2.show_images_button.click() - chat_2.allow_button.click() - chat_2.first_image_from_gallery.click() - chat_2.send_message_button.click() - - def device_2_sends_audio(): - chat_2.just_fyi("Sending Audio in chat") - chat_2.record_audio_message(message_length_in_seconds=3) - chat_2.send_message_button.click() - - sending_list = { - "sticker": device_2_sends_sticker, - "image": device_2_sends_image, - "audio": device_2_sends_audio, - } - - for key, value in sending_list.items(): - navigate_to_start_state_of_both_devices() - sending_list[key]() - if not device_1.element_by_text_part(key.capitalize()).is_element_displayed(10): - self.errors.append("%s not appeared in Push Notification" % key.capitalize()) - device_1.click_system_back_button() - device_1.get_app_from_background() - else: - device_1.element_by_text_part(key.capitalize()).click() - message = chat_2.chat_element_by_text(key) - chat_1.set_reaction(key) - if message.emojis_below_message(own=False) != 1: - self.errors.append("Counter of reaction is not set on %s for message receiver!" % key) - chat_1.set_reaction(key) - if message.emojis_below_message(own=False) == 1: - self.errors.append("Counter of reaction is not re-set on %s for message receiver!" % key) - - chat_2.just_fyi("Sending Emoji/Tag/Links in chat") - # TODO: add link and tag messages after #11168 is fixed(rechecked 23.11.21, valid) - navigate_to_start_state_of_both_devices() - - emoji_name = random.choice(list(emoji.EMOJI_UNICODE)) - emoji_unicode = emoji.EMOJI_UNICODE[emoji_name] - - chat_2.just_fyi("Sending Emoji in chat") - chat_2.chat_message_input.send_keys(emoji.emojize(emoji_name)) - chat_2.send_message_button.click() - - if not device_1.element_by_text_part(emoji_unicode).is_element_displayed(10): - self.errors.append("Emoji not appeared in Push Notification") - device_1.click_system_back_button() - device_1.get_app_from_background() - else: - device_1.element_by_text_part(emoji_unicode).click() - - emoji_message = chat_2.chat_element_by_text(emoji_unicode) - chat_1.set_reaction(emoji_unicode, emoji_message=True) - if emoji_message.emojis_below_message(own=False) != 1: - self.errors.append("Counter of reaction is not set on Emoji for message receiver!") - chat_1.set_reaction(emoji_unicode, emoji_message=True) - if emoji_message.emojis_below_message(own=False) == 1: - self.errors.append("Counter of reaction is not re-set on Emoji for message receiver!") - - self.errors.verify_no_errors() - - @marks.testrail_id(5425) - @marks.medium - # TODO: should be completed with quoting after fix 9480 (rechecked 23.11.21, valid) - def test_markdown_support_in_messages(self): - self.create_drivers(2) - sign_in_1, sign_in_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) - home_1, home_2 = sign_in_1.create_user(), sign_in_2.create_user() - profile_2 = home_2.profile_button.click() - default_username_2 = profile_2.default_username_text.text - home_2 = profile_2.home_button.click() - public_key_1 = home_1.get_public_key_and_username() - home_1.home_button.click() - - chat_2 = home_2.add_contact(public_key_1) - chat_2.chat_message_input.send_keys('test message') - chat_2.send_message_button.click() - chat_1 = home_1.get_chat(default_username_2).click() - - markdown = { - 'bold text in asterics': '**', - 'bold text in underscores': '__', - 'italic text in asteric': '*', - 'italic text in underscore': '_', - 'inline code': '`', - 'code blocks': '```', - # 'quote reply (one row)' : '>', - } - - for message, symbol in markdown.items(): - home_1.just_fyi('checking that "%s" is applied (%s) in 1-1 chat' % (message, symbol)) - message_to_send = symbol + message + symbol if 'quote' not in message else symbol + message - chat_2.chat_message_input.send_keys(message_to_send) - chat_2.send_message_button.click() - if not chat_2.chat_element_by_text(message).is_element_displayed(): - self.errors.append('%s is not displayed with markdown in 1-1 chat for the sender \n' % message) - - if not chat_1.chat_element_by_text(message).is_element_displayed(): - self.errors.append('%s is not displayed with markdown in 1-1 chat for the recipient \n' % message) - - [chat.home_button.double_click() for chat in (chat_1, chat_2)] - chat_name = home_1.get_random_chat_name() - [home.join_public_chat(chat_name) for home in (home_1, home_2)] - - for message, symbol in markdown.items(): - home_1.just_fyi('checking that "%s" is applied (%s) in public chat' % (message, symbol)) - message_to_send = symbol + message + symbol if 'quote' not in message else symbol + message - chat_2.chat_message_input.send_keys(message_to_send) - chat_2.send_message_button.click() - if not chat_2.chat_element_by_text(message).is_element_displayed(30): - self.errors.append('%s is not displayed with markdown in public chat for the sender \n' % message) - - if not chat_1.chat_element_by_text(message).is_element_displayed(30): - self.errors.append('%s is not displayed with markdown in public chat for the recipient \n' % message) - - self.errors.verify_no_errors() - class TestMessagesOneToOneChatSingle(SingleDeviceTestCase): diff --git a/test/appium/tests/atomic/test_public_chat_browsing.py b/test/appium/tests/atomic/test_public_chat_browsing.py index e0cecf9141..d7ae31b197 100644 --- a/test/appium/tests/atomic/test_public_chat_browsing.py +++ b/test/appium/tests/atomic/test_public_chat_browsing.py @@ -474,6 +474,311 @@ class TestPublicChatBrowserOneDeviceMerged(MultipleSharedDeviceTestCase): self.errors.verify_no_errors() +@pytest.mark.xdist_group(name="chat_medium_2") +@marks.medium +class TestChatMultipleDevice(MultipleSharedDeviceTestCase): + + @classmethod + def setup_class(cls): + cls.drivers, cls.loop = create_shared_drivers(2) + cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) + cls.home_1, cls.home_2 = cls.device_1.create_user(enable_notifications=True), cls.device_2.create_user() + cls.public_key_1, cls.default_username_1 = cls.home_1.get_public_key_and_username(return_username=True) + cls.public_key_2, cls.default_username_2 = cls.home_2.get_public_key_and_username(return_username=True) + profile_2 = cls.home_2.profile_button.click() + profile_2.switch_network() + [home.home_button.click() for home in (cls.home_1, cls.home_2)] + + cls.home_1.just_fyi("Creating 1-1 chats") + cls.chat_1 = cls.home_1.add_contact(cls.public_key_2) + cls.chat_2 = cls.home_2.add_contact(cls.public_key_1) + cls.home_2.just_fyi('Install free sticker pack and use it in 1-1 chat') + cls.chat_2.install_sticker_pack_by_name() + [home.home_button.click() for home in (cls.home_1, cls.home_2)] + + cls.home_1.just_fyi("Creating group chats") + cls.initial_group_chat_name = "GroupChat before rename" + cls.new_group_chat_name = "GroupChat after rename" + cls.group_chat_1 = cls.home_1.create_group_chat(user_names_to_add=[cls.default_username_2], group_chat_name=cls.initial_group_chat_name) + cls.group_chat_2 = cls.home_2.get_chat(cls.initial_group_chat_name).click() + cls.group_chat_2.join_chat_button.click() + [home.home_button.click() for home in (cls.home_1, cls.home_2)] + + cls.home_1.just_fyi("Creating public chats") + cls.public_chat_name = cls.home_1.get_random_chat_name() + cls.public_chat_1, cls.public_chat_2 = cls.home_1.join_public_chat(cls.public_chat_name), cls.home_2.join_public_chat(cls.public_chat_name) + [home.home_button.click() for home in (cls.home_1, cls.home_2)] + + cls.home_1.get_chat(cls.default_username_2).click() + cls.home_2.get_chat(cls.default_username_1).click() + + cls.message_1, cls.message_2, cls.message_3, cls.message_4 = "Message1", "Message2", "Message3", "Message4" + + @marks.testrail_id(702066) + def test_chat_push_notifications_reaction_for_messages_sticker_audio_image(self): + + # methods with steps to use later in loop + def navigate_to_start_state_of_both_devices(): + self.chat_1.put_app_to_background() + self.device_1.open_notification_bar() + self.chat_2.get_back_to_home_view(2) + self.home_2.get_chat_from_home_view(self.default_username_1).click() + + def device_2_sends_sticker(): + self.chat_2.just_fyi("Sending Sticker in chat") + self.chat_2.show_stickers_button.click() + self.chat_2.sticker_icon.click() + + def device_2_sends_image(): + self.chat_2.just_fyi("Sending Image in chat") + self.chat_2.show_images_button.click() + self.chat_2.allow_button.click() + self.chat_2.first_image_from_gallery.click() + self.chat_2.send_message_button.click() + + def device_2_sends_audio(): + self.chat_2.just_fyi("Sending Audio in chat") + self.chat_2.record_audio_message(message_length_in_seconds=3) + self.chat_2.send_message_button.click() + + sending_list = { + "sticker": device_2_sends_sticker, + "image": device_2_sends_image, + "audio": device_2_sends_audio, + } + + for key, value in sending_list.items(): + navigate_to_start_state_of_both_devices() + sending_list[key]() + if not self.device_1.element_by_text_part(key.capitalize()).is_element_displayed(10): + self.errors.append("%s not appeared in Push Notification" % key.capitalize()) + self.device_1.click_system_back_button() + self.device_1.get_app_from_background() + else: + self.device_1.element_by_text_part(key.capitalize()).click() + message = self.chat_2.chat_element_by_text(key) + self.chat_1.set_reaction(key) + if message.emojis_below_message(own=False) != 1: + self.errors.append("Counter of reaction is not set on %s for message receiver!" % key) + self.chat_1.set_reaction(key) + if message.emojis_below_message(own=False) == 1: + self.errors.append("Counter of reaction is not re-set on %s for message receiver!" % key) + + self.chat_2.just_fyi("Sending Emoji/Tag/Links in chat") + # TODO: add link and tag messages after #11168 is fixed(rechecked 23.11.21, valid) + navigate_to_start_state_of_both_devices() + + emoji_name = random.choice(list(emoji.EMOJI_UNICODE)) + emoji_unicode = emoji.EMOJI_UNICODE[emoji_name] + + self.chat_2.just_fyi("Sending Emoji in chat") + self.chat_2.chat_message_input.send_keys(emoji.emojize(emoji_name)) + self.chat_2.send_message_button.click() + + if not self.device_1.element_by_text_part(emoji_unicode).is_element_displayed(10): + self.errors.append("Emoji not appeared in Push Notification") + self.device_1.click_system_back_button() + self.device_1.get_app_from_background() + else: + self.device_1.element_by_text_part(emoji_unicode).click() + + emoji_message = self.chat_2.chat_element_by_text(emoji_unicode) + self.chat_1.set_reaction(emoji_unicode, emoji_message=True) + if emoji_message.emojis_below_message(own=False) != 1: + self.errors.append("Counter of reaction is not set on Emoji for message receiver!") + self.chat_1.set_reaction(emoji_unicode, emoji_message=True) + if emoji_message.emojis_below_message(own=False) == 1: + self.errors.append("Counter of reaction is not re-set on Emoji for message receiver!") + + self.errors.verify_no_errors() + + @marks.testrail_id(702069) + def test_chat_can_pin_messages_in_1_1(self): + + self.home_1.just_fyi("Check that Device1 can pin own message in 1-1 chat") + self.chat_1.send_message(self.message_1) + self.chat_1.send_message(self.message_2) + self.chat_1.pin_message(self.message_1) + if not self.chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_present(): + self.drivers[0].fail("Message is not pinned!") + + self.home_1.just_fyi("Check that Device2 can pin Device1 message in 1-1 chat and two pinned " + "messages are in Device1 profile") + self.chat_2.pin_message(self.message_2) + self.chat_2.chat_options.click() + self.chat_2.view_profile_button.click() + if not self.chat_2.pinned_messages_button.count == "2": + self.drivers[0].fail("Pinned message count is not 2 as expected!") + + self.home_1.just_fyi("Check pinned message are visible in Pinned panel for both users") + self.chat_1.chat_options.click() + self.chat_1.view_profile_button.click() + self.chat_1.pinned_messages_button.click() + if not (self.chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_present() and + self.chat_1.chat_element_by_text(self.message_2).pinned_by_label.is_element_present() and + self.chat_1.chat_element_by_text(self.message_1).is_element_present() and + self.chat_1.chat_element_by_text(self.message_2).is_element_present()): + self.drivers[0].fail("Something missed on Pinned messaged on Device 1!") + self.chat_2.pinned_messages_button.click() + if not (self.chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_present() and + self.chat_2.chat_element_by_text(self.message_2).pinned_by_label.is_element_present() and + self.chat_2.chat_element_by_text(self.message_1).is_element_present() and + self.chat_2.chat_element_by_text(self.message_2).is_element_present()): + self.drivers[0].fail("Something missed on Pinned messaged on Device 2!") + self.chat_1.close_button.click() + + self.home_1.just_fyi("Check that Device1 can not pin more than 3 messages and 'Unpin' dialog appears" + "messages are in Device1 profile") + self.chat_1.send_message(self.message_3) + self.chat_1.send_message(self.message_4) + self.chat_1.pin_message(self.message_3) + self.chat_1.pin_message(self.message_4) + if not self.chat_1.unpin_message_popup.is_element_present(): + self.drivers[0].fail("No 'Unpin' dialog appears when pining 4th message") + + self.home_1.just_fyi("Unpin one message so that another could be pinned") + self.chat_1.unpin_message_popup.message_text(self.message_1).click() + self.chat_1.unpin_message_popup.click_unpin_message_button() + + if self.chat_1.unpin_message_popup.is_element_present(): + self.drivers[0].fail("Unpin message pop up keep staying after Unpin button pressed") + if self.chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_present(): + self.drivers[0].fail("Message is not unpinned!") + if not self.chat_1.chat_element_by_text(self.message_4).pinned_by_label.is_element_present(): + self.drivers[0].fail("Message is not pinned!") + + self.home_1.just_fyi("Unpin another message and check it's unpinned for another user") + self.chat_2.close_button.click() + self.chat_2.pin_message(self.message_4, action="unpin") + self.chat_1.chat_element_by_text(self.message_4).pinned_by_label.wait_for_invisibility_of_element() + if self.chat_1.chat_element_by_text(self.message_4).pinned_by_label.is_element_present(): + self.drivers[0].fail("Message_4 is not unpinned!") + + @marks.testrail_id(702065) + def test_chat_markdown_support_in_public(self): + markdown = { + 'bold text in asterics': '**', + 'bold text in underscores': '__', + 'italic text in asteric': '*', + 'italic text in underscore': '_', + 'inline code': '`', + 'code blocks': '```', + 'quote reply (one row)': '>', + } + + for message, symbol in markdown.items(): + self.home_1.just_fyi('checking that "%s" is applied (%s) in 1-1 chat' % (message, symbol)) + message_to_send = symbol + message + symbol if 'quote' not in message else symbol + message + self.chat_2.send_message(message_to_send) + if not self.chat_2.chat_element_by_text(message).is_element_displayed(): + self.errors.append('%s is not displayed with markdown in 1-1 chat for the sender \n' % message) + + if not self.chat_1.chat_element_by_text(message).is_element_displayed(): + self.errors.append('%s is not displayed with markdown in 1-1 chat for the recipient \n' % message) + + [chat.home_button.double_click() for chat in (self.chat_1, self.chat_2)] + [home.get_chat('#' + self.public_chat_name).click() for home in (self.home_1, self.home_2)] + + for message, symbol in markdown.items(): + self.home_1.just_fyi('checking that "%s" is applied (%s) in public chat' % (message, symbol)) + message_to_send = symbol + message + symbol if 'quote' not in message else symbol + message + self.public_chat_1.send_message(message_to_send) + if not self.public_chat_2.chat_element_by_text(message).is_element_displayed(30): + self.errors.append('%s is not displayed with markdown in public chat for the sender \n' % message) + + if not self.public_chat_1.chat_element_by_text(message).is_element_displayed(30): + self.errors.append('%s is not displayed with markdown in public chat for the recipient \n' % message) + + self.errors.verify_no_errors() + + @marks.testrail_id(702098) + def test_chat_group_chat_rename(self): + + [chat.home_button.double_click() for chat in [self.chat_1, self.chat_2]] + # new_chat_name = self.home_1.get_random_chat_name() + + self.home_2.just_fyi('Rename chat and check system messages') + [home.get_chat(self.initial_group_chat_name).click() for home in (self.home_1, self.home_2)] + self.group_chat_1.rename_chat_via_group_info(self.new_group_chat_name) + for chat in (self.group_chat_1, self.group_chat_2): + if not chat.element_by_text( + chat.create_system_message(self.default_username_1, self.initial_group_chat_name)).is_element_displayed(): + self.errors.append('Initial system message about creating chat was changed!') + if not chat.element_by_text( + chat.changed_group_name_system_message(self.default_username_1, + self.new_group_chat_name)).is_element_displayed(): + self.errors.append('Message about changing chat name is not shown') + + self.home_2.just_fyi('Check that you can see renamed chat') + self.group_chat_2.back_button.click() + self.home_2.get_chat(self.new_group_chat_name).wait_for_visibility_of_element(60) + + self.errors.verify_no_errors() + + @marks.testrail_id(702097) + def test_chat_block_and_unblock_user_from_group_chat_via_group_info(self): + + [chat.home_button.double_click() for chat in [self.chat_1, self.chat_2]] + + self.home_2.just_fyi('Send message and block user via Group Info') + [home.get_chat(self.new_group_chat_name).click() for home in (self.home_1, self.home_2)] + message_before_block = 'message from device2' + self.group_chat_2.send_message(message_before_block) + options_2 = self.group_chat_1.get_user_options(self.default_username_2) + options_2.view_profile_button.click() + options_2.block_contact() + self.home_1.close_button.click() + if self.group_chat_1.chat_element_by_text(message_before_block).is_element_displayed(10): + self.errors.append('User was blocked, but past message are shown') + message_after_block = 'message from device2 after block' + self.group_chat_2.send_message(message_after_block) + if self.group_chat_1.chat_element_by_text(message_after_block).is_element_displayed(10): + self.errors.append('User was blocked, but new messages still received') + + self.home_1.just_fyi('Unblock user via group info and check that new messages will arrive') + options_2 = self.group_chat_1.get_user_options(self.default_username_2) + options_2.view_profile_button.click() + options_2.unblock_contact_button.click() + [options_2.close_button.click() for _ in range(2)] + message_after_unblock = 'message from device2 after unblock' + self.group_chat_2.send_message(message_after_unblock) + if not self.group_chat_1.chat_element_by_text(message_after_unblock).is_element_displayed(20): + self.errors.append('User was unblocked, but new messages are not received') + + self.errors.verify_no_errors() + + @marks.testrail_id(702070) + def test_chat_pin_messages_in_group_chat(self): + + [chat.home_button.double_click() for chat in [self.chat_1, self.chat_2]] + + self.home_1.just_fyi("Enter group chat and pin message there. It's pinned for both members.") + [home.get_chat(self.new_group_chat_name).click() for home in (self.home_1, self.home_2)] + self.group_chat_1.send_message(self.message_1) + self.group_chat_1.pin_message(self.message_1) + if not (self.group_chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_present(30) and + self.group_chat_2.chat_element_by_text(self.message_1).pinned_by_label.is_element_present(30)): + self.errors.append("Message is not pinned in group chat!") + + self.home_1.just_fyi("Check that non admin user can not unpin messages") + self.group_chat_2.chat_element_by_text(self.message_1).long_press_element() + if self.group_chat_2.element_by_translation_id("unpin").is_element_present(): + self.errors.append("Unpin option is available for non-admin user") + + self.home_1.just_fyi("Grant another user with admin rights and check he can unpin message now") + self.group_chat_1.chat_options.click() + group_info = self.group_chat_1.group_info.click() + options = group_info.get_username_options(self.default_username_2).click() + options.make_admin_button.click() + self.group_chat_2.click_system_back_button() + self.group_chat_2.pin_message(self.message_1, action="unpin") + if (self.group_chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_present() and + self.group_chat_2.chat_element_by_text(self.message_1).pinned_by_label.is_element_present()): + self.errors.append("Message failed be unpinned by user who granted admin permissions!") + + self.errors.verify_no_errors() + + class TestPublicChatMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(6342) @@ -618,15 +923,11 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): home_2.get_back_to_home_view() home_2.just_fyi("Joining 1-1 chat by device 2 and sending message") - # one_to_one_chat_element = home_2.get_chat(username_1, wait_time=10) - # one_to_one_chat_2 = one_to_one_chat_element.click() one_to_one_chat_2 = home_2.add_contact(public_key_1) one_to_one_chat_2.send_message(message_2) home_2.get_back_to_home_view() home_2.just_fyi("Joining Group chat by device 2 and sending message") - # home_2.notifications_button.click() - # group_chat_2 = home_2.get_chat_from_activity_center_view(group_chat_name).click() group_chat_2 = home_2.get_chat(group_chat_name).click() group_chat_2.join_chat_button.click() group_chat_2.send_message(message_2) @@ -651,7 +952,4 @@ class TestPublicChatMultipleDevice(MultipleDeviceTestCase): if not chat_view.chat_element_by_text(message_2).is_element_displayed(10): self.errors.append("Message in {} chat has not been fetched automatically".format(chat.user_name_text.text)) chat_view.back_button.click() - self.errors.verify_no_errors() - - - + self.errors.verify_no_errors() \ No newline at end of file