2023-10-06 03:02:48 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
|
|
|
from allure_commons._allure import step
|
2024-02-02 10:22:52 +00:00
|
|
|
|
|
|
|
import driver
|
2023-12-07 16:47:34 +00:00
|
|
|
from . import marks
|
2023-10-06 03:02:48 +00:00
|
|
|
|
|
|
|
import configs.testpath
|
|
|
|
import constants
|
|
|
|
from constants import UserAccount
|
2023-11-27 10:44:42 +00:00
|
|
|
from constants.messaging import Messaging
|
2023-10-06 03:02:48 +00:00
|
|
|
from gui.main_window import MainWindow
|
|
|
|
from gui.screens.messages import MessagesScreen
|
|
|
|
|
2023-12-07 16:47:34 +00:00
|
|
|
pytestmark = marks
|
2023-10-06 03:02:48 +00:00
|
|
|
|
2023-12-27 08:09:56 +00:00
|
|
|
|
2023-10-06 03:02:48 +00:00
|
|
|
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703014', 'Create a group and send messages')
|
|
|
|
@pytest.mark.case(703014)
|
2024-02-15 07:46:50 +00:00
|
|
|
@pytest.mark.timeout(timeout=315)
|
2023-10-06 03:02:48 +00:00
|
|
|
@pytest.mark.parametrize('user_data_one, user_data_two, user_data_three', [
|
2024-03-27 10:17:55 +00:00
|
|
|
(configs.testpath.TEST_USER_DATA / 'group_chat_user_1', configs.testpath.TEST_USER_DATA / 'group_chat_user_2',
|
|
|
|
configs.testpath.TEST_USER_DATA / 'group_chat_user_3')
|
2023-10-06 03:02:48 +00:00
|
|
|
])
|
2024-03-27 09:38:50 +00:00
|
|
|
def test_group_chat(multiple_instances, user_data_one, user_data_two, user_data_three):
|
2023-10-06 03:02:48 +00:00
|
|
|
user_one: UserAccount = constants.user_account_one
|
|
|
|
user_two: UserAccount = constants.user_account_two
|
|
|
|
user_three: UserAccount = constants.user_account_three
|
|
|
|
members = [user_two.name, user_three.name]
|
|
|
|
main_window = MainWindow()
|
|
|
|
messages_screen = MessagesScreen()
|
|
|
|
|
2024-03-27 09:38:50 +00:00
|
|
|
with multiple_instances() as aut_one, multiple_instances() as aut_two, multiple_instances() as aut_three:
|
2023-10-06 03:02:48 +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, aut_three], [user_one, user_two, user_three]):
|
|
|
|
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()
|
2023-12-13 08:20:56 +00:00
|
|
|
profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
|
2024-02-02 06:38:41 +00:00
|
|
|
chat_key = profile_popup.copy_chat_key
|
2023-10-06 03:02:48 +00:00
|
|
|
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()
|
|
|
|
messaging_settings = settings.left_panel.open_messaging_settings()
|
|
|
|
contacts_settings = messaging_settings.open_contacts_settings()
|
|
|
|
contact_request_popup = contacts_settings.open_contact_request_form()
|
|
|
|
contact_request_popup.send(chat_key, f'Hello {user_two.name}')
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_two.name}, accept contact request from {user_one.name}'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
settings = main_window.left_panel.open_settings()
|
|
|
|
messaging_settings = settings.left_panel.open_messaging_settings()
|
|
|
|
contacts_settings = messaging_settings.open_contacts_settings()
|
|
|
|
contacts_settings.accept_contact_request(user_one.name)
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_three.name}, get chat key'):
|
|
|
|
aut_three.attach()
|
|
|
|
main_window.prepare()
|
2023-12-13 08:20:56 +00:00
|
|
|
profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
|
2024-02-02 06:38:41 +00:00
|
|
|
chat_key = profile_popup.copy_chat_key
|
2023-10-06 03:02:48 +00:00
|
|
|
profile_popup.close()
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name}, send contact request to {user_three.name}'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
settings = main_window.left_panel.open_settings()
|
|
|
|
messaging_settings = settings.left_panel.open_messaging_settings()
|
|
|
|
contacts_settings = messaging_settings.open_contacts_settings()
|
|
|
|
contact_request_popup = contacts_settings.open_contact_request_form()
|
|
|
|
contact_request_popup.send(chat_key, f'Hello {user_three.name}')
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_three.name}, accept contact request from {user_one.name}'):
|
|
|
|
aut_three.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
settings = main_window.left_panel.open_settings()
|
|
|
|
messaging_settings = settings.left_panel.open_messaging_settings()
|
|
|
|
contacts_settings = messaging_settings.open_contacts_settings()
|
|
|
|
contacts_settings.accept_contact_request(user_one.name)
|
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name}, start chat and add {user_two.name}'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_window.prepare()
|
|
|
|
main_window.left_panel.open_messages_screen()
|
|
|
|
messages_screen.left_panel.start_chat().create_chat(members)
|
|
|
|
|
|
|
|
with step('Verify group chat info'):
|
|
|
|
with step('Verify group chat name'):
|
|
|
|
group_chat_name = user_two.name + '&' + user_three.name
|
|
|
|
assert messages_screen.group_chat.group_name == group_chat_name, f'Group chat name is not correct'
|
|
|
|
with step('Welcome group message is correct'):
|
|
|
|
actual_welcome_message = messages_screen.group_chat.group_welcome_message
|
2023-11-27 10:44:42 +00:00
|
|
|
assert actual_welcome_message.startswith(Messaging.WELCOME_GROUP_MESSAGE.value)
|
2023-10-06 03:02:48 +00:00
|
|
|
assert actual_welcome_message.endswith(' group!')
|
|
|
|
assert group_chat_name in actual_welcome_message
|
|
|
|
with step('Verify there are three members in group members list'):
|
|
|
|
assert user_one.name in messages_screen.right_panel.members
|
|
|
|
assert user_two.name in messages_screen.right_panel.members
|
|
|
|
assert user_three.name in messages_screen.right_panel.members
|
|
|
|
assert len(messages_screen.right_panel.members) == 3
|
|
|
|
|
|
|
|
with step('Open edit group name and image form and change name'):
|
|
|
|
new_name = 'New_name'
|
|
|
|
edit_group_popup = messages_screen.group_chat.open_edit_group_name_form()
|
|
|
|
edit_group_popup.change_group_name(new_name)
|
|
|
|
edit_group_popup.save_changes()
|
|
|
|
|
|
|
|
with step('Verify group chat name is changed'):
|
|
|
|
assert messages_screen.group_chat.group_name == new_name
|
|
|
|
|
|
|
|
with step('Send message to group chat and verify it was sent'):
|
|
|
|
messages_screen.group_chat.send_message_to_group_chat('Hi')
|
2024-02-29 05:01:48 +00:00
|
|
|
message_objects = messages_screen.chat.messages('0')
|
2023-10-06 03:02:48 +00:00
|
|
|
message_items = [message.text for message in message_objects]
|
|
|
|
for message_item in message_items:
|
|
|
|
assert 'Hi' in message_item
|
|
|
|
|
2024-02-02 10:22:52 +00:00
|
|
|
with step(f'Remove {user_three.name} from group'):
|
|
|
|
messages_screen.group_chat.remove_member_from_chat(user_three.name)
|
2023-10-06 03:02:48 +00:00
|
|
|
|
2024-02-02 10:22:52 +00:00
|
|
|
with step('Verify there are two members in group members list'):
|
|
|
|
assert driver.waitFor(lambda: user_one.name in messages_screen.right_panel.members, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
assert user_two.name in messages_screen.right_panel.members
|
|
|
|
assert len(messages_screen.right_panel.members) == 2
|
2023-10-06 03:02:48 +00:00
|
|
|
main_window.hide()
|
|
|
|
|
|
|
|
with step(f'Restart app for {user_two.name} and open group chat'):
|
|
|
|
aut_two.restart()
|
|
|
|
main_window.authorize_user(user_two)
|
|
|
|
messages_screen.left_panel.open_chat(new_name)
|
|
|
|
|
2024-02-02 10:22:52 +00:00
|
|
|
with step('Verify there are three members in group members list'):
|
|
|
|
assert user_one.name in messages_screen.right_panel.members
|
2023-10-06 03:02:48 +00:00
|
|
|
assert user_two.name in messages_screen.right_panel.members
|
|
|
|
assert len(messages_screen.right_panel.members) == 2
|
|
|
|
|
|
|
|
with step('Send message to group chat and verify it was sent'):
|
|
|
|
messages_screen.group_chat.send_message_to_group_chat('Hi')
|
2024-02-29 05:01:48 +00:00
|
|
|
message_objects = messages_screen.chat.messages('1')
|
2023-10-06 03:02:48 +00:00
|
|
|
message_items = [message.text for message in message_objects]
|
|
|
|
for message_item in message_items:
|
|
|
|
assert 'Hi' in message_item
|
|
|
|
|
|
|
|
with step('Leave group'):
|
|
|
|
messages_screen.left_panel.open_leave_group_popup(new_name).confirm_leaving()
|
|
|
|
|
|
|
|
with step('Check that group name is not displayed on left panel'):
|
|
|
|
assert new_name not in messages_screen.left_panel.contacts
|
|
|
|
main_window.hide()
|
|
|
|
|
2024-02-02 10:22:52 +00:00
|
|
|
with step(f'Restart app for {user_three.name} and verify that user is not the member of chat'):
|
2023-10-06 03:02:48 +00:00
|
|
|
aut_three.restart()
|
|
|
|
main_window.authorize_user(user_three)
|
2024-02-02 10:22:52 +00:00
|
|
|
|
|
|
|
with step('Check that {user_three.name} is not a member of a group'):
|
|
|
|
messages_screen.left_panel.open_chat(new_name)
|
|
|
|
gray_message_text = messages_screen.group_chat.gray_text_from_message_area
|
|
|
|
assert gray_message_text == Messaging.YOU_NEED_TO_BE_A_MEMBER.value
|
|
|
|
assert not messages_screen.group_chat.is_message_area_enabled
|
|
|
|
|
|
|
|
with step(f'Restart app for {user_one.name} and open group chat'):
|
|
|
|
aut_one.restart()
|
|
|
|
main_window.authorize_user(user_one)
|
2023-10-06 03:02:48 +00:00
|
|
|
messages_screen.left_panel.open_chat(new_name)
|
|
|
|
|
|
|
|
with step('Verify there is one member in group members list'):
|
2024-02-02 10:22:52 +00:00
|
|
|
assert user_one.name in messages_screen.right_panel.members
|
2023-10-06 03:02:48 +00:00
|
|
|
assert len(messages_screen.right_panel.members) == 1
|
|
|
|
|
|
|
|
with step('Leave group'):
|
2024-02-02 10:22:52 +00:00
|
|
|
messages_screen.group_chat.leave_group().confirm_leaving()
|
2023-10-06 03:02:48 +00:00
|
|
|
|
|
|
|
with step('Check that group name is not displayed on left panel'):
|
|
|
|
assert new_name not in messages_screen.left_panel.contacts
|