2024-03-28 11:17:32 +00:00
|
|
|
import random
|
|
|
|
import string
|
2024-03-19 10:17:28 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
import allure
|
|
|
|
import pytest
|
|
|
|
from allure_commons._allure import step
|
|
|
|
|
2024-04-08 10:48:27 +00:00
|
|
|
import driver
|
2024-05-30 09:41:16 +00:00
|
|
|
from constants.images_paths import HEART_EMOJI_PATH, ANGRY_EMOJI_PATH, THUMBSUP_EMOJI_PATH, THUMBSDOWN_EMOJI_PATH, \
|
|
|
|
LAUGHING_EMOJI_PATH, SAD_EMOJI_PATH
|
2024-06-18 09:42:55 +00:00
|
|
|
from gui.screens.messages import MessagesScreen, ToolBar
|
2024-03-25 09:06:10 +00:00
|
|
|
from tests.settings.settings_messaging import marks
|
2024-03-19 10:17:28 +00:00
|
|
|
|
|
|
|
import configs.testpath
|
|
|
|
import constants
|
|
|
|
from constants import UserAccount
|
|
|
|
from gui.main_window import MainWindow
|
|
|
|
|
|
|
|
pytestmark = marks
|
|
|
|
|
|
|
|
|
2024-03-22 09:37:20 +00:00
|
|
|
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703087', '1-1 Chat')
|
|
|
|
@pytest.mark.case(703087)
|
2024-03-28 09:40:30 +00:00
|
|
|
def test_1x1_chat(multiple_instances):
|
2024-03-28 11:37:24 +00:00
|
|
|
user_one: UserAccount = constants.user_with_random_attributes_1
|
|
|
|
user_two: UserAccount = constants.user_with_random_attributes_2
|
2024-03-19 10:17:28 +00:00
|
|
|
main_window = MainWindow()
|
|
|
|
messages_screen = MessagesScreen()
|
|
|
|
emoji = 'sunglasses'
|
2024-05-30 06:47:42 +00:00
|
|
|
timeout = configs.timeouts.UI_LOAD_TIMEOUT_MSEC
|
2024-06-18 09:42:55 +00:00
|
|
|
path = configs.testpath.TEST_IMAGES / 'comm_logo.jpeg'
|
|
|
|
EMOJI_PATHES = [HEART_EMOJI_PATH, THUMBSUP_EMOJI_PATH, THUMBSDOWN_EMOJI_PATH, LAUGHING_EMOJI_PATH,
|
|
|
|
SAD_EMOJI_PATH, ANGRY_EMOJI_PATH]
|
2024-03-19 10:17:28 +00:00
|
|
|
|
2024-03-28 09:40:30 +00:00
|
|
|
with multiple_instances(user_data=None) as aut_one, multiple_instances(user_data=None) as aut_two:
|
2024-03-19 10:17:28 +00:00
|
|
|
with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'):
|
|
|
|
for aut, account in zip([aut_one, aut_two], [user_one, user_two]):
|
|
|
|
aut.attach()
|
|
|
|
main_window.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
|
|
|
|
main_window.authorize_user(account)
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_two.name}, get chat key'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
|
|
|
|
chat_key = profile_popup.copy_chat_key
|
|
|
|
profile_popup.close()
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name}, send contact request to {user_two.name}'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
settings = main_window.left_panel.open_settings()
|
2024-06-18 09:42:55 +00:00
|
|
|
contact_request_form = settings.left_panel.open_messaging_settings().open_contacts_settings().open_contact_request_form()
|
|
|
|
contact_request_form.send(chat_key, f'Hello {user_two.name}')
|
2024-03-19 10:17:28 +00:00
|
|
|
|
|
|
|
with step(f'User {user_two.name}, accept contact request from {user_one.name} via activity center'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
activity_center = ToolBar().open_activity_center()
|
2024-05-30 06:47:42 +00:00
|
|
|
request = activity_center.find_contact_request_in_list(user_one.name, timeout)
|
2024-03-19 10:17:28 +00:00
|
|
|
activity_center.click_activity_center_button(
|
|
|
|
'Contact requests').accept_contact_request(request)
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name} send another message to {user_two.name}, edit it and verify it was changed'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
2024-03-28 08:44:16 +00:00
|
|
|
chat = main_window.left_panel.open_messages_screen().left_panel.click_chat_by_name(user_two.name)
|
2024-03-28 11:17:32 +00:00
|
|
|
chat_message1 = \
|
|
|
|
''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 21))
|
2024-06-18 09:42:55 +00:00
|
|
|
messages_screen.group_chat.send_message_to_group_chat(chat_message1)
|
2024-03-28 11:17:32 +00:00
|
|
|
message = chat.find_message_by_text(chat_message1, 0)
|
2024-03-19 10:17:28 +00:00
|
|
|
additional_text = '?'
|
|
|
|
time.sleep(5)
|
|
|
|
message_actions = message.hover_message()
|
|
|
|
message_actions.edit_message(additional_text)
|
2024-06-18 09:42:55 +00:00
|
|
|
message_object = messages_screen.chat.messages(0)[0]
|
|
|
|
assert chat_message1 + additional_text in message_object.text, \
|
|
|
|
f"Message text is not found in last message"
|
|
|
|
assert message_object.delegate_button.object.isEdited, \
|
|
|
|
f"Message status was not changed to edited"
|
2024-03-19 10:17:28 +00:00
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_two.name} opens 1x1 chat with {user_one.name}'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
2024-03-28 08:44:16 +00:00
|
|
|
messages_screen.left_panel.click_chat_by_name(user_one.name)
|
2024-03-19 10:17:28 +00:00
|
|
|
|
|
|
|
with step(f'User {user_two.name} send reply to {user_one.name}'):
|
2024-03-28 11:17:32 +00:00
|
|
|
chat_message2 = \
|
|
|
|
''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 21))
|
|
|
|
messages_screen.group_chat.send_message_to_group_chat(chat_message2)
|
2024-06-18 09:42:55 +00:00
|
|
|
message_object_0 = messages_screen.chat.messages(0)[0]
|
|
|
|
assert chat_message2 in message_object_0.text, \
|
|
|
|
f"Message text is not found in the last message"
|
|
|
|
message_object_1 = messages_screen.chat.messages(1)[0]
|
|
|
|
assert chat_message1 in message_object_1.text,\
|
|
|
|
f"Message text is not found in the last message"
|
2024-03-19 10:17:28 +00:00
|
|
|
|
|
|
|
with step(f'User {user_two.name} send emoji to {user_one.name}'):
|
|
|
|
messages_screen.group_chat.send_emoji_to_chat(emoji)
|
2024-06-18 09:42:55 +00:00
|
|
|
message_object = messages_screen.chat.messages(0)[0]
|
|
|
|
assert '😎' in message_object.text
|
2024-05-30 06:47:42 +00:00
|
|
|
|
|
|
|
with step(f'User {user_two.name} send image to {user_one.name} and verify it was sent'):
|
|
|
|
messages_screen.group_chat.send_image_to_chat(str(path))
|
|
|
|
message_object = messages_screen.chat.messages(0)[0]
|
2024-06-18 09:42:55 +00:00
|
|
|
assert message_object.image_message.visible,\
|
|
|
|
f"Message text is not found in the last message"
|
2024-03-19 10:17:28 +00:00
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name}, received reply from {user_two.name}'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
2024-05-30 06:47:42 +00:00
|
|
|
time.sleep(4)
|
2024-06-18 09:42:55 +00:00
|
|
|
message_object = messages_screen.chat.messages(2)[0]
|
|
|
|
assert driver.waitFor(lambda: chat_message2 in message_object.text),\
|
|
|
|
f"Message text is not found in the last message"
|
2024-03-19 10:17:28 +00:00
|
|
|
|
|
|
|
with step(f'User {user_one.name}, received emoji from {user_two.name}'):
|
2024-06-18 09:42:55 +00:00
|
|
|
message_object = messages_screen.chat.messages(1)[0]
|
|
|
|
assert driver.waitFor(lambda: '😎' in message_object.text, timeout),\
|
|
|
|
f"Message text is not found in the last message"
|
2024-05-30 06:47:42 +00:00
|
|
|
|
|
|
|
with step(f'User {user_one.name}, received image from {user_two.name}'):
|
|
|
|
message_object = messages_screen.chat.messages(0)[0]
|
2024-06-18 09:42:55 +00:00
|
|
|
assert message_object.image_message.visible,\
|
|
|
|
f"There is no image in the last message"
|
2024-03-19 10:17:28 +00:00
|
|
|
|
2024-04-16 10:38:31 +00:00
|
|
|
with step(f'User {user_one.name}, reply to own message and verify that message displayed as a reply'):
|
|
|
|
chat_message_reply = \
|
|
|
|
''.join(random.choice(string.ascii_letters + string.digits) for _ in range(1, 21))
|
|
|
|
message.hover_message().reply_own_message(chat_message_reply)
|
|
|
|
chat = main_window.left_panel.open_messages_screen().left_panel.click_chat_by_name(user_two.name)
|
|
|
|
message = chat.find_message_by_text(chat_message_reply, 0)
|
2024-06-18 09:42:55 +00:00
|
|
|
assert message.reply_corner.exists,\
|
|
|
|
f"Last message does not have reply corner"
|
2024-04-16 10:38:31 +00:00
|
|
|
|
2024-05-30 06:47:42 +00:00
|
|
|
with step(f'User {user_one.name}, add reaction to the last message and verify it was added'):
|
2024-05-30 09:51:23 +00:00
|
|
|
occurrence = random.randint(1, 6)
|
2024-05-30 09:41:16 +00:00
|
|
|
message.open_context_menu_for_message().add_reaction_to_message(occurrence)
|
|
|
|
assert driver.waitFor(lambda: EMOJI_PATHES[occurrence - 1] == message.get_emoji_reactions_pathes()[0],
|
2024-06-18 09:42:55 +00:00
|
|
|
timeout),\
|
|
|
|
f"Emoji reaction is not correct"
|
2024-05-30 09:41:16 +00:00
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_two.name}, also see emoji reaction on the last message'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
message = chat.find_message_by_text(chat_message_reply, 0)
|
|
|
|
assert driver.waitFor(lambda: EMOJI_PATHES[occurrence - 1] == message.get_emoji_reactions_pathes()[0],
|
2024-06-18 09:42:55 +00:00
|
|
|
timeout),\
|
|
|
|
f"Emoji reaction is not correct"
|
2024-05-30 09:41:16 +00:00
|
|
|
main_window.hide()
|
2024-05-30 06:47:42 +00:00
|
|
|
|
2024-03-19 10:17:28 +00:00
|
|
|
with step(f'User {user_one.name}, delete own message and verify it was deleted'):
|
2024-05-30 09:41:16 +00:00
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
message = chat.find_message_by_text(chat_message_reply, 0)
|
2024-03-19 10:17:28 +00:00
|
|
|
message.hover_message().delete_message()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name}, cannot delete {user_two.name} message'):
|
2024-04-16 10:38:31 +00:00
|
|
|
message = messages_screen.left_panel.click_chat_by_name(user_two.name).find_message_by_text(chat_message2,
|
2024-05-30 06:47:42 +00:00
|
|
|
3)
|
2024-06-18 09:42:55 +00:00
|
|
|
assert not message.hover_message().is_delete_button_visible(),\
|
|
|
|
f"Delete button is visible although it should not be"
|
2024-04-16 10:38:31 +00:00
|
|
|
|
|
|
|
with step(f'User {user_one.name}, clears chat history'):
|
2024-06-18 09:42:55 +00:00
|
|
|
messages_screen.group_chat.clear_history()
|
2024-04-16 10:38:31 +00:00
|
|
|
messages = messages_screen.chat.messages(index=None)
|
2024-06-18 09:42:55 +00:00
|
|
|
assert len(messages) == 0, f"The history of messages is not empty"
|
2024-04-16 10:38:31 +00:00
|
|
|
assert user_two.name in messages_screen.left_panel.get_chats_names, f'{chat} is not present in chats list'
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'Verify chat history was not cleared for {user_two.name} '):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
messages_screen.left_panel.click_chat_by_name(user_one.name)
|
|
|
|
messages = messages_screen.chat.messages(index=None)
|
2024-06-18 09:42:55 +00:00
|
|
|
assert len(messages) != 0, f"The history of messages is empty"
|
2024-04-16 10:38:31 +00:00
|
|
|
|
|
|
|
with step(f'User {user_two.name} close chat'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
2024-06-18 09:42:55 +00:00
|
|
|
messages_screen.group_chat.close_chat()
|
2024-04-16 10:38:31 +00:00
|
|
|
assert user_one.name not in messages_screen.left_panel.get_chats_names, f'{chat} is present in chats list'
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name} sees chat in the list'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
assert driver.waitFor(lambda: user_two.name in messages_screen.left_panel.get_chats_names,
|
2024-05-30 06:47:42 +00:00
|
|
|
timeout), f'{chat} is present in chats list'
|
2024-03-19 10:17:28 +00:00
|
|
|
main_window.hide()
|