From ab01093a6eca84a11e28a6b923dfd95ccb9762d2 Mon Sep 17 00:00:00 2001 From: Serhy Date: Wed, 7 Jul 2021 11:02:54 +0300 Subject: [PATCH] Edit message in chat test Signed-off-by: Serhy --- .../account_management/test_create_account.py | 2 +- .../tests/atomic/chats/test_commands.py | 2 +- .../tests/atomic/chats/test_one_to_one.py | 56 ++++++++++++++++++- test/appium/views/chat_view.py | 8 +++ 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/test/appium/tests/atomic/account_management/test_create_account.py b/test/appium/tests/atomic/account_management/test_create_account.py index a6b1686793..61288f4d5b 100644 --- a/test/appium/tests/atomic/account_management/test_create_account.py +++ b/test/appium/tests/atomic/account_management/test_create_account.py @@ -96,7 +96,7 @@ class TestCreateAccount(SingleDeviceTestCase): if sign_in.generate_key_button.is_element_displayed(): self.errors.append("Agree with ToS is not mandatory to proceed onboarding!") sign_in.accept_tos_checkbox.click() - sign_in.generate_key_button.click() + sign_in.get_started_button.click() from views.sign_in_view import MultiAccountButton account_button = sign_in.get_multiaccount_by_position(position=random.randint(1, 4), element_class=MultiAccountButton) username = account_button.username.text diff --git a/test/appium/tests/atomic/chats/test_commands.py b/test/appium/tests/atomic/chats/test_commands.py index d9bd2efe97..29e9cc0626 100644 --- a/test/appium/tests/atomic/chats/test_commands.py +++ b/test/appium/tests/atomic/chats/test_commands.py @@ -99,7 +99,7 @@ class TestCommandsMultipleDevices(MultipleDeviceTestCase): @marks.testrail_id(6263) @marks.critical def test_request_and_receive_stt_in_1_1_chat_offline(self): - sender = transaction_senders['C'] + sender = transaction_senders['L'] self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) asset_name = 'STT' 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 ca691e885b..fb287dac4a 100644 --- a/test/appium/tests/atomic/chats/test_one_to_one.py +++ b/test/appium/tests/atomic/chats/test_one_to_one.py @@ -196,6 +196,60 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase): # self.errors.append("Updated profile picture is not shown in one-to-one chat") self.errors.verify_no_errors() + @marks.testrail_id(695843) + @marks.high + def test_edit_message_in_one_to_one_and_public_chats(self): + self.create_drivers(2) + device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + device_1_home, device_2_home = device_1.create_user(), device_2.create_user() + + device_2.just_fyi("Create public chat on Device1, send message and edit it then") + public_key_1, username_1 = device_1_home.get_public_key_and_username(return_username=True) + public_key_2, username_2 = device_2_home.get_public_key_and_username(return_username=True) + device_1_home.home_button.click() + device_2_home.home_button.click() + chat_name = device_1_home.get_random_chat_name() + device_1_home.join_public_chat(chat_name) + device_1_public_chat = device_1_home.get_chat_view() + message_before_edit = "Message BEFORE edit 1" + message_after_edit = "Message AFTER edit 2" + device_1_public_chat.send_message(message_before_edit) + device_1_public_chat.edit_message_in_chat(message_before_edit, message_after_edit) + if not device_1_public_chat.element_by_text_part("⌫ Edited").is_element_displayed(): + self.errors.append('No mark in message bubble about this message was edited') + + device_2.just_fyi("Device 1 sends text message and edits it in 1-1 chat. Device2 checks edited message is shown") + device_2_chat = device_2_home.add_contact(public_key_1) + message_before_edit_1_1 = "Message before edit 1-1" + message_after_edit_1_1 = "AFTER" + device_2_chat.send_message(message_before_edit_1_1) + device_1_home.home_button.click() + + device_1_one_to_one_chat_element = device_1_home.get_chat(username_2) + device_2_chat.edit_message_in_chat(message_before_edit_1_1, message_after_edit_1_1) + device_2_home.home_button.click() + if not device_1_home.element_by_text_part(message_after_edit_1_1).is_element_present(): + self.errors.append('UNedited message version displayed on preview') + device_1_one_to_one_chat_element.click() + if not device_1_home.element_by_text_part(message_after_edit_1_1).is_element_present(): + self.errors.append('No edited message in 1-1 chat displayed') + if not device_1_home.element_by_text_part("⌫ Edited").is_element_present(): + self.errors.append('No mark in message bubble about this message was edited on receiver side') + + device_2.just_fyi("Verify Device1 can not edit received message from Device2") + device_1_home.element_by_text_part(message_after_edit_1_1).long_press_element() + if device_1_home.element_by_translation_id("edit").is_element_present(): + self.errors.append('Option to edit someone else message available!') + + device_2_home.home_button.click() + device_2_public_chat = device_2_home.join_public_chat(chat_name) + if not device_2_public_chat.element_by_text_part("⌫ Edited").is_element_displayed(): + self.errors.append('No mark in message bubble about this message was edited') + if not device_2_public_chat.element_by_text_part(message_after_edit).is_element_displayed(): + self.errors.append('Message is not edited.') + + self.errors.verify_no_errors() + @marks.testrail_id(5782) @marks.critical def test_install_pack_and_send_sticker(self): @@ -786,7 +840,7 @@ class TestMessagesOneToOneChatSingle(SingleDeviceTestCase): @marks.testrail_id(6322) @marks.medium def test_can_scan_different_links_with_universal_qr_scanner(self): - user = transaction_senders['C'] + user = transaction_senders['L'] home_view = SignInView(self.driver).recover_access(user['passphrase']) wallet_view = home_view.wallet_button.click() wallet_view.set_up_wallet() diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 39f9c67f94..7d1b9eb824 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -603,6 +603,14 @@ class ChatView(BaseView): self.chat_message_input.send_keys(message) self.send_message_button.click() + def edit_message_in_chat(self, message_to_edit, message_to_update): + self.driver.info("**Looking for message '%s' to edit it**" % message_to_edit) + self.element_by_text_part(message_to_edit).long_press_element() + self.element_by_translation_id("edit").click() + self.chat_message_input.clear() + self.chat_message_input.send_keys(message_to_update) + self.send_message_button.click() + def copy_message_text(self, message_text): self.driver.info("**Copying '%s' message via long press**" % message_text) self.element_by_text_part(message_text).long_press_element()